public static Index makeConcurrentForRetrieval(Index index) { if (index.hasIndexStructure("document") && ! index.getDocumentIndex().getClass().isAnnotationPresent(ConcurrentReadable.class) ) if (index.hasIndexStructure("inverted") && ! index.getInvertedIndex().getClass().isAnnotationPresent(ConcurrentReadable.class) ) if (index.hasIndexStructure("lexicon") && ! index.getLexicon().getClass().isAnnotationPresent(ConcurrentReadable.class) ) if (index.hasIndexStructure("meta") && ! index.getMetaIndex().getClass().isAnnotationPresent(ConcurrentReadable.class) )
public static Index makeConcurrentForRetrieval(Index index) { if (index.hasIndexStructure("document") && ! index.getDocumentIndex().getClass().isAnnotationPresent(ConcurrentReadable.class) ) if (index.hasIndexStructure("inverted") && ! index.getInvertedIndex().getClass().isAnnotationPresent(ConcurrentReadable.class) ) if (index.hasIndexStructure("lexicon") && ! index.getLexicon().getClass().isAnnotationPresent(ConcurrentReadable.class) ) if (index.hasIndexStructure("meta") && ! index.getMetaIndex().getClass().isAnnotationPresent(ConcurrentReadable.class) )
@Override public void checkIndex(BatchEndToEndTest test, Index index) throws Exception { testInverted(index); if (index.hasIndexStructure("direct")) testDirect(index); }
@Test public void testQuickly() throws Exception { Index index = IndexTestUtils.makeIndexSinglePass( new String[]{"doc1", "doc2"}, new String[]{"Quick fast brown fox", "jumped huge black lazy dog"});//no stopwords assertFalse(index.hasIndexStructure("direct")); assertFalse(index.hasIndexStructure("direct-inputstream")); assertTrue(index instanceof IndexOnDisk); new Inverted2DirectIndexBuilder((IndexOnDisk) index).createDirectIndex(); assertTrue(index.hasIndexStructure("direct")); assertTrue(index.hasIndexStructure("direct-inputstream")); }
if (t.getMaxFrequencyInDocuments() == Integer.MAX_VALUE && index.hasIndexStructure("maxtf"))
if (t.getMaxFrequencyInDocuments() == Integer.MAX_VALUE && index.hasIndexStructure("maxtf"))
if (index.hasIndexStructure("metacache")) metaCache = (LRUMap<Integer,String[]>) index.getIndexStructure("metacache"); else
if (index.hasIndexStructure("metacache")) metaCache = (LRUMap<Integer,String[]>) index.getIndexStructure("metacache"); else
@Test public void testQuicklyMultiPass() throws Exception { Index index = IndexTestUtils.makeIndexSinglePass( new String[]{"doc1", "doc2"}, new String[]{"Quick fast brown fox", "jumped huge black lazy dog"});//no stopwords assertFalse(index.hasIndexStructure("direct")); assertFalse(index.hasIndexStructure("direct-inputstream")); assertTrue(index instanceof IndexOnDisk); ApplicationSetup.setProperty("inverted2direct.processtokens", "4"); new Inverted2DirectIndexBuilder((IndexOnDisk) index).createDirectIndex(); assertTrue(index.hasIndexStructure("direct")); assertTrue(index.hasIndexStructure("direct-inputstream")); }
return 1; PostingIndex<?> di = index.hasIndexStructure("direct") ? index.getDirectIndex() : null; DocumentIndex doi = index.getDocumentIndex(); MetaIndex meta = index.getMetaIndex();
return 1; PostingIndex<?> di = index.hasIndexStructure("direct") ? index.getDirectIndex() : null; DocumentIndex doi = index.getDocumentIndex(); MetaIndex meta = index.getMetaIndex();
assertTrue("Index has no "+ structureName + " structure", index.hasIndexStructure(structureName)); for (String structureName : expectedStructuresInputStream ) assertTrue("Index has no "+ structureName + " inputstream structure", index.hasIndexStructure(structureName));
@SuppressWarnings("unchecked") @Test public void testSimple() throws IOException { Index index = Index.createNewIndex(ApplicationSetup.TERRIER_INDEX_PATH, ApplicationSetup.TERRIER_INDEX_PREFIX); CompressionConfiguration cc = getConfig("inverted", new String[0], 0,0); AbstractPostingOutputStream pos = cc.getPostingOutputStream(((IndexOnDisk)index).getPath() + "/" + ((IndexOnDisk)index).getPrefix() + ".inverted" + cc.getStructureFileExtension()); Pointer p = pos.writePostings(new ArrayOfBasicIterablePosting(new int[]{0, 1}, new int[]{1,2})); pos.close(); cc.writeIndexProperties(index, "lexicon-entry-inputstream"); index.flush(); assertTrue(index.hasIndexStructure("inverted")); PostingIndex<Pointer> inv = (PostingIndex<Pointer>) index.getIndexStructure("inverted"); IterablePosting ip = inv.getPostings(p); assertNotNull(ip); assertEquals(0, ip.next()); assertEquals(1, ip.getFrequency()); assertEquals(1, ip.next()); assertEquals(2, ip.getFrequency()); index.close(); IndexUtil.deleteIndex(ApplicationSetup.TERRIER_INDEX_PATH, ApplicationSetup.TERRIER_INDEX_PREFIX); } }