• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python java_gateway.java_import函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中py4j.java_gateway.java_import函数的典型用法代码示例。如果您正苦于以下问题:Python java_import函数的具体用法?Python java_import怎么用?Python java_import使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了java_import函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, mrgeo):
     self._mrgeo = mrgeo
     jvm = self._mrgeo._get_jvm()
     # Import the raster map op test support class and all other needed classes
     java_import(jvm, "org.mrgeo.mapalgebra.InlineCsvMapOp")
     self._jvm = jvm
     self._sparkContext = mrgeo.sparkContext
开发者ID:ericwood73,项目名称:mrgeo,代码行数:7,代码来源:vectormapoptestsupport.py


示例2: __init__

    def __init__(self, language, gateway, **kwargs):
        '''
        Constructor
        @param language: The language code for the proper initialization of this language-dependent tool
        @type language: string
        @param gateway: An already initialized Py4j java gateway
        @type gateway: py4j.java_gateway.JavaGateway
        '''
        self.language = language
        #self.jvm = JVM(java_classpath)
        #socket_no = self.jvm.socket_no
        #gatewayclient = GatewayClient('localhost', socket_no)
        #gateway = JavaGateway(gatewayclient, auto_convert=True, auto_field=True)
        #sys.stderr.write("Initialized local Java gateway with pid {} in socket {}\n".format(self.jvm.pid, socket_no))
    
        self.meteor_view = gateway.new_jvm_view()
        #import necessary java packages from meteor jar
        java_import(self.meteor_view, 'edu.cmu.meteor.scorer.*')
        java_import(self.meteor_view, 'edu.cmu.meteor.util.*')
#        java_import(self.meteor_view, '')
        
        #pass the language setting into the meteor configuration object
        config = self.meteor_view.MeteorConfiguration();
        config.setLanguage(language);
        #initialize object with the given config
        sys.stderr.write("If next line displays error, it is not critical, but METEOR language-specific transducer must be installed.")
        self.scorer = self.meteor_view.MeteorScorer(config)
开发者ID:lefterav,项目名称:qualitative,代码行数:27,代码来源:meteor.py


示例3: _do_init

 def _do_init(self, *args, **kwargs):
     # Modifies base _do_init to add a Java-Cassandra SparkContext (jcsc)
     # to the instance
     super(CassandraSparkContext, self)._do_init(*args, **kwargs)
     java_import(self._jvm, "com.datastax.spark.connector.CassandraJavaUtil")
     java_import(self._jvm, "com.datastax.spark.connector.RowConvertingIterator")
     self._jcsc = self._jvm.CassandraJavaUtil.javaFunctions(self._jsc)
开发者ID:awaemmanuel,项目名称:pyspark-cassandra,代码行数:7,代码来源:pyspark_cassandra.py


示例4: main

def main():
    if len(sys.argv) != 3:
        print >> sys.stderr, "Usage: example <keyspace_name> <column_family_name>"
        sys.exit(-1)

    keyspace_name = sys.argv[1]
    column_family_name = sys.argv[2]

    # Valid config options here https://github.com/datastax/spark-cassandra-connector/blob/master/doc/1_connecting.md
    conf = SparkConf().set("spark.cassandra.connection.host", "127.0.0.1")

    sc = SparkContext(appName="Spark + Cassandra Example",
                      conf=conf)

    # import time; time.sleep(30)
    java_import(sc._gateway.jvm, "com.datastax.spark.connector.CassandraJavaUtil")
    print sc._jvm.CassandraJavaUtil

    users = (
        ["Mike", "Sukmanowsky"],
        ["Andrew", "Montalenti"],
        ["Keith", "Bourgoin"],
    )
    rdd = sc.parallelize(users)
    print rdd.collect()
开发者ID:NunoEdgarGub1,项目名称:pyspark-cassandra,代码行数:25,代码来源:cassandra_example.py


示例5: start_gateway_server

