MergeIndex extends AppFunction { @Override public void run(Parameters p, PrintStream output) throws Exception { if ((!p.containsKey("indexPath")) || !p.containsKey("inputPath")) { output.println(getHelpString()); return; } MergeIndex build = new MergeIndex(); Job job = build.getJob(p); TupleflowAppUtil.runTupleFlowJob(job, p, output); }  Job getJob(Parameters p); @Override String getName(); @Override String getHelpString(); @Override void run(Parameters p, PrintStream output);  }
@Test public void testMergeDiskIndexesDoNotRenumber() throws Exception { File trecData1 = null; File trecData2 = null; File index1 = null; File index2 = null; File indexmerged = null; try { StringBuilder docs1 = new StringBuilder(); StringBuilder docs2 = new StringBuilder(); for (int i = 0; i < 10; i++) { docs1.append(AppTest.trecDocument("DOCS1-" + i, "This is sample document " + i)); docs2.append(AppTest.trecDocument("DOCS2-" + i, "This is a different document " + i)); } trecData1 = FileUtility.createTemporary(); trecData2 = FileUtility.createTemporary(); StreamUtil.copyStringToFile(docs1.toString(), trecData1); StreamUtil.copyStringToFile(docs2.toString(), trecData2); index1 = FileUtility.createTemporaryDirectory(); App.main(new String[]{"build", "--inputPath=" + trecData1.getAbsolutePath(), "--indexPath=" + index1.getAbsolutePath(), "--corpus=false"}); index2 = FileUtility.createTemporaryDirectory(); App.main(new String[]{"build", "--inputPath=" + trecData2.getAbsolutePath(), "--indexPath=" + index2.getAbsolutePath(), "--corpus=false"}); AppTest.verifyIndexStructures(index1); AppTest.verifyIndexStructures(index2); indexmerged = FileUtility.createTemporaryDirectory(); Parameters mergeParams = Parameters.create(); mergeParams.set("indexPath", indexmerged.getAbsolutePath()); ArrayList<String> inputs = new ArrayList<String>(); inputs.add(index1.getAbsolutePath()); inputs.add(index2.getAbsolutePath()); mergeParams.set("inputPath", inputs); mergeParams.set("renumberDocuments", false); try { App.run("merge-index", mergeParams, System.out); fail("This should not passs"); } catch (Exception e) { } } finally { if (trecData1 != null) { trecData1.delete(); } if (trecData2 != null) { trecData2.delete(); } if (index1 != null) { FSUtil.deleteDirectory(index1); } if (index2 != null) { FSUtil.deleteDirectory(index2); } if (indexmerged != null) { FSUtil.deleteDirectory(indexmerged); } } }