static FixedSizeWriteableFactory<?> getKeyFactory(Index _index, String _structureName) throws IOException { _index.addIndexStructure(_structureName+"-keyfactory", org.terrier.structures.seralization.FixedSizeTextFactory.class.getName(), "java.lang.String", "${max.term.length}"); _index.flush(); return (FixedSizeWriteableFactory<?>)_index.getIndexStructure(_structureName+"-keyfactory"); }
List<BitIndexPointer> pointerList = (List<BitIndexPointer>) index.getIndexStructure(args[2]); PostingIndex<?> bpi = (PostingIndex<?>) index.getIndexStructure(structureName); List<? extends Writable> list = (List<? extends Writable>) index.getIndexStructure(structureName); for(int argC=2;argC<args.length;argC++)
static FixedSizeWriteableFactory<?> getKeyFactory(Index _index, String _structureName) throws IOException { _index.addIndexStructure(_structureName+"-keyfactory", org.terrier.structures.seralization.FixedSizeTextFactory.class.getName(), "java.lang.String", "${max.term.length}"); _index.flush(); return (FixedSizeWriteableFactory<?>)_index.getIndexStructure(_structureName+"-keyfactory"); }
List<BitIndexPointer> pointerList = (List<BitIndexPointer>) index.getIndexStructure(args[2]); PostingIndex<?> bpi = (PostingIndex<?>) index.getIndexStructure(structureName); List<? extends Writable> list = (List<? extends Writable>) index.getIndexStructure(structureName); for(int argC=2;argC<args.length;argC++)
public Pair<EntryStatistics, IterablePosting> getPostingIterator(Index index) throws IOException { Lexicon<Date> lexDate = (Lexicon<Date>) index.getIndexStructure("datelexicon"); PostingIndex<Pointer> invDate = (PostingIndex<Pointer>) index.getIndexStructure("dateinverted"); List<LexiconEntry> _le = new ArrayList<LexiconEntry>(); List<IterablePosting> _joinedPostings = new ArrayList<IterablePosting>();
public Pair<EntryStatistics, IterablePosting> getPostingIterator(Index index) throws IOException { Lexicon<Date> lexDate = (Lexicon<Date>) index.getIndexStructure("datelexicon"); PostingIndex<Pointer> invDate = (PostingIndex<Pointer>) index.getIndexStructure("dateinverted"); List<LexiconEntry> _le = new ArrayList<LexiconEntry>(); List<IterablePosting> _joinedPostings = new ArrayList<IterablePosting>();
List<Integer> maxTFStructure = (List<Integer>) index.getIndexStructure("maxtf"); if (maxTFStructure != null)
List<Integer> maxTFStructure = (List<Integer>) index.getIndexStructure("maxtf"); if (maxTFStructure != null)
metaCache = (LRUMap<Integer,String[]>) index.getIndexStructure("metacache"); else metaCache = new LRUMap<Integer,String[]>(1000);
metaCache = (LRUMap<Integer,String[]>) index.getIndexStructure("metacache"); else metaCache = new LRUMap<Integer,String[]>(1000);
@Test public void testCopyStructureSameIndex() throws Exception { Index i1 = Index.createNewIndex(ApplicationSetup.TERRIER_INDEX_PATH, ApplicationSetup.TERRIER_INDEX_PREFIX + "i1"); i1.addIndexStructure("test1", Object.class.getName(), "", ""); IndexUtil.copyStructure(i1, i1, "test1", "test2"); assertEquals(Object.class, i1.getIndexStructure("test2").getClass()); }
@Test public void testCopyStructureDifferentIndex() throws Exception { Index i1 = Index.createNewIndex(ApplicationSetup.TERRIER_INDEX_PATH, ApplicationSetup.TERRIER_INDEX_PREFIX + "i1"); Index i2 = Index.createNewIndex(ApplicationSetup.TERRIER_INDEX_PATH, ApplicationSetup.TERRIER_INDEX_PREFIX + "i2"); i1.addIndexStructure("test1", Object.class.getName(), "", ""); IndexUtil.copyStructure(i1, i2, "test1", "test2"); assertEquals(Object.class, i2.getIndexStructure("test2").getClass()); }
if (FieldScore.FIELDS_COUNT > 0) assertTrue("LexiconEntry is not of type FieldLexiconEntry", ((FixedSizeWriteableFactory<LexiconEntry>)index.getIndexStructure("lexicon-valuefactory")).newInstance() instanceof FieldLexiconEntry); assertTrue("DocumentIndexEntry is not of type FieldDocumentIndexEntry", ((FixedSizeWriteableFactory<DocumentIndexEntry>)index.getIndexStructure("document-factory")).newInstance() instanceof FieldDocumentIndexEntry); LexiconEntry le = ((FixedSizeWriteableFactory<LexiconEntry>)index.getIndexStructure("lexicon-valuefactory")).newInstance(); assertTrue("LexiconEntry is not of type BasicLexiconEntry", (le instanceof BasicLexiconEntry) || (le instanceof Tr4BasicLexiconEntry)
: (MetaIndex) index.getIndexStructure(name); assertNotNull(mi);
@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); } }