當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。