code: public static void saveSequenceFile(String path, JavaRDD<List<Writable>> rdd,  Integer maxOutputFiles) {
          path = FilenameUtils.normalize(path, true);
          if (maxOutputFiles != null) {
              rdd = rdd.coalesce(maxOutputFiles);
          }
          JavaPairRDD<List<Writable>, Long> dataIndexPairs = rdd.zipWithUniqueId(); //Note: Long values are unique + NOT contiguous; more efficient than zipWithIndex
          JavaPairRDD<LongWritable, RecordWritable> keyedByIndex =
                          dataIndexPairs.mapToPair(new RecordSavePrepPairFunction());
  
          keyedByIndex.saveAsNewAPIHadoopFile(path, LongWritable.class, RecordWritable.class,
                          SequenceFileOutputFormat.class);
      }
docs: Save a {@code JavaRDD<List<Writable>>} to a Hadoop {@link org.apache.hadoop.io.SequenceFile}. Each record is given
  a unique (but noncontiguous) {@link LongWritable} key, and values are stored as {@link RecordWritable} instances.
  <p>
  Use {@link #restoreSequenceFile(String, JavaSparkContext)} to restore values saved with this method.
  
  @param path           Path to save the sequence file
  @param rdd            RDD to save
  @param maxOutputFiles Nullable. If non-null: first coalesce the RDD to the specified size (number of partitions)
  to limit the maximum number of output sequence files
  @see #saveSequenceFileSequences(String, JavaRDD)
  @see #saveMapFile(String, JavaRDD)