本文整理汇总了Java中org.lemurproject.galago.core.retrieval.iterator.DataIterator.currentCandidate方法的典型用法代码示例。如果您正苦于以下问题:Java DataIterator.currentCandidate方法的具体用法?Java DataIterator.currentCandidate怎么用?Java DataIterator.currentCandidate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lemurproject.galago.core.retrieval.iterator.DataIterator
的用法示例。
在下文中一共展示了DataIterator.currentCandidate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: asIterator
import org.lemurproject.galago.core.retrieval.iterator.DataIterator; //导入方法依赖的package包/类
private static <T> Iterator<T> asIterator(final DataIterator<T> galagoDataIter) {
final ScoringContext ctx = new ScoringContext();
return new Iterator<T>() {
@Override
public boolean hasNext() {
return !galagoDataIter.isDone();
}
@Override
public T next() {
ctx.document = galagoDataIter.currentCandidate();
T obj = galagoDataIter.data(ctx);
try {
galagoDataIter.movePast(ctx.document);
} catch (IOException e) {
throw new RuntimeException(e);
}
return obj;
}
@Override
public void remove() {
throw new UnsupportedOperationException("Read-only iterator");
}
};
}
示例2: addIteratorData
import org.lemurproject.galago.core.retrieval.iterator.DataIterator; //导入方法依赖的package包/类
@Override
public void addIteratorData(byte[] key, BaseIterator iterator) throws IOException {
DataIterator<String> i = (DataIterator<String>) iterator;
ScoringContext sc = new ScoringContext();
while (!iterator.isDone()) {
sc.document = i.currentCandidate();
String name = i.data(sc);
if (names.isEmpty()) {
offset = sc.document;
}
if (offset + names.size() > sc.document) {
throw new IOException("Unable to add names data out of order.");
}
// if we are adding id + lengths directly - we need
while (offset + names.size() < sc.document) {
names.add(null);
}
docCount += 1;
termCount += 1;
names.add(name);
iterator.movePast(sc.document);
}
}
示例3: getAllNames
import org.lemurproject.galago.core.retrieval.iterator.DataIterator; //导入方法依赖的package包/类
public List<String> getAllNames() throws IOException {
List<String> output = new ArrayList<>();
ScoringContext ctx = new ScoringContext();
DataIterator<String> iter = getNamesIterator();
while(!iter.isDone()) {
long doc = iter.currentCandidate();
ctx.document = doc;
String name = iter.data(ctx);
output.add(name);
iter.movePast(doc);
}
return output;
}
示例4: run
import org.lemurproject.galago.core.retrieval.iterator.DataIterator; //导入方法依赖的package包/类
@Override
public void run(Parameters p, PrintStream output) throws Exception {
if (!p.containsKey("index")) {
output.println(this.getHelpString());
return;
}
DiskIndex index = new DiskIndex(p.getString("index"));
DataIterator<String> namesItr = index.getNamesIterator();
LengthsIterator lengthsItr = index.getLengthsIterator();
ScoringContext sc = new ScoringContext();
while (!namesItr.isDone()) {
long docId = namesItr.currentCandidate();
sc.document = docId;
String docName = namesItr.data(sc);
lengthsItr.syncTo(docId);
int docLen = lengthsItr.length(sc);
if ((docLen == 0) && p.get("zeros", true)) {
output.println(docId + "\t" + docName + "\t" + docLen);
} else if (p.get("non-zeros", true)) {
output.println(docId + "\t" + docName + "\t" + docLen);
}
namesItr.movePast(docId);
}
}