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


Java SortedSetDocValues.getValueCount方法代码示例

本文整理汇总了Java中org.apache.lucene.index.SortedSetDocValues.getValueCount方法的典型用法代码示例。如果您正苦于以下问题:Java SortedSetDocValues.getValueCount方法的具体用法?Java SortedSetDocValues.getValueCount怎么用?Java SortedSetDocValues.getValueCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.index.SortedSetDocValues的用法示例。


在下文中一共展示了SortedSetDocValues.getValueCount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SortedSetRangeLeafCollector

import org.apache.lucene.index.SortedSetDocValues; //导入方法依赖的package包/类
SortedSetRangeLeafCollector(SortedSetDocValues values,
        Range[] ranges, LeafBucketCollector sub) {
    super(sub, values);
    for (int i = 1; i < ranges.length; ++i) {
        if (RANGE_COMPARATOR.compare(ranges[i-1], ranges[i]) > 0) {
            throw new IllegalArgumentException("Ranges must be sorted");
        }
    }
    this.values = values;
    this.sub = sub;
    froms = new long[ranges.length];
    tos = new long[ranges.length]; // inclusive
    maxTos = new long[ranges.length];
    for (int i = 0; i < ranges.length; ++i) {
        if (ranges[i].from == null) {
            froms[i] = 0;
        } else {
            froms[i] = values.lookupTerm(ranges[i].from);
            if (froms[i] < 0) {
                froms[i] = -1 - froms[i];
            }
        }
        if (ranges[i].to == null) {
            tos[i] = values.getValueCount() - 1;
        } else {
            long ord = values.lookupTerm(ranges[i].to);
            if (ord < 0) {
                tos[i] = -2 - ord;
            } else {
                tos[i] = ord - 1;
            }
        }
    }
    maxTos[0] = tos[0];
    for (int i = 1; i < tos.length; ++i) {
        maxTos[i] = Math.max(maxTos[i-1], tos[i]);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:39,代码来源:BinaryRangeAggregator.java

示例2: accumMulti

import org.apache.lucene.index.SortedSetDocValues; //导入方法依赖的package包/类
/** accumulates per-segment multi-valued facet counts */
static void accumMulti(int counts[], int startTermIndex, SortedSetDocValues si, DocIdSetIterator disi, int subIndex, OrdinalMap map) throws IOException {
  if (startTermIndex == -1 && (map == null || si.getValueCount() < disi.cost()*10)) {
    // no prefixing, not too many unique values wrt matching docs (lucene/facets heuristic): 
    //   collect separately per-segment, then map to global ords
    accumMultiSeg(counts, si, disi, subIndex, map);
  } else {
    // otherwise: do collect+map on the fly
    accumMultiGeneric(counts, startTermIndex, si, disi, subIndex, map);
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:12,代码来源:DocValuesFacets.java

示例3: accumMultiSeg

import org.apache.lucene.index.SortedSetDocValues; //导入方法依赖的package包/类
/** "typical" multi-valued faceting: not too many unique values, no prefixing. maps to global ordinals as a separate step */
static void accumMultiSeg(int counts[], SortedSetDocValues si, DocIdSetIterator disi, int subIndex, OrdinalMap map) throws IOException {
  // First count in seg-ord space:
  final int segCounts[];
  if (map == null) {
    segCounts = counts;
  } else {
    segCounts = new int[1+(int)si.getValueCount()];
  }
  
  int doc;
  while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
    si.setDocument(doc);
    int term = (int) si.nextOrd();
    if (term < 0) {
      counts[0]++; // missing
    } else {
      do {
        segCounts[1+term]++;
      } while ((term = (int)si.nextOrd()) >= 0);
    }
  }
  
  // migrate to global ords (if necessary)
  if (map != null) {
    migrateGlobal(counts, segCounts, subIndex, map);
  }
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:29,代码来源:DocValuesFacets.java

示例4: getComparator

import org.apache.lucene.index.SortedSetDocValues; //导入方法依赖的package包/类
@Override
public FieldComparator<?> getComparator(int numHits, int sortPos) throws IOException {
  return new FieldComparator.TermOrdValComparator(numHits, getField(), missingValue == STRING_LAST) {
    @Override
    protected SortedDocValues getSortedDocValues(AtomicReaderContext context, String field) throws IOException {
      SortedSetDocValues sortedSet = FieldCache.DEFAULT.getDocTermOrds(context.reader(), field);
      
      if (sortedSet.getValueCount() >= Integer.MAX_VALUE) {
        throw new UnsupportedOperationException("fields containing more than " + (Integer.MAX_VALUE-1) + " unique terms are unsupported");
      }
      
      SortedDocValues singleton = DocValues.unwrapSingleton(sortedSet);
      if (singleton != null) {
        // it's actually single-valued in practice, but indexed as multi-valued,
        // so just sort on the underlying single-valued dv directly.
        // regardless of selector type, this optimization is safe!
        return singleton;
      } else if (selector == Selector.MIN) {
        return new MinValue(sortedSet);
      } else {
        if (sortedSet instanceof RandomAccessOrds == false) {
          throw new UnsupportedOperationException("codec does not support random access ordinals, cannot use selector: " + selector);
        }
        RandomAccessOrds randomOrds = (RandomAccessOrds) sortedSet;
        switch(selector) {
          case MAX: return new MaxValue(randomOrds);
          case MIDDLE_MIN: return new MiddleMinValue(randomOrds);
          case MIDDLE_MAX: return new MiddleMaxValue(randomOrds);
          case MIN: 
          default: 
            throw new AssertionError();
        }
      }
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:37,代码来源:SortedSetSortField.java

示例5: DefaultSortedSetDocValuesReaderState

import org.apache.lucene.index.SortedSetDocValues; //导入方法依赖的package包/类
/** Creates this, pulling doc values from the specified
 *  field. */
public DefaultSortedSetDocValuesReaderState(IndexReader reader, String field) throws IOException {
  this.field = field;
  this.origReader = reader;

  // We need this to create thread-safe MultiSortedSetDV
  // per collector:
  topReader = SlowCompositeReaderWrapper.wrap(reader);
  SortedSetDocValues dv = topReader.getSortedSetDocValues(field);
  if (dv == null) {
    throw new IllegalArgumentException("field \"" + field + "\" was not indexed with SortedSetDocValues");
  }
  if (dv.getValueCount() > Integer.MAX_VALUE) {
    throw new IllegalArgumentException("can only handle valueCount < Integer.MAX_VALUE; got " + dv.getValueCount());
  }
  valueCount = (int) dv.getValueCount();

  // TODO: we can make this more efficient if eg we can be
  // "involved" when OrdinalMap is being created?  Ie see
  // each term/ord it's assigning as it goes...
  String lastDim = null;
  int startOrd = -1;

  // TODO: this approach can work for full hierarchy?;
  // TaxoReader can't do this since ords are not in
  // "sorted order" ... but we should generalize this to
  // support arbitrary hierarchy:
  for(int ord=0;ord<valueCount;ord++) {
    final BytesRef term = dv.lookupOrd(ord);
    String[] components = FacetsConfig.stringToPath(term.utf8ToString());
    if (components.length != 2) {
      throw new IllegalArgumentException("this class can only handle 2 level hierarchy (dim/value); got: " + Arrays.toString(components) + " " + term.utf8ToString());
    }
    if (!components[0].equals(lastDim)) {
      if (lastDim != null) {
        prefixToOrdRange.put(lastDim, new OrdRange(startOrd, ord-1));
      }
      startOrd = ord;
      lastDim = components[0];
    }
  }

  if (lastDim != null) {
    prefixToOrdRange.put(lastDim, new OrdRange(startOrd, valueCount-1));
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:48,代码来源:DefaultSortedSetDocValuesReaderState.java

示例6: getSortedSetDocValues

import org.apache.lucene.index.SortedSetDocValues; //导入方法依赖的package包/类
@Override
public SortedSetDocValues getSortedSetDocValues(String field) throws IOException {
  final SortedSetDocValues sortedSetDocValues = in.getSortedSetDocValues(field);
  if (sortedSetDocValues == null) {
    return null;
  }
  return new SortedSetDocValues() {

    private boolean _access;

    @Override
    public void setDocument(int docID) {
      try {
        if (_access = _accessControl.hasAccess(ReadType.SORTED_SET_DOC_VALUE, docID)) {
          sortedSetDocValues.setDocument(docID);
        }
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }

    @Override
    public long nextOrd() {
      if (_access) {
        return sortedSetDocValues.nextOrd();
      }
      return NO_MORE_ORDS;
    }

    @Override
    public void lookupOrd(long ord, BytesRef result) {
      if (_access) {
        sortedSetDocValues.lookupOrd(ord, result);
      } else {
        result.bytes = BinaryDocValues.MISSING;
        result.length = 0;
        result.offset = 0;
      }
    }

    @Override
    public long getValueCount() {
      return sortedSetDocValues.getValueCount();
    }
  };
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:47,代码来源:SecureAtomicReader.java

示例7: DefaultSortedSetDocValuesReaderState

import org.apache.lucene.index.SortedSetDocValues; //导入方法依赖的package包/类
/** Creates this, pulling doc values from the specified
 *  field. */
public DefaultSortedSetDocValuesReaderState(IndexReader reader, String field) throws IOException {
  this.field = field;
  this.origReader = reader;

  // We need this to create thread-safe MultiSortedSetDV
  // per collector:
  topReader = SlowCompositeReaderWrapper.wrap(reader);
  SortedSetDocValues dv = topReader.getSortedSetDocValues(field);
  if (dv == null) {
    throw new IllegalArgumentException("field \"" + field + "\" was not indexed with SortedSetDocValues");
  }
  if (dv.getValueCount() > Integer.MAX_VALUE) {
    throw new IllegalArgumentException("can only handle valueCount < Integer.MAX_VALUE; got " + dv.getValueCount());
  }
  valueCount = (int) dv.getValueCount();

  // TODO: we can make this more efficient if eg we can be
  // "involved" when OrdinalMap is being created?  Ie see
  // each term/ord it's assigning as it goes...
  String lastDim = null;
  int startOrd = -1;
  BytesRef spare = new BytesRef();

  // TODO: this approach can work for full hierarchy?;
  // TaxoReader can't do this since ords are not in
  // "sorted order" ... but we should generalize this to
  // support arbitrary hierarchy:
  for(int ord=0;ord<valueCount;ord++) {
    dv.lookupOrd(ord, spare);
    String[] components = FacetsConfig.stringToPath(spare.utf8ToString());
    if (components.length != 2) {
      throw new IllegalArgumentException("this class can only handle 2 level hierarchy (dim/value); got: " + Arrays.toString(components) + " " + spare.utf8ToString());
    }
    if (!components[0].equals(lastDim)) {
      if (lastDim != null) {
        prefixToOrdRange.put(lastDim, new OrdRange(startOrd, ord-1));
      }
      startOrd = ord;
      lastDim = components[0];
    }
  }

  if (lastDim != null) {
    prefixToOrdRange.put(lastDim, new OrdRange(startOrd, valueCount-1));
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:49,代码来源:DefaultSortedSetDocValuesReaderState.java

示例8: SortedSetDocValuesReaderState

import org.apache.lucene.index.SortedSetDocValues; //导入方法依赖的package包/类
/** Create an instance, scanning the {@link
 *  SortedSetDocValues} from the provided reader and
 *  {@link FacetIndexingParams}. */
public SortedSetDocValuesReaderState(FacetIndexingParams fip, IndexReader reader) throws IOException {

  this.field = fip.getCategoryListParams(null).field + FACET_FIELD_EXTENSION;
  this.separator = fip.getFacetDelimChar();
  this.separatorRegex = Pattern.quote(Character.toString(separator));
  this.origReader = reader;

  // We need this to create thread-safe MultiSortedSetDV
  // per collector:
  topReader = SlowCompositeReaderWrapper.wrap(reader);
  SortedSetDocValues dv = topReader.getSortedSetDocValues(field);
  if (dv == null) {
    throw new IllegalArgumentException("field \"" + field + "\" was not indexed with SortedSetDocValues");
  }
  if (dv.getValueCount() > Integer.MAX_VALUE) {
    throw new IllegalArgumentException("can only handle valueCount < Integer.MAX_VALUE; got " + dv.getValueCount());
  }
  valueCount = (int) dv.getValueCount();

  // TODO: we can make this more efficient if eg we can be
  // "involved" when OrdinalMap is being created?  Ie see
  // each term/ord it's assigning as it goes...
  String lastDim = null;
  int startOrd = -1;
  BytesRef spare = new BytesRef();

  // TODO: this approach can work for full hierarchy?;
  // TaxoReader can't do this since ords are not in
  // "sorted order" ... but we should generalize this to
  // support arbitrary hierarchy:
  for(int ord=0;ord<valueCount;ord++) {
    dv.lookupOrd(ord, spare);
    String[] components = spare.utf8ToString().split(separatorRegex, 2);
    if (components.length != 2) {
      throw new IllegalArgumentException("this class can only handle 2 level hierarchy (dim/value); got: " + spare.utf8ToString());
    }
    if (!components[0].equals(lastDim)) {
      if (lastDim != null) {
        prefixToOrdRange.put(lastDim, new OrdRange(startOrd, ord-1));
      }
      startOrd = ord;
      lastDim = components[0];
    }
  }

  if (lastDim != null) {
    prefixToOrdRange.put(lastDim, new OrdRange(startOrd, valueCount-1));
  }
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:53,代码来源:SortedSetDocValuesReaderState.java


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