def _py2java(gateway, obj):
if isinstance(obj, RDD):<EOL><INDENT>obj = _to_java_object_rdd(obj)<EOL><DEDENT>elif isinstance(obj, DataFrame):<EOL><INDENT>obj = obj._jdf<EOL><DEDENT>elif isinstance(obj, SparkContext):<EOL><INDENT>obj = obj._jsc<EOL><DEDENT>elif isinstance(obj, (list, tuple)):<EOL><INDENT>obj = ListConverter().convert([_py2java(gateway, x) for x in obj],<EOL>gateway._gateway_client)<EOL><DEDENT>elif isinstance(obj, dict):<EOL><INDENT>result = {}<EOL>for (key, value) in obj.items():<EOL><INDENT>result[key] = _py2java(gateway, value)<EOL><DEDENT>obj = MapConverter().convert(result, gateway._gateway_client)<EOL><DEDENT>elif isinstance(obj, JavaValue):<EOL><INDENT>obj = obj.value<EOL><DEDENT>elif isinstance(obj, JavaObject):<EOL><INDENT>pass<EOL><DEDENT>elif isinstance(obj, (int, long, float, bool, bytes, unicode)):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>data = bytearray(PickleSerializer().dumps(obj))<EOL>obj = gateway.jvm.org.apache.spark.bigdl.api.python.BigDLSerDe.loads(data)<EOL><DEDENT>return obj<EOL>
Convert Python object into Java