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