Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #
""" This class wraps a function RDD[X] -> RDD[Y] that was passed to DStream.transform(), allowing it to be called from Java via Py4J's callback server.
Java calls this function with a sequence of JavaRDDs and this function returns a single JavaRDD pointer back to Java. """
# Clear the failure # stopped return
# extend deserializers with the first one
for jrdd, ser in zip(jrdds, sers)] # Here, we work around to ensure `_jrdd` is `JavaRDD` by wrapping it by `map`. # org.apache.spark.streaming.api.python.PythonTransformFunction requires to return # `JavaRDD`; however, this could be `JavaPairRDD` by some APIs, for example, `zip`. # See SPARK-17756. else:
return "TransformFunction(%s)" % self.func
""" This class implements a serializer for PythonTransformFunction Java objects.
This is necessary because the Java PythonTransformFunction objects are actually Py4J references to Python objects and thus are not directly serializable. When Java needs to serialize a PythonTransformFunction, it uses this class to invoke Python, which returns the serialized function as a byte array. """
# Clear the failure func.func, func.rdd_wrap_func, func.deserializers)))
# Clear the failure except: self.failure = traceback.format_exc()
return "TransformFunctionSerializer(%s)" % self.serializer
""" Return string prefix-time(.suffix)
Examples -------- >>> rddToFileName("spark", None, 12345678910) 'spark-12345678910' >>> rddToFileName("spark", "tmp", 12345678910) 'spark-12345678910.tmp' """ else:
sys.exit(-1) |