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