ResplitSequenceFiles { public static void main(String[] args) throws IOException { ResplitSequenceFiles runner = new ResplitSequenceFiles(); if (runner.parseArgs(args)) { runner.run(new PrintWriter(new OutputStreamWriter(System.out, Charsets.UTF_8), true)); } } private  ResplitSequenceFiles(); static void main(String[] args);  }
@Test public void testSplitting() throws Exception { Path inputFile = new Path(getTestTempDirPath("input"), "test.seq"); Path output = getTestTempDirPath("output"); Configuration conf = new Configuration(); LocalFileSystem fs = FileSystem.getLocal(conf); SequenceFile.Writer writer = null; try { writer = SequenceFile.createWriter(fs, conf, inputFile, IntWritable.class, IntWritable.class); writer.append(new IntWritable(1), new IntWritable(1)); writer.append(new IntWritable(2), new IntWritable(2)); writer.append(new IntWritable(3), new IntWritable(3)); writer.append(new IntWritable(4), new IntWritable(4)); writer.append(new IntWritable(5), new IntWritable(5)); writer.append(new IntWritable(6), new IntWritable(6)); writer.append(new IntWritable(7), new IntWritable(7)); writer.append(new IntWritable(8), new IntWritable(8)); } finally { Closeables.close(writer, false); } String splitPattern = "split"; int numSplits = 4; ResplitSequenceFiles.main(new String[] { "--input", inputFile.toString(), "--output", output.toString() + "/" + splitPattern, "--numSplits", String.valueOf(numSplits) }); FileStatus[] statuses = HadoopUtil.getFileStatus(output, PathType.LIST, PathFilters.logsCRCFilter(), null, conf); for (FileStatus status : statuses) { String name = status.getPath().getName(); assertTrue(name.startsWith(splitPattern)); assertEquals(2, numEntries(status, conf)); } assertEquals(numSplits, statuses.length); }