{"id":322699,"date":"2021-05-06T15:00:49","date_gmt":"2021-05-06T15:00:49","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=322699"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=322699","title":{"rendered":"Py4J \u2013 \u043c\u043e\u0441\u0442 \u043c\u0435\u0436\u0434\u0443 Python \u0438 Java"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/a4\/ec\/02\/a4ec02uiv2tpxakenbyhtaygpxm.png\"><\/p>\n<p>  \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 Py4J \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 PySpark, \u043d\u043e \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 Python \u0438 Java. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u0440\u0430\u0442\u043a\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 Py4J, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0441\u0438\u043b\u044c\u043d\u044b\u0435 \u0438 \u0441\u043b\u0430\u0431\u044b\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0412 \u043a\u043e\u043d\u0446\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0441\u0432\u044f\u0437\u0438 Java \u0438 Python. <a name=\"habracut\"><\/a><\/p>\n<p>  Py4J \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u043c, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c \u0432 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0435 Python, \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c Java \u0432\u043d\u0443\u0442\u0440\u0438 JVM. \u041c\u0435\u0442\u043e\u0434\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u0430\u043a, \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0431\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u044b Java \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0432 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0435 Python, \u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u043c Java \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 Python. Py4J \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u043c Java \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b Python, \u043d\u043e \u043d\u0430 \u044d\u0442\u043e\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0435 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f. Py4J \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 <a href=\"https:\/\/www.py4j.org\/advanced_topics.html#accessing-java-collections-and-arrays-from-python\">\u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0437 Python \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 Java<\/a>, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e Array, List, Set \u0438 Map. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/www.py4j.org\/advanced_topics.html#converting-python-collections-to-java-collections\">\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c Python \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0432 Java \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438<\/a>. \u0415\u0449\u0451 \u0438\u0437 Python \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/www.py4j.org\/advanced_topics.html#implementing-java-interfaces-from-python-callback\">\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 Java<\/a>.<\/p>\n<p>  \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/www.jython.org\/\">Jython<\/a>. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043d\u0435\u0433\u043e, Py4J \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043a\u043e\u0434 Python \u0432 JVM, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Py4J \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e Cython. \u0415\u0449\u0451 \u0435\u0441\u0442\u044c <a href=\"https:\/\/jpype.readthedocs.io\/en\/latest\/\">JPype<\/a>, \u043d\u043e Py4J \u043d\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0442\u043e\u043a\u0438 Python \u0438 Java, \u0442\u0430\u043a\u0436\u0435 \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u043e\u043a\u0435\u0442\u044b, \u0430 \u043d\u0435 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Java_Native_Interface\">JNI<\/a> \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u0441 JVM.<\/p>\n<p>  \u0413\u043b\u0430\u0432\u043d\u044b\u043c \u043c\u0438\u043d\u0443\u0441\u043e\u043c Py4J \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 Python \u0438 Java. \u0422\u0430\u043a \u043a\u0430\u043a \u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0441\u043e\u043a\u0435\u0442\u043e\u0432, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442, \u0431\u0443\u0434\u0435\u0442 \u043f\u043b\u043e\u0445\u043e\u0439 \u0438\u0434\u0435\u0435\u0439, \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 Py4J \u2013 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c Java \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Python \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a.<\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b<\/h2>\n<p>  \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u0442\u0440\u0438 Java \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u043e\u0434\u0438\u043d Python \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b. \u041a\u043b\u0430\u0441\u0441 Dict, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 HashMap, \u041a\u043b\u0430\u0441\u0441 DictEntryPoint, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b Python \u043c\u043e\u0433 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430 Dict. \u0422\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u0435\u043d \u043a\u043b\u0430\u0441\u0441 Program, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u0443\u0441\u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>  \u0414\u043b\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b Py4J \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c GatewayServer, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0441\u0432\u044f\u0437\u044c Python \u0441 JVM \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u043a\u0435\u0442 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438. \u0414\u0430\u043b\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Java \u043a\u043e\u0434 \u0438\u0437 Python.<\/p>\n<p>  <b>Dict.java<\/b><\/p>\n<pre><code class=\"java\">  package py4j_example;    import java.util.HashMap;    public class Dict {     private HashMap&lt;Integer, String&gt; dict = new HashMap&lt;&gt;();      \/**     * \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u043e \u043a\u043b\u044e\u0447\u0443     *\/     public void add(Integer key, String value) {          dict.put(key, value);      }      \/**     * \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0435\u0446 HashMap     *\/     public void add(String value) {         dict.put(dict.size(), value);     }      \/**     * \u0423\u0434\u0430\u043b\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0443     *\/     public String remove(Integer key) {         return dict.remove(key);     }      \/**     * \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0443     *\/     public String get(Integer key) {         return dict.get(key);     }      \/**     * \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u043b\u0438\u043d\u0443 HashMap     *\/     public int length() {         return dict.size();     }      \/**     * \u041f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0451\u0442 HashMap     *\/     public void clear() {         dict = new HashMap&lt;&gt;();         add(&quot;\u0417\u0430\u043f\u0438\u0441\u044c \u0438\u0437 Java&quot;);     }   } <\/code><\/pre>\n<p>  <b>DictEntryPoint.java<\/b><\/p>\n<pre><code class=\"java\">  package py4j_example;    import py4j.GatewayServer;    public class DictEntryPoint {     private final Dict dict;      \/**     * \u0421\u043e\u0437\u0434\u0430\u0451\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 Dict     *\/     public DictEntryPoint() {         this.dict = new Dict();     }      \/**     * \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 Dict     *\/     public Dict getDict() {         return this.dict;     }   } <\/code><\/pre>\n<p>  <b>Program.java<\/b><\/p>\n<pre><code class=\"java\">  package py4j_example;    import py4j.GatewayServer;    public class Program {     public static void main(String[] args) {       \/* \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0430 *\/       GatewayServer gatewayServer = new GatewayServer(new DictEntryPoint());       gatewayServer.start();       System.out.println(&quot;Gateway Server Started&quot;);     }   } <\/code><\/pre>\n<p>  \u0412\u044b\u0432\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Program.java \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e Python \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a JVM.<\/p>\n<pre><code class=\"bash\">  Connected to the target VM, address: '127.0.0.1:58425', transport: 'socket'   Gateway Server Started <\/code><\/pre>\n<p>  <b>Application.py<\/b><\/p>\n<pre><code class=\"python\">  from py4j.java_gateway import JavaGateway      def add_some_values(dict):     # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043c\u0451\u043d \u0438 \u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 dict     names = [&quot;\u0412\u0430\u0441\u044f&quot;, &quot;\u0410\u043d\u044f&quot;, &quot;\u041b\u0435\u043d\u0430&quot;, &quot;\u041d\u0438\u043a\u0438\u0442\u0430&quot;]     for name in names:         dict.add(name)      # \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043b\u044e\u0447\u0443 4     deleted = dict.remove(4)      # \u0412\u044b\u0432\u043e\u0434 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e dict     for i in range(dict.length()):         print(i, &quot;\\t&quot;, dict.get(i))      print(&quot;\\n\u0423\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 =&quot;, deleted)     return 1    def main():     # \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f JavaGateway     gateway = JavaGateway()     # \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u043a\u043b\u0430\u0441\u0441\u0430 Dict     dict = gateway.entry_point.getDict()      add_some_values(dict)     # \u041e\u0447\u0438\u0441\u0442\u043a\u0430 Dict     dict.clear()     return 0    if __name__ == &quot;__main__&quot;:       main() <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Application.py \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"bash\">  0 \u0417\u0430\u043f\u0438\u0441\u044c \u0438\u0437 Java   1 \u0412\u0430\u0441\u044f   2 \u0410\u043d\u044f   3 \u041b\u0435\u043d\u0430    \u0423\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 = \u041d\u0438\u043a\u0438\u0442\u0430 <\/code><\/pre>\n<p>  \u041f\u043e \u043a\u043b\u044e\u0447\u0443 0 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0438\u0437 Java, \u0430 \u0438\u043c\u0435\u043d\u0430 \u043b\u044e\u0434\u0435\u0439 \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  Py4J \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u043b\u0435\u0433\u043a\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 Java \u0438\u0437 Python, \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0434\u0432\u0443\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u043c\u0438 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c\u0438 \u0432 \u0434\u0432\u0443\u0445 \u044f\u0437\u044b\u043a\u0430\u0445, \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0438 JVM \u0441\u043e\u043a\u0435\u0442\u0430\u043c\u0438. \u041e\u043d \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0445 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Python, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<ul>\n<li> <a href=\"https:\/\/www.py4j.org\/index.html\">\u041e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0430\u0439\u0442<\/a>   <\/li>\n<li> <a href=\"https:\/\/www.py4j.org\/contents.html\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/a>   <\/li>\n<li> <a href=\"https:\/\/github.com\/bartdag\/py4j\">github<\/a>   <\/li>\n<\/ul>\n<p>  <\/p>\n<hr>\n<p>  <\/p>\n<h4>\u041d\u0430 \u043f\u0440\u0430\u0432\u0430\u0445 \u0440\u0435\u043a\u043b\u0430\u043c\u044b<\/h4>\n<p>  VDSina \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 <a href=\"https:\/\/vdsina.ru\/cloud-servers?partner=habr350\">\u0431\u044b\u0441\u0442\u0440\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u044b<\/a> \u0432 \u0430\u0440\u0435\u043d\u0434\u0443 \u043f\u043e\u0434 \u043b\u044e\u0431\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438, \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u041e\u0421 \u0441 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e <a href=\"https:\/\/vdsina.ru\/qa\/q\/kak-ispolzovat-svoy-obraz-iso-v-vds?partner=habr114\">ISO<\/a>, \u0443\u0434\u043e\u0431\u043d\u0430\u044f <a href=\"https:\/\/habr.com\/ru\/company\/vdsina\/blog\/460107\/\">\u043f\u0430\u043d\u0435\u043b\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f<\/a> \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043f\u043e\u0441\u0443\u0442\u043e\u0447\u043d\u0430\u044f \u043e\u043f\u043b\u0430\u0442\u0430.<\/p>\n<p>  \u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u043d\u0430 <a href=\"https:\/\/t.me\/vdsina\">\u043d\u0430\u0448 \u0447\u0430\u0442 \u0432 Telegram<\/a>.<\/p>\n<p>  <a href=\"https:\/\/vdsina.ru\/cloud-servers?partner=habr350\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/8p\/3v\/z4\/8p3vz47nluspfyc0axlkx88gdua.png\"><\/a><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/vdsina\/blog\/555140\/\"> https:\/\/habr.com\/ru\/company\/vdsina\/blog\/555140\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/a4\/ec\/02\/a4ec02uiv2tpxakenbyhtaygpxm.png\"><\/p>\n<p>  \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 Py4J \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 PySpark, \u043d\u043e \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 Python \u0438 Java. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u0440\u0430\u0442\u043a\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 Py4J, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0441\u0438\u043b\u044c\u043d\u044b\u0435 \u0438 \u0441\u043b\u0430\u0431\u044b\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0412 \u043a\u043e\u043d\u0446\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0441\u0432\u044f\u0437\u0438 Java \u0438 Python. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-322699","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322699","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=322699"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322699\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=322699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=322699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=322699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}