def start_gateway_server():
    classPath = compute_classpath(DDF_HOME)
    # launch GatewayServer in a new process
    javaopts = os.getenv('JAVA_OPTS')
    if javaopts is not None:
        javaopts = javaopts.split()
    else:
        javaopts = []
    #command = ["java", "-classpath", classPath] + ["-Dlog4j.configuration=file:"+ DDF_HOME + "/core/conf/local/ddf-local-log4j.properties"] + ["py4j.GatewayServer", "--die-on-broken-pipe", "0"]
    command = ["java", "-classpath", classPath] + javaopts + ["py4j.GatewayServer", "--die-on-broken-pipe", "0"]
    
    proc = Popen(command, stdout = PIPE, stdin = PIPE, preexec_fn = preexec_func)
    # get the port of the GatewayServer
    port = int(proc.stdout.readline())

    class JavaOutputThread(Thread):
        def __init__(self, stream):
            Thread.__init__(self)
            self.daemon = True
            self.stream = stream

        def run(self):
            while True:
                line = self.stream.readline()
                sys.stderr.write(line)
    JavaOutputThread(proc.stdout).start()
    # connect to the gateway server
    gateway = JavaGateway(GatewayClient(port = port), auto_convert = False)
    java_import(gateway.jvm, "io.ddf.*")
    java_import(gateway.jvm, "io.ddf.spark.*")
    return gateway
开发者ID:Tarrasch,项目名称:DDF,代码行数:31,代码来源:gateway.py


示例6: singlethread

def singlethread(java_classpath):
    print "Thread starting"
    
    jvm = JVM(java_classpath, dir_path)
    socket_no = self.jvm.socket_no
    gatewayclient = GatewayClient('localhost', socket_no)
    gateway = JavaGateway(gatewayclient, auto_convert=True, auto_field=True)
    sys.stderr.write("Initialized global Java gateway with pid {} in socket {}\n".format(self.jvm.pid, socket_no))

    
    gatewayclient = GatewayClient('localhost', socket_no)
    print "Gclient started"
    gateway = JavaGateway(gatewayclient, auto_convert=True, auto_field=True)
    print "Java Gateway started"
    #create a new view for the jvm
    meteor_view = gateway.new_jvm_view()
    #import required packages
    java_import(meteor_view, 'edu.cmu.meteor.scorer.*')
    #initialize the java object
    java_import(meteor_view, 'edu.cmu.meteor.util.*')
    print "Modules imported"
    #pass the language setting into the meteor configuration object
    config = meteor_view.MeteorConfiguration();
    config.setLanguage("en");
    scorer = meteor_view.MeteorScorer(config)
    print "object initialized"
    #run object function
    stats = scorer.getMeteorStats("Test sentence", "Test sentence !");
    print stats.score
    return 1
开发者ID:lefterav,项目名称:qualitative,代码行数:30,代码来源:testmeteor.py


示例7: _connect

 def _connect(self, gateway, grammarfile):        
     module_view = gateway.new_jvm_view()      
     java_import(module_view, 'BParser')
     
     # get the application instance
     log.info("Grammar file: {}".format(grammarfile))
     self.bp_obj =  module_view.BParser(grammarfile)
     sys.stderr.write("got BParser object\n")
开发者ID:lefterav,项目名称:qualitative,代码行数:8,代码来源:berkeleyparsersocket.py


示例8: scala_set_to_set

def scala_set_to_set(ctx, x):
    from py4j.java_gateway import java_import

    # import scala
    java_import(ctx._jvm, 'scala')

    # grab Scala's set converter and convert to a Python set
    return set(ctx._jvm.scala.collection.JavaConversions.setAsJavaSet(x))
开发者ID:MoherX,项目名称:odo,代码行数:8,代码来源:sparksql.py


示例9: get_smoothing_method

    def get_smoothing_method(self, spark_context):
        java_import(spark_context._jvm, ClassNames.WEIGHTS)
        java_import(spark_context._jvm, ClassNames.WEIGHTED_MOVING_AVERAGE)
        java_weights = spark_context._jvm.Weights(self.__python_weights.limit())
        for index in range(self.__window_size):
            java_weights.add(self.__python_weights.get(index))

        return spark_context._jvm.WeightedMovingAverageMethod(self.__window_size, java_weights)
