GeometricIndex implements DynamicIndex, Index { @Override public void process(Document doc) throws IOException { currentMemoryIndex.process(doc); globalDocumentCount++; lastAddedDocumentIdentifier = doc.name; lastAddedDocumentNumber = globalDocumentCount; if (globalDocumentCount % indexBlockSize == 0) { flushCurrentIndexBlock(); maintainMergeLocal(); } } GeometricIndex(TupleFlowParameters parameters);  GeometricIndex(TupleFlowParameters parameters, CheckPointHandler checkpointer); @Override String getIndexPath(); @Override void process(Document doc); @Override void close(); void forceFlush(); void forceMerge(); @Override String getDefaultPart(); @Override String getIndexPartName(Node node); @Override IndexPartReader getIndexPart(String part); @Override boolean containsPart(String partName); @Override NodeType getNodeType(Node node); @Override Set<String> getPartNames(); @Override Map<String, NodeType> getPartNodeTypes(String partName); @Override Parameters getManifest(); @Override boolean containsDocumentIdentifier(long document); @Override BaseIterator getIterator(Node node); @Override IndexPartStatistics getIndexPartStatistics(String part); @Override int getLength(long document); @Override String getName(long document); @Override long getIdentifier(String document); @Override Document getDocument(String document, DocumentComponents p); @Override Map<String, Document> getDocuments(List<String> documents, DocumentComponents p); @Override LengthsIterator getLengthsIterator(); @Override DataIterator<String> getNamesIterator(); public long globalDocumentCount; }
@Test public void testRetrievalFunctions() throws Exception { File shards = FileUtility.createTemporaryDirectory(); Random rnd = new Random(); try { Parameters p = Parameters.create(); p.set("indexBlockSize", 50); p.set("shardDirectory", shards.getAbsolutePath()); p.set("requested", 10); GeometricIndex index = new GeometricIndex(new FakeParameters(p)); LocalRetrieval ret = new LocalRetrieval(index); for (int i = 0; i < 255; i++) { Document d = new Document(); d.name = "DOC-" + i; d.text = "this is sample document " + i; d.terms = Arrays.asList(d.text.split(" ")); d.tags = new ArrayList<Tag>(); d.metadata = new HashMap<String,String>(); index.process(d); if (i > 0) { int j = rnd.nextInt(i); Node query = StructuredQuery.parse("sample " + j); query = ret.transformQuery(query, p); List<ScoredDocument> results = ret.executeQuery(query, p).scoredDocuments; assert (results.get(0).documentName.contains(Integer.toString(j))); } } } finally { FSUtil.deleteDirectory(shards); } }