当前位置: 首页>>代码示例>>Java>>正文


Java GenericElement类代码示例

本文整理汇总了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();
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:15,代码来源:DocumentIndexWriter.java

示例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();
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:15,代码来源:IndexWriterTest.java

示例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();
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:37,代码来源:IndexWriterTest.java

示例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();
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:16,代码来源:IndexWriterTest.java


注:本文中的org.galagosearch.core.index.GenericElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。