• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TermsEnumWithSlice类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.apache.lucene.index.MultiTermsEnum.TermsEnumWithSlice的典型用法代码示例。如果您正苦于以下问题:Java TermsEnumWithSlice类的具体用法?Java TermsEnumWithSlice怎么用?Java TermsEnumWithSlice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

TermsEnumWithSlice类属于org.apache.lucene.index.MultiTermsEnum包,在下文中一共展示了TermsEnumWithSlice类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: OrdinalMap

点赞 2

import org.apache.lucene.index.MultiTermsEnum.TermsEnumWithSlice; //导入依赖的package包/类
/** 
 * Creates an ordinal map that allows mapping ords to/from a merged
 * space from <code>subs</code>.
 * @param owner a cache key
 * @param subs TermsEnums that support {@link TermsEnum#ord()}. They need
 *             not be dense (e.g. can be FilteredTermsEnums}.
 * @throws IOException if an I/O error occurred.
 */
public OrdinalMap(Object owner, TermsEnum subs[]) throws IOException {
  // create the ordinal mappings by pulling a termsenum over each sub's 
  // unique terms, and walking a multitermsenum over those
  this.owner = owner;
  globalOrdDeltas = new MonotonicAppendingLongBuffer();
  subIndexes = new AppendingLongBuffer();
  ordDeltas = new MonotonicAppendingLongBuffer[subs.length];
  for (int i = 0; i < ordDeltas.length; i++) {
    ordDeltas[i] = new MonotonicAppendingLongBuffer();
  }
  long segmentOrds[] = new long[subs.length];
  ReaderSlice slices[] = new ReaderSlice[subs.length];
  TermsEnumIndex indexes[] = new TermsEnumIndex[slices.length];
  for (int i = 0; i < slices.length; i++) {
    slices[i] = new ReaderSlice(0, 0, i);
    indexes[i] = new TermsEnumIndex(subs[i], i);
  }
  MultiTermsEnum mte = new MultiTermsEnum(slices);
  mte.reset(indexes);
  long globalOrd = 0;
  while (mte.next() != null) {        
    TermsEnumWithSlice matches[] = mte.getMatchArray();
    for (int i = 0; i < mte.getMatchCount(); i++) {
      int subIndex = matches[i].index;
      long segmentOrd = matches[i].terms.ord();
      long delta = globalOrd - segmentOrd;
      // for each unique term, just mark the first subindex/delta where it occurs
      if (i == 0) {
        subIndexes.add(subIndex);
        globalOrdDeltas.add(delta);
      }
      // for each per-segment ord, map it back to the global term.
      while (segmentOrds[subIndex] <= segmentOrd) {
        ordDeltas[subIndex].add(delta);
        segmentOrds[subIndex]++;
      }
    }
    globalOrd++;
  }
}
 

开发者ID:pkarmstr,
项目名称:NYBC,
代码行数:49,
代码来源:MultiDocValues.java

示例2: OrdinalMap

点赞 2

import org.apache.lucene.index.MultiTermsEnum.TermsEnumWithSlice; //导入依赖的package包/类
/** 
 * Creates an ordinal map that allows mapping ords to/from a merged
 * space from <code>subs</code>.
 * @param owner a cache key
 * @param subs TermsEnums that support {@link TermsEnum#ord()}. They need
 *             not be dense (e.g. can be FilteredTermsEnums}.
 * @throws IOException if an I/O error occurred.
 */
public OrdinalMap(Object owner, TermsEnum subs[]) throws IOException {
  // create the ordinal mappings by pulling a termsenum over each sub's 
  // unique terms, and walking a multitermsenum over those
  this.owner = owner;
  globalOrdDeltas = new MonotonicAppendingLongBuffer(PackedInts.COMPACT);
  firstSegments = new AppendingPackedLongBuffer(PackedInts.COMPACT);
  ordDeltas = new MonotonicAppendingLongBuffer[subs.length];
  for (int i = 0; i < ordDeltas.length; i++) {
    ordDeltas[i] = new MonotonicAppendingLongBuffer();
  }
  long segmentOrds[] = new long[subs.length];
  ReaderSlice slices[] = new ReaderSlice[subs.length];
  TermsEnumIndex indexes[] = new TermsEnumIndex[slices.length];
  for (int i = 0; i < slices.length; i++) {
    slices[i] = new ReaderSlice(0, 0, i);
    indexes[i] = new TermsEnumIndex(subs[i], i);
  }
  MultiTermsEnum mte = new MultiTermsEnum(slices);
  mte.reset(indexes);
  long globalOrd = 0;
  while (mte.next() != null) {        
    TermsEnumWithSlice matches[] = mte.getMatchArray();
    for (int i = 0; i < mte.getMatchCount(); i++) {
      int segmentIndex = matches[i].index;
      long segmentOrd = matches[i].terms.ord();
      long delta = globalOrd - segmentOrd;
      // for each unique term, just mark the first segment index/delta where it occurs
      if (i == 0) {
        firstSegments.add(segmentIndex);
        globalOrdDeltas.add(delta);
      }
      // for each per-segment ord, map it back to the global term.
      while (segmentOrds[segmentIndex] <= segmentOrd) {
        ordDeltas[segmentIndex].add(delta);
        segmentOrds[segmentIndex]++;
      }
    }
    globalOrd++;
  }
  firstSegments.freeze();
  globalOrdDeltas.freeze();
  for (int i = 0; i < ordDeltas.length; ++i) {
    ordDeltas[i].freeze();
  }
}
 

开发者ID:yintaoxue,
项目名称:read-open-source-code,
代码行数:54,
代码来源:MultiDocValues.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)