@Test public void testSave() throws Exception { Configuration conf = getConfiguration(); Writable key = new IntWritable(0); Vector value = new DenseVector(VECTOR); Path path = getTestTempDirPath("output"); VectorCache.save(key, value, path, conf, true, true); SequenceFileValueIterator<VectorWritable> iterator = new SequenceFileValueIterator<VectorWritable>(path, true, conf); try { VectorWritable old = iterator.next(); assertEquals("Saved vector is identical to original", old.get(), value); } finally { Closeables.close(iterator, true); } }
public static void save(Writable key, Vector vector, Path output, Configuration conf, boolean overwritePath, boolean deleteOnExit) throws IOException { FileSystem fs = FileSystem.get(output.toUri(), conf); output = fs.makeQualified(output); if (overwritePath) { HadoopUtil.delete(conf, output); } DistributedCache.setCacheFiles(new URI[]{output.toUri()}, conf); SequenceFile.Writer writer = new SequenceFile.Writer(fs, conf, output, IntWritable.class, VectorWritable.class); try { writer.append(key, new VectorWritable(vector)); } finally { Closeables.close(writer, false); } if (deleteOnExit) { fs.deleteOnExit(output); } }
VectorCache { public static void save(Writable key, Vector vector, Path output, Configuration conf, boolean overwritePath, boolean deleteOnExit) throws IOException { FileSystem fs = FileSystem.get(output.toUri(), conf); output = fs.makeQualified(output); if (overwritePath) { HadoopUtil.delete(conf, output); } DistributedCache.setCacheFiles(new URI[]{output.toUri()}, conf); SequenceFile.Writer writer = new SequenceFile.Writer(fs, conf, output, IntWritable.class, VectorWritable.class); try { writer.append(key, new VectorWritable(vector)); } finally { Closeables.close(writer, false); } if (deleteOnExit) { fs.deleteOnExit(output); } } }
VectorCache { public static void save(Writable key, Vector vector, Path output, Configuration conf, boolean overwritePath, boolean deleteOnExit) throws IOException { FileSystem fs = FileSystem.get(output.toUri(), conf); output = fs.makeQualified(output); if (overwritePath) { HadoopUtil.delete(conf, output); } DistributedCache.setCacheFiles(new URI[]{output.toUri()}, conf); SequenceFile.Writer writer = new SequenceFile.Writer(fs, conf, output, IntWritable.class, VectorWritable.class); try { writer.append(key, new VectorWritable(vector)); } finally { Closeables.close(writer, false); } if (deleteOnExit) { fs.deleteOnExit(output); } } private  VectorCache(); }
VectorCache { public static void save(Writable key, Vector vector, Path output, Configuration conf, boolean overwritePath, boolean deleteOnExit) throws IOException { FileSystem fs = FileSystem.get(output.toUri(), conf); output = fs.makeQualified(output); if (overwritePath) { HadoopUtil.delete(conf, output); } DistributedCache.setCacheFiles(new URI[]{output.toUri()}, conf); SequenceFile.Writer writer = new SequenceFile.Writer(fs, conf, output, IntWritable.class, VectorWritable.class); try { writer.append(key, new VectorWritable(vector)); } finally { Closeables.close(writer, false); } if (deleteOnExit) { fs.deleteOnExit(output); } } private  VectorCache(); static void save(Writable key,
                          Vector vector,
                          Path output,
                          Configuration conf,
                          boolean overwritePath,
                          boolean deleteOnExit); static void save(Writable key, Vector vector, Path output, Configuration conf); static Vector load(Configuration conf); static Vector load(Configuration conf, Path input); }
VectorCache { public static void save(Writable key, Vector vector, Path output, Configuration conf, boolean overwritePath, boolean deleteOnExit) throws IOException { FileSystem fs = FileSystem.get(output.toUri(), conf); output = fs.makeQualified(output); if (overwritePath) { HadoopUtil.delete(conf, output); } DistributedCache.setCacheFiles(new URI[]{output.toUri()}, conf); SequenceFile.Writer writer = new SequenceFile.Writer(fs, conf, output, IntWritable.class, VectorWritable.class); try { writer.append(key, new VectorWritable(vector)); } finally { Closeables.close(writer, false); } if (deleteOnExit) { fs.deleteOnExit(output); } } private  VectorCache(); static void save(Writable key,
                          Vector vector,
                          Path output,
                          Configuration conf,
                          boolean overwritePath,
                          boolean deleteOnExit); static void save(Writable key, Vector vector, Path output, Configuration conf); static Vector load(Configuration conf); static Vector load(Configuration conf, Path input);  }