本文整理匯總了Java中org.galagosearch.core.index.GenericElement類的典型用法代碼示例。如果您正苦於以下問題:Java GenericElement類的具體用法?Java GenericElement怎麽用?Java GenericElement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GenericElement類屬於org.galagosearch.core.index包,在下文中一共展示了GenericElement類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: process
import org.galagosearch.core.index.GenericElement; //導入依賴的package包/類
public void process(Document document) throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
VByteOutput output = new VByteOutput(new DataOutputStream(stream));
output.writeString(document.text);
for (Map.Entry<String, String> entry : document.metadata.entrySet()) {
output.writeString(entry.getKey());
output.writeString(entry.getValue());
}
writer.add(new GenericElement(document.identifier, stream.toByteArray()));
if (documentsWritten != null)
documentsWritten.increment();
}
示例2: testSingleKeyValue
import org.galagosearch.core.index.GenericElement; //導入依賴的package包/類
public void testSingleKeyValue() throws IOException {
Parameters parameters = new Parameters();
parameters.add("blockSize", Long.toString(64));
temporary = Utility.createTemporary();
IndexWriter writer = new IndexWriter(temporary.getAbsolutePath(), parameters);
writer.add(new GenericElement("key", "value"));
writer.close();
assertTrue(IndexReader.isIndexFile(temporary.getAbsolutePath()));
IndexReader reader = new IndexReader(temporary.getAbsolutePath());
assertEquals("value", reader.getValueString("key"));
reader.close();
}
示例3: testSeek
import org.galagosearch.core.index.GenericElement; //導入依賴的package包/類
public void testSeek() throws IOException {
Parameters parameters = new Parameters();
parameters.add("blockSize", Long.toString(64));
temporary = Utility.createTemporary();
IndexWriter writer = new IndexWriter(temporary.getAbsolutePath(), parameters);
writer.add(new GenericElement("key", "value"));
writer.add(new GenericElement("more", "value2"));
writer.close();
assertTrue(IndexReader.isIndexFile(temporary.getAbsolutePath()));
IndexReader reader = new IndexReader(temporary.getAbsolutePath());
IndexReader.Iterator iterator = reader.getIterator();
// Skip to 'more'
iterator.skipTo(new byte[] { (byte) 'm' });
assertFalse(iterator.isDone());
assertEquals("more", iterator.getKey());
assertEquals("value2", iterator.getValueString());
assertFalse(iterator.nextKey());
// Start at the beginning
iterator = reader.getIterator();
assertFalse(iterator.isDone());
assertEquals("key", iterator.getKey());
assertTrue(iterator.nextKey());
assertEquals("more", iterator.getKey());
assertFalse(iterator.nextKey());
// Start after all keys
iterator = reader.getIterator();
assertFalse(iterator.isDone());
iterator.skipTo(new byte[] { (byte) 'z' });
assertTrue(iterator.isDone());
reader.close();
}
示例4: testSingleCompressedKeyValue
import org.galagosearch.core.index.GenericElement; //導入依賴的package包/類
public void testSingleCompressedKeyValue() throws IOException {
Parameters parameters = new Parameters();
parameters.add("blockSize", Long.toString(64));
parameters.add("isCompressed", "true");
temporary = Utility.createTemporary();
IndexWriter writer = new IndexWriter(temporary.getAbsolutePath(), parameters);
writer.add(new GenericElement("key", "value"));
writer.close();
assertTrue(IndexReader.isIndexFile(temporary.getAbsolutePath()));
IndexReader reader = new IndexReader(temporary.getAbsolutePath());
assertEquals("value", reader.getValueString("key"));
reader.close();
}