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


Java TermSlot类代码示例

本文整理汇总了Java中org.galagosearch.core.index.VocabularyReader.TermSlot的典型用法代码示例。如果您正苦于以下问题:Java TermSlot类的具体用法?Java TermSlot怎么用?Java TermSlot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TermSlot类属于org.galagosearch.core.index.VocabularyReader包,在下文中一共展示了TermSlot类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: skipTo

import org.galagosearch.core.index.VocabularyReader.TermSlot; //导入依赖的package包/类
public void skipTo(byte[] key) throws IOException {
    TermSlot slot = vocabulary.get(key);
    if (slot == null) {
        done = true;
    } else {
        invalidateBlock();
        block = readVocabularyBlock(slot.begin);
        keyIndex = 0;
        while (keyIndex < block.keys.length) {
            byte[] blockKey = Utility.makeBytes(block.keys[keyIndex]);
            if (Utility.compare(key, blockKey) <= 0) {
                loadIndex();
                return;
            }
            keyIndex++;
        }
        done = true;
    }
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:20,代码来源:IndexReader.java

示例2: getIterator

import org.galagosearch.core.index.VocabularyReader.TermSlot; //导入依赖的package包/类
/**
 * Returns an iterator pointing at a specific key.  Returns
 * null if the key is not found in the index.
 */
public Iterator getIterator(String key) throws IOException {
    // read from offset to offset in the vocab structure (right?)
    VocabularyReader.TermSlot slot = vocabulary.get(key);

    if (slot == null) {
        return null;
    }
    VocabularyBlock block = readVocabularyBlock(slot.begin);
    int index = block.findIndex(key);

    if (index >= 0) {
        return new Iterator(block, index);
    }
    return null;
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:20,代码来源:IndexReader.java

示例3: processCorpusFile

import org.galagosearch.core.index.VocabularyReader.TermSlot; //导入依赖的package包/类
private void processCorpusFile(String fileName, String fileType) throws IOException {
    // If this is a big file, we'll split it into roughly 100MB pieces.
    long fileLength = new File(fileName).length();
    long chunkSize = 100 * 1024 * 1024;
    
    IndexReader reader = new IndexReader(fileName);
    VocabularyReader vocabulary = reader.getVocabulary();
    List<TermSlot> slots = vocabulary.getSlots();
    int pieces = Math.max(2, (int) (fileLength / chunkSize));
    ArrayList<byte[]> keys = new ArrayList<byte[]>();

    for (int i = 1; i < pieces; ++i) {
        float fraction = (float) i / pieces;
        int slot = (int) (fraction * slots.size());
        keys.add(slots.get(slot).termData);
    }

    for (int i = 0; i < pieces; ++i) {
        byte[] firstKey = new byte[0];
        byte[] lastKey = new byte[0];

        if (i > 0) {
            firstKey = keys.get(i - 1);
        }
        if (i < pieces - 1) {
            lastKey = keys.get(i);
        }
        DocumentSplit split = new DocumentSplit(fileName, fileType, false, firstKey, lastKey);
        processor.process(split);
    }
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:32,代码来源:DocumentSource.java


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