| [ Web Proxy ] |
| Viewing: https://spark.apache.org/docs/latest/api/python/reference/api/pyspark.RDD.saveAsSequenceFile.html | [Back] [Original] |
Site Navigation
Site Navigation
Section Navigation
Output a Python RDD of key-value pairs (of form RDD[(K, V)]) to any Hadoop file
system, using the org.apache.hadoop.io.Writable types that we convert from the
RDDs key and value types. The mechanism is as follows:
Pickle is used to convert pickled Python RDD into RDD of Java objects.
Keys and values of this Java RDD are converted to Writables and written out.
New in version 1.1.0.
path to sequence file
fully qualified classname of the compression codec class i.e. org.apache.hadoop.io.compress.GzipCodec (None by default)
See also
Examples
>>> import os
>>> import tempfile
Set the related classes
>>> with tempfile.TemporaryDirectory(prefix="saveAsSequenceFile") as d:
... path = os.path.join(d, "sequence_file")
...
... # Write a temporary sequence file
... rdd = sc.parallelize([(1, ""), (1, "a"), (3, "x")])
... rdd.saveAsSequenceFile(path)
...
... # Load this sequence file as an RDD
... loaded = sc.sequenceFile(path)
... sorted(loaded.collect())
[(1, ''), (1, 'a'), (3, 'x')]
Copyright @ 2026 The Apache Software Foundation, Licensed under the Apache License, Version 2.0.
Created using Sphinx 4.5.0.
Built with the PyData Sphinx Theme 0.13.3.
| Web Proxy Viewer | New URL | Original Page |