开发者ID:sitaramyadav,项目名称:prep-buddy,代码行数:8,代码来源:smoothing_algorithms.py


示例10: launch_gateway

def launch_gateway():
    if "MRGEO_GATEWAY_PORT" in os.environ:
        gateway_port = int(os.environ["MRGEO_GATEWAY_PORT"])
    else:
        # Launch the Py4j gateway using the MrGeo command so that we pick up the proper classpath

        script = find_script()

        # Start a socket that will be used by PythonGatewayServer to communicate its port to us
        callback_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        callback_socket.bind(('127.0.0.1', 0))
        callback_socket.listen(1)
        callback_host, callback_port = callback_socket.getsockname()
        env = dict(os.environ)
        env['_MRGEO_DRIVER_CALLBACK_HOST'] = callback_host
        env['_MRGEO_DRIVER_CALLBACK_PORT'] = str(callback_port)

        command = [script, "python", "-v", "-h", callback_host, "-p", str(callback_port)]

        # Launch the Java gateway.
        # We open a pipe to stdin so that the Java gateway can die when the pipe is broken
        # Don't send ctrl-c / SIGINT to the Java gateway:
        def preexec_func():
            signal.signal(signal.SIGINT, signal.SIG_IGN)

        proc = Popen(command, stdin=PIPE, preexec_fn=preexec_func, env=env)

        gateway_port = None
        # We use select() here in order to avoid blocking indefinitely if the subprocess dies
        # before connecting
        while gateway_port is None and proc.poll() is None:
            timeout = 1  # (seconds)
            readable, _, _ = select.select([callback_socket], [], [], timeout)
            if callback_socket in readable:
                gateway_connection = callback_socket.accept()[0]
                # Determine which ephemeral port the server started on:
                gateway_port = read_int(gateway_connection.makefile(mode="rb"))
                gateway_connection.close()
                callback_socket.close()

        if gateway_port is None:
            raise Exception("Java gateway process exited before sending the driver its port number")

    print("Talking with MrGeo on port " + str(gateway_port))

    # Connect to the gateway
    gateway = JavaGateway(GatewayClient(port=gateway_port), auto_convert=True)

    # Import the classes used by MrGeo
    java_import(gateway.jvm, "org.mrgeo.python.*")

    # Import classes used by Spark
    java_import(gateway.jvm, "org.apache.spark.SparkConf")
    java_import(gateway.jvm, "org.apache.spark.api.java.*")
    java_import(gateway.jvm, "org.apache.spark.api.python.*")
    java_import(gateway.jvm, "org.apache.spark.mllib.api.python.*")

    return gateway
开发者ID:tulika-chaterjee,项目名称:mrgeo,代码行数:58,代码来源:java_gateway.py


示例11: _getSome

    def _getSome(self, value):
        java_import(self._jvm, "scala.Some")
        return self._jvm.Some(value)




# suite = TestLoader().loadTestsFromTestCase(MrGeoLocalIntegrationTests)
# TextTestRunner(verbosity=2).run(suite)
开发者ID:ericwood73,项目名称:mrgeo,代码行数:9,代码来源:crop_tests.py


示例12: setUp

 def setUp(self):
     conf = SparkConf().setAppName('test').setMaster('local[*]')
     pwd = os.path.dirname(os.path.realpath(__file__))
     metastore_dir = os.path.abspath(os.path.join(pwd, '..',
                                                  'metastore_db'))
     silentremove(os.path.join(metastore_dir, "dbex.lck"))
     silentremove(os.path.join(metastore_dir, "db.lck"))
     self.sc = SparkContext(conf=conf)
     self.jvm = self.sc._gateway.jvm
     java_import(self.jvm, "org.apache.spark.sql.*")
开发者ID:addisonj,项目名称:spark-jobserver,代码行数:10,代码来源:apitests.py


示例13: createColor

