本文整理汇总了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();
}