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


Java DataIterator类代码示例

本文整理汇总了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");
    }
  };
}
 
开发者ID:jjfiv,项目名称:ecir2015timebooks,代码行数:27,代码来源:GalagoUtil.java

示例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);
  }
}
 
开发者ID:teanalab,项目名称:demidovii,代码行数:29,代码来源:MemoryDocumentNames.java

示例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);
  }
}
 
开发者ID:teanalab,项目名称:demidovii,代码行数:12,代码来源:MemoryCorpus.java

示例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;
}
 
开发者ID:teanalab,项目名称:demidovii,代码行数:14,代码来源:DiskIndex.java

示例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.");
  }
}
 
开发者ID:teanalab,项目名称:demidovii,代码行数:9,代码来源:DisjointNamesIterator.java

示例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);
  }
}
 
开发者ID:teanalab,项目名称:demidovii,代码行数:12,代码来源:GeometricIndex.java

示例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);
}
 
开发者ID:teanalab,项目名称:demidovii,代码行数:10,代码来源:GeometricIndex.java

示例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);
  }
}
 
开发者ID:teanalab,项目名称:demidovii,代码行数:33,代码来源:DumpNamesLengths.java

示例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);
    }
  };
}
 
开发者ID:jjfiv,项目名称:ecir2015timebooks,代码行数:12,代码来源:GalagoUtil.java

示例10: getNamesIterator

import org.lemurproject.galago.core.retrieval.iterator.DataIterator; //导入依赖的package包/类
@Override
public DataIterator<String> getNamesIterator() throws IOException {
  return namesReader.getNamesIterator();
}
 
开发者ID:teanalab,项目名称:demidovii,代码行数:5,代码来源:MemoryIndex.java

示例11: DisjointNamesIterator

import org.lemurproject.galago.core.retrieval.iterator.DataIterator; //导入依赖的package包/类
public DisjointNamesIterator(Collection<DataIterator<String>> iterators) {
  super((Collection) iterators);
}
 
开发者ID:teanalab,项目名称:demidovii,代码行数:4,代码来源:DisjointNamesIterator.java

示例12: getNamesIterator

import org.lemurproject.galago.core.retrieval.iterator.DataIterator; //导入依赖的package包/类
public DataIterator<String> getNamesIterator() throws IOException; 
开发者ID:teanalab,项目名称:demidovii,代码行数:2,代码来源:Index.java


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