def createColor(r, g, b):    

    global _gateway
    if _gateway is None:
        _gateway = JavaGateway()
        
    jvm = _gateway.jvm

    java_import(jvm, 'org.eclipse.swt.graphics.*')
    
    return jvm.Color(None, r, g, b)
开发者ID:REJN2,项目名称:scisoft-core,代码行数:11,代码来源:pyplottingsystem.py


示例14: getPlottingSystem

def getPlottingSystem(plottingSystemName):
    
    global _gateway
    if _gateway is None:
        _gateway = JavaGateway()
        
    jvm = _gateway.jvm
    
    java_import(jvm, 'org.eclipse.dawnsci.plotting.api.*')
    
    return jvm.PlottingFactory.getPlottingSystem(plottingSystemName, True)
开发者ID:REJN2,项目名称:scisoft-core,代码行数:11,代码来源:pyplottingsystem.py


示例15: __init__

    def __init__(self, _jvm, smvconfig):
        self._jvm = _jvm

        self.smvconfig = smvconfig
        self.dsRepoFactories = []

        from py4j.java_gateway import java_import
        java_import(self._jvm, "org.tresamigos.smv.python.SmvPythonHelper")
        java_import(self._jvm, "org.tresamigos.smv.DataSetRepoFactoryPython")

        self.helper = self._jvm.SmvPythonHelper
开发者ID:TresAmigosSD,项目名称:SMV,代码行数:11,代码来源:datasetmgr.py


示例16: getService

def getService(serviceClass):
    
    global _gateway
    if _gateway is None:
        _gateway = JavaGateway()
        
    jvm = _gateway.jvm
    
    java_import(jvm, 'org.dawb.common.services.*')
    
    return jvm.Activator.getService(serviceClass)
开发者ID:REJN2,项目名称:scisoft-core,代码行数:11,代码来源:pyplottingsystem.py


示例17: new_gateway_client

def new_gateway_client():
    global __gateway_server_port

    if __gateway_server_port is None:
        __gateway_server_port = start_gateway_server()

    # connect to the gateway server
    gateway = JavaGateway(GatewayClient(port=__gateway_server_port), auto_convert=False)
    java_import(gateway.jvm, 'io.ddf.*')
    java_import(gateway.jvm, 'io.ddf.spark.*')
    return gateway
开发者ID:datascibox,项目名称:DDF,代码行数:11,代码来源:gateway.py


示例18: createHistogramBound

def createHistogramBound(position, r, g, b):    

    global _gateway
    if _gateway is None:
        _gateway = JavaGateway()
        
    jvm = _gateway.jvm

    java_import(jvm, 'org.eclipse.dawnsci.plotting.api.histogram.*')
    
    return jvm.HistogramBound(position, r, g, b)
开发者ID:REJN2,项目名称:scisoft-core,代码行数:11,代码来源:pyplottingsystem.py


示例19: _create_job

    def _create_job(self):
        if not self._job:
            jvm = self._get_jvm()
            java_import(jvm, "org.mrgeo.job.*")

            appname = "PyMrGeo"

            self._job = jvm.JobArguments()
            java_gateway.set_field(self._job, "name", appname)

            # Yarn in the default
            self.useyarn()
开发者ID:jdunbar921,项目名称:mrgeo,代码行数:12,代码来源:mrgeo.py


示例20: __set_file_type

 def __set_file_type(self, jvm, file_type):
     java_import(jvm, ClassNames.FileType)
     file_types = {
         'CSV': jvm.FileType.CSV,
         'TSV': jvm.FileType.TSV
     }
     if file_type in file_types.values():
         self.__file_type = file_type
     elif file_type.upper() in file_types:
         self.__file_type = file_types[file_type.upper()]
     else:
         raise ValueError('"%s" is not a valid file type\nValid file types are CSV and TSV' % file_type)
开发者ID:data-commons,项目名称:prep-buddy,代码行数:12,代码来源:transformable_rdd.py



注:本文中的py4j.java_gateway.java_import函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python java_gateway.JavaGateway类代码示例发布时间:2022-05-25
下一篇:
Python compat.range函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap