DocumentPriorWriter extends KeyValueWriter<DocumentFeature> { @Override public void close() throws IOException { Parameters p = writer.getManifest(); p.set("maxScore", this.maxObservedScore); p.set("minScore", this.minObservedScore); if(!p.isDouble("default")){ p.set("defaultProb", this.minObservedScore); } super.close(); } DocumentPriorWriter(TupleFlowParameters parameters); @Override GenericElement prepare(DocumentFeature docfeat); @Override void close(); static void verify(TupleFlowParameters parameters, ErrorStore store);  }
@Test public void testSomeMethod() throws Exception { File tmp = FileUtility.createTemporary(); try { Parameters p = Parameters.create(); p.set("filename", tmp.getAbsolutePath()); DocumentPriorWriter writer = new DocumentPriorWriter(new FakeParameters(p)); Map<Long, Double> trueData = new HashMap<Long,Double>(); for (long i = 0; i < 100; i++) { trueData.put(i, i + 0.1); writer.process(new DocumentFeature(i, i + 0.1)); } for (long i = 8000000000l; i < 9000010000l; i += 100000001l) { trueData.put(i, i + 0.1); writer.process(new DocumentFeature(i, i + 0.1)); } writer.close(); DocumentPriorReader reader = new DocumentPriorReader(tmp.getAbsolutePath()); DocumentPriorReader.KeyIterator ki = reader.getIterator(); while (!ki.isDone()) { long id = Long.parseLong(ki.getKeyString()); Double val = Double.parseDouble(ki.getValueString()); assertEquals(val, trueData.get(id)); ki.nextKey(); } reader.close(); } finally { assertTrue(tmp.delete()); } }