spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davies Liu <>
Subject Re: java.lang.NegativeArraySizeException in pyspark
Date Mon, 22 Sep 2014 18:12:11 GMT
The traceback said that the serialized closure cannot be parsed (base64)
correctly by py4j.

The string in Java cannot be longer than 2G, so the serialized closure
cannot longer than 1.5G (there are overhead in base64), is it possible
that your data used in the map function is so big? If it's, you should
use broadcast for it.

In master of Spark, we will use broadcast automatically if the closure
is too big. (but use broadcast explicitly is always better).

On Sat, Sep 20, 2014 at 12:42 PM, Brad Miller
<> wrote:
> Hi All,
> I'm experiencing a java.lang.NegativeArraySizeException in a pyspark script
> I have.  I've pasted the full traceback at the end of this email.
> I have isolated the line of code in my script which "causes" the exception
> to occur. Although the exception seems to occur deterministically, it is
> very unclear why the different variants of the line would cause the
> exception to occur. Unfortunately, I am only able to reproduce the bug in
> the context of a large data processing job, and the line of code which must
> change to reproduce the bug has little meaning out of context.  The bug
> occurs when I call "map" on an RDD with a function that references some
> state outside of the RDD (which is presumably bundled up and distributed
> with the function).  The output of the function is a tuple where the first
> element is an int and the second element is a list of floats (same positive
> length every time, as verified by an 'assert' statement).
> Given that:
> -It's unclear why changes in the line would cause an exception
> -The exception comes from within pyspark code
> -The exception has to do with negative array sizes (and I couldn't have
> created a negative sized array anywhere in my python code)
> I suspect this is a bug in pyspark.
> Has anybody else observed or reported this bug?
> best,
> -Brad
> Traceback (most recent call last):
>   File "/home/bmiller1/pipeline/", line 214, in <module>
>     main()
>   File "/home/bmiller1/pipeline/", line 203, in main
>     bl.write_results(iteration_out_dir)
>   File "/home/bmiller1/pipeline/layer/", line 137, in
> write_results
>     fig, accuracy = _get_results(self.prediction_rdd)
>   File "/home/bmiller1/pipeline/layer/", line 56, in
> _get_results
>     predictions = np.array(prediction_rdd.collect())
>   File "/home/spark/spark-1.1.0-bin-hadoop1/python/pyspark/", line
> 723, in collect
>     bytesInJava = self._jrdd.collect().iterator()
>   File "/home/spark/spark-1.1.0-bin-hadoop1/python/pyspark/", line
> 2026, in _jrdd
>     broadcast_vars, self.ctx._javaAccumulator)
>   File
> "/home/spark/spark-1.1.0-bin-hadoop1/python/lib/",
> line 701, in __call__
>   File
> "/home/spark/spark-1.1.0-bin-hadoop1/python/lib/",
> line 304, in get_return_value
> py4j.protocol.Py4JError: An error occurred while calling
> Trace:
> java.lang.NegativeArraySizeException
> at py4j.Base64.decode(
> at py4j.Protocol.getBytes(
> at py4j.Protocol.getObject(
> at py4j.commands.AbstractCommand.getArguments(
> at py4j.commands.ConstructorCommand.execute(
> at
> at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message