InterResults { public static void store(FileSystem fs, Path forestPath, TreeID[] keys, Node[] trees, int[] sizes) throws IOException { Preconditions.checkArgument(keys.length == trees.length, "keys.length != trees.length"); int numTrees = keys.length; int numMaps = sizes.length; FSDataOutputStream out = fs.create(forestPath); for (int p = 0; p < numMaps; p++) { out.writeInt(sizes[p]); } for (int index = 0; index < numTrees; index++) { keys[index].write(out); trees[index].write(out); } out.close(); } private  InterResults(); static int load(FileSystem fs,
                         Path forestPath,
                         int numMaps,
                         int numTrees,
                         int partition,
                         TreeID[] keys,
                         Node[] trees); static void store(FileSystem fs,
                           Path forestPath,
                           TreeID[] keys,
                           Node[] trees,
                           int[] sizes);  }
@Test public void testStore() throws Exception { Path forestPath = new Path("testdata/InterResultsTest/test.forest"); FileSystem fs = forestPath.getFileSystem(new Configuration()); InterResults.store(fs, forestPath, keys, trees, sizes); FSDataInputStream in = fs.open(forestPath); try { for (int p = 0; p < NUM_MAPPERS; p++) { assertEquals(splits[p].length, in.readInt()); } TreeID key = new TreeID(); for (int index = 0; index < NUM_TREES; index++) { key.readFields(in); Node value = Node.read(in); assertEquals("index: " + index, keys[index], key); assertEquals("index: " + index, trees[index], value); } } finally { in.close(); } }