/** {@inheritDoc} */ public void flush() throws IOException { for (Index i : this.indices) i.flush(); }
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"); }
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"); }
index.flush(); return OK;
index.flush(); return OK;
@Test(expected=IllegalArgumentException.class) public void dirNotExists() throws Exception { Index newIndex = IndexOnDisk.createNewIndex(ApplicationSetup.TERRIER_INDEX_PATH + "/tmp/", "data"); newIndex.setIndexProperty("hello", "there"); newIndex.flush(); newIndex.close(); }
@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); } }