本文整理汇总了Java中org.lemurproject.galago.core.retrieval.iterator.DataIterator类的典型用法代码示例。如果您正苦于以下问题:Java DataIterator类的具体用法?Java DataIterator怎么用?Java DataIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataIterator类属于org.lemurproject.galago.core.retrieval.iterator包,在下文中一共展示了DataIterator类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: addIteratorData
import org.lemurproject.galago.core.retrieval.iterator.DataIterator; //导入依赖的package包/类
@Override
public void addIteratorData(byte[] key, BaseIterator iterator) throws IOException {
ScoringContext sc = new ScoringContext();
while (!iterator.isDone()) {
sc.document = iterator.currentCandidate();
Document doc = ((DataIterator<Document>) iterator).data(sc);
// if the document already exists - no harm done.
addDocument(doc);
iterator.movePast(sc.document);
}
}
示例4: 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;
}
示例5: data
import org.lemurproject.galago.core.retrieval.iterator.DataIterator; //导入依赖的package包/类
@Override
public String data(ScoringContext c) {
if (head != null) {
return ((DataIterator<String>) this.head).data(c);
} else {
throw new RuntimeException("Names Iterator is done.");
}
}
示例6: getName
import org.lemurproject.galago.core.retrieval.iterator.DataIterator; //导入依赖的package包/类
@Override
public String getName(long document) throws IOException {
DataIterator<String> i = this.getNamesIterator();
i.syncTo(document);
ScoringContext ctx = new ScoringContext(document);
if (i.hasMatch(ctx)) {
return i.data(ctx);
} else {
throw new IOException("Could not find document identifier " + document);
}
}
示例7: getNamesIterator
import org.lemurproject.galago.core.retrieval.iterator.DataIterator; //导入依赖的package包/类
@Override
public DataIterator<String> getNamesIterator() throws IOException {
List<DataIterator<String>> itrs = new ArrayList<>();
itrs.add(currentMemoryIndex.getNamesIterator());
for (DiskIndex di : this.geometricParts.getIndexes()) {
itrs.add(di.getNamesIterator());
}
return new DisjointNamesIterator(itrs);
}
示例8: 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);
}
}
示例9: asIterable
import org.lemurproject.galago.core.retrieval.iterator.DataIterator; //导入依赖的package包/类
public static <T> Iterable<T> asIterable(final DataIterator<T> galagoDataIter) {
return new Iterable<T>() {
boolean used = false;
@Override
public Iterator<T> iterator() {
if(used) throw new IllegalStateException("Used DataIterator as Iterable twice!");
used=true;
return asIterator(galagoDataIter);
}
};
}
示例10: getNamesIterator
import org.lemurproject.galago.core.retrieval.iterator.DataIterator; //导入依赖的package包/类
@Override
public DataIterator<String> getNamesIterator() throws IOException {
return namesReader.getNamesIterator();
}
示例11: DisjointNamesIterator
import org.lemurproject.galago.core.retrieval.iterator.DataIterator; //导入依赖的package包/类
public DisjointNamesIterator(Collection<DataIterator<String>> iterators) {
super((Collection) iterators);
}
示例12: getNamesIterator
import org.lemurproject.galago.core.retrieval.iterator.DataIterator; //导入依赖的package包/类
public DataIterator<String> getNamesIterator() throws IOException;