Java Code Examples for org.apache.lucene.index.SortedDocValues

The following examples show how to use org.apache.lucene.index.SortedDocValues. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: lucene-solr   Source File: ExpandComponent.java    License: Apache License 2.0 6 votes vote down vote up
public GroupExpandCollector(SortedDocValues docValues, FixedBitSet groupBits, IntHashSet collapsedSet, int limit, Sort sort) throws IOException {
  int numGroups = collapsedSet.size();
  groups = new LongObjectHashMap<>(numGroups);
  DocIdSetIterator iterator = new BitSetIterator(groupBits, 0); // cost is not useful here
  int group;
  while ((group = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
    groups.put(group, getCollector(limit, sort));
  }

  this.collapsedSet = collapsedSet;
  this.groupBits = groupBits;
  this.docValues = docValues;
  if(docValues instanceof MultiDocValues.MultiSortedDocValues) {
    this.multiSortedDocValues = (MultiDocValues.MultiSortedDocValues)docValues;
    this.ordinalMap = multiSortedDocValues.mapping;
  }
}
 
Example 2
Source Project: lucene-solr   Source File: LegacyDocValuesIterables.java    License: Apache License 2.0 6 votes vote down vote up
/** Converts {@link SortedDocValues} into an {@code Iterable&lt;BytesRef&gt;} for all the values.
 *
 * @deprecated Consume {@link SortedDocValues} instead. */
@Deprecated
public static Iterable<BytesRef> valuesIterable(final SortedDocValues values) {
  return new Iterable<BytesRef>() {
    @Override
    public Iterator<BytesRef> iterator() {
      return new Iterator<BytesRef>() {
        private int nextOrd;
  
        @Override
        public boolean hasNext() {
          return nextOrd < values.getValueCount();
        }

        @Override
        public BytesRef next() {
          try {
            return values.lookupOrd(nextOrd++);
          } catch (IOException e) {
            throw new RuntimeException(e);
          }
        }
      };
    }
  };
}
 
Example 3
Source Project: lucene-solr   Source File: FieldUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static void visitOrds(SortedDocValues singleDv, DocIdSetIterator disi, OrdFunc ordFunc) throws IOException {
  int doc;
  if (singleDv instanceof FieldCacheImpl.SortedDocValuesImpl.Iter) {
    FieldCacheImpl.SortedDocValuesImpl.Iter fc = (FieldCacheImpl.SortedDocValuesImpl.Iter) singleDv;
    while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
      ordFunc.handleOrd(doc, fc.getOrd(doc));
    }
  } else {
    while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
      if (singleDv.advanceExact(doc)) {
        ordFunc.handleOrd(doc, singleDv.ordValue());
      } else {
        // TODO: optionally pass in missingOrd?
      }
    }
  }
}
 
Example 4
Source Project: lucene-solr   Source File: GlobalOrdinalsQuery.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
  SortedDocValues values = DocValues.getSorted(context.reader(), joinField);
  if (values == null) {
    return Explanation.noMatch("Not a match");
  }

  if (values.advance(doc) != doc) {
    return Explanation.noMatch("Not a match");
  }
  int segmentOrd = values.ordValue();
  BytesRef joinValue = values.lookupOrd(segmentOrd);

  int ord;
  if (globalOrds != null) {
    ord = (int) globalOrds.getGlobalOrds(context.ord).get(segmentOrd);
  } else {
    ord = segmentOrd;
  }
  if (foundOrds.get(ord) == false) {
    return Explanation.noMatch("Not a match, join value " + Term.toString(joinValue));
  }

  return Explanation.match(score(), "A match, join value " + Term.toString(joinValue));
}
 
Example 5
Source Project: lucene-solr   Source File: GlobalOrdinalsQuery.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Scorer scorer(LeafReaderContext context) throws IOException {
  SortedDocValues values = DocValues.getSorted(context.reader(), joinField);
  if (values == null) {
    return null;
  }

  Scorer approximationScorer = approximationWeight.scorer(context);
  if (approximationScorer == null) {
    return null;
  }
  if (globalOrds != null) {
    return new OrdinalMapScorer(this, score(), foundOrds, values, approximationScorer.iterator(), globalOrds.getGlobalOrds(context.ord));
  } {
    return new SegmentOrdinalScorer(this, score(), foundOrds, values, approximationScorer.iterator());
  }
}
 
Example 6
@Override
public SortedDocValues getSorted(FieldInfo field) throws IOException {
  SortedDocValues sortedDocValues = _sortedDocValuesCache.get(field.number);
  if (sortedDocValues != null) {
    return sortedDocValues;
  }
  synchronized (_sortedDocValuesCache) {
    sortedDocValues = _sortedDocValuesCache.get(field.number);
    if (sortedDocValues != null) {
      return sortedDocValues;
    }
    sortedDocValues = newSortedDocValues(field);
    if (_cache && sortedDocValues != null) {
      _sortedDocValuesCache.put(field.number, sortedDocValues);
    }
    return sortedDocValues;
  }
}
 
Example 7
Source Project: lucene-solr   Source File: CollapsingQParserPlugin.java    License: Apache License 2.0 6 votes vote down vote up
public OrdLongStrategy(int maxDoc,
                       int nullPolicy,
                       int valueCount,
                       GroupHeadSelector groupHeadSelector,
                       boolean needsScores,
                       IntIntHashMap boostDocs, SortedDocValues values) throws IOException {
  super(maxDoc, valueCount, nullPolicy, needsScores, boostDocs, values);
  this.field = groupHeadSelector.selectorText;

  assert GroupHeadSelectorType.MIN_MAX.contains(groupHeadSelector.type);

  if (GroupHeadSelectorType.MAX.equals(groupHeadSelector.type)) {
    comp = new MaxLongComp();
    this.ordVals = new IntLongDynamicMap(valueCount, Long.MIN_VALUE);
  } else {
    this.nullVal = Long.MAX_VALUE;
    comp = new MinLongComp();
    this.ordVals = new IntLongDynamicMap(valueCount, Long.MAX_VALUE);
  }
}
 
Example 8
Source Project: lucene-solr   Source File: CollapsingQParserPlugin.java    License: Apache License 2.0 6 votes vote down vote up
public OrdIntStrategy(int maxDoc,
                      int nullPolicy,
                      int valueCount,
                      GroupHeadSelector groupHeadSelector,
                      boolean needsScores,
                      IntIntHashMap boostDocs,
                      SortedDocValues values) throws IOException {
  super(maxDoc, valueCount, nullPolicy, needsScores, boostDocs, values);
  this.field = groupHeadSelector.selectorText;

  assert GroupHeadSelectorType.MIN_MAX.contains(groupHeadSelector.type);

  if (GroupHeadSelectorType.MAX.equals(groupHeadSelector.type)) {
    comp = new MaxIntComp();
    this.ordVals = new IntIntDynamicMap(valueCount, Integer.MIN_VALUE);
  } else {
    comp = new MinIntComp();
    this.ordVals = new IntIntDynamicMap(valueCount, Integer.MAX_VALUE);
    this.nullVal = Integer.MAX_VALUE;
  }
}
 
Example 9
Source Project: lucene-solr   Source File: GlobalOrdinalsWithScoreQuery.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Scorer scorer(LeafReaderContext context) throws IOException {
  SortedDocValues values = DocValues.getSorted(context.reader(), joinField);
  if (values == null) {
    return null;
  }

  Scorer approximationScorer = in.scorer(context);
  if (approximationScorer == null) {
    return null;
  } else if (globalOrds != null) {
    return new OrdinalMapScorer(this, collector, values, approximationScorer.iterator(), globalOrds.getGlobalOrds(context.ord));
  } else {
    return new SegmentOrdinalScorer(this, collector, values, approximationScorer.iterator());
  }
}
 
Example 10
Source Project: lucene-solr   Source File: ToParentBlockJoinSortField.java    License: Apache License 2.0 6 votes vote down vote up
private FieldComparator<?> getStringComparator(int numHits) {
  return new FieldComparator.TermOrdValComparator(numHits, getField(), missingValue == STRING_LAST) {

    @Override
    protected SortedDocValues getSortedDocValues(LeafReaderContext context, String field) throws IOException {
      SortedSetDocValues sortedSet = DocValues.getSortedSet(context.reader(), field);
      final BlockJoinSelector.Type type = order
          ? BlockJoinSelector.Type.MAX
          : BlockJoinSelector.Type.MIN;
      final BitSet parents = parentFilter.getBitSet(context);
      final BitSet children = childFilter.getBitSet(context);
      if (children == null) {
        return DocValues.emptySorted();
      }
      return BlockJoinSelector.wrap(sortedSet, type, parents, toIter(children));
    }

  };
}
 
Example 11
Source Project: lucene-solr   Source File: CollapsingQParserPlugin.java    License: Apache License 2.0 6 votes vote down vote up
public OrdFloatStrategy(int maxDoc,
                        int nullPolicy,
                        int valueCount,
                        GroupHeadSelector groupHeadSelector,
                        boolean needsScores,
                        IntIntHashMap boostDocs,
                        SortedDocValues values) throws IOException {
  super(maxDoc, valueCount, nullPolicy, needsScores, boostDocs, values);
  this.field = groupHeadSelector.selectorText;

  assert GroupHeadSelectorType.MIN_MAX.contains(groupHeadSelector.type);

  if (GroupHeadSelectorType.MAX.equals(groupHeadSelector.type)) {
    comp = new MaxFloatComp();
    this.ordVals = new IntFloatDynamicMap(valueCount, -Float.MAX_VALUE);
    this.nullVal = -Float.MAX_VALUE;
  } else {
    comp = new MinFloatComp();
    this.ordVals = new IntFloatDynamicMap(valueCount, Float.MAX_VALUE);
    this.nullVal = Float.MAX_VALUE;
  }
}
 
Example 12
Source Project: lucene-solr   Source File: SortedSetSelector.java    License: Apache License 2.0 6 votes vote down vote up
/** Wraps a multi-valued SortedSetDocValues as a single-valued view, using the specified selector */
public static SortedDocValues wrap(SortedSetDocValues sortedSet, Type selector) {
  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 {
    switch(selector) {
      case MIN: return new MinValue(sortedSet);
      case MAX: return new MaxValue(sortedSet);
      case MIDDLE_MIN: return new MiddleMinValue(sortedSet);
      case MIDDLE_MAX: return new MiddleMaxValue(sortedSet);
      default: 
        throw new AssertionError();
    }
  }
}
 
Example 13
Source Project: lucene-solr   Source File: IntervalFacets.java    License: Apache License 2.0 6 votes vote down vote up
private void accumIntervalsSingle(SortedDocValues sdv, DocIdSetIterator disi, Bits bits) throws IOException {
  // First update the ordinals in the intervals to this segment
  for (FacetInterval interval : intervals) {
    interval.updateContext(sdv);
  }
  int doc;
  while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
    if (bits != null && bits.get(doc) == false) {
      continue;
    }
    if (doc > sdv.docID()) {
      sdv.advance(doc);
    }
    if (doc == sdv.docID()) {
      accumInterval(sdv.ordValue());
    }
  }
}
 
Example 14
Source Project: lucene-solr   Source File: DocValuesFacets.java    License: Apache License 2.0 6 votes vote down vote up
/** accumulates per-segment single-valued facet counts, mapping to global ordinal space on-the-fly */
static void accumSingleGeneric(int counts[], int startTermIndex, SortedDocValues si, DocIdSetIterator disi, int subIndex, OrdinalMap map) throws IOException {
  final LongValues ordmap = map == null ? null : map.getGlobalOrds(subIndex);
  int doc;
  while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
    int term;
    if (si.advanceExact(doc)) {
      term = si.ordValue();
    } else {
      term = -1;
    }
    if (map != null && term >= 0) {
      term = (int) ordmap.get(term);
    }
    int arrIdx = term-startTermIndex;
    if (arrIdx>=0 && arrIdx<counts.length) counts[arrIdx]++;
  }
}
 
Example 15
Source Project: lucene-solr   Source File: DocValuesFacets.java    License: Apache License 2.0 6 votes vote down vote up
/** "typical" single-valued faceting: not too many unique values, no prefixing. maps to global ordinals as a separate step */
static void accumSingleSeg(int counts[], SortedDocValues 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+si.getValueCount()];
  }
  
  int doc;
  while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
    if (si.advanceExact(doc)) {
      segCounts[1+si.ordValue()]++;
    } else {
      segCounts[0]++;
    }
  }
  
  // migrate to global ords (if necessary)
  if (map != null) {
    migrateGlobal(counts, segCounts, subIndex, map);
  }
}
 
Example 16
Source Project: lucene-solr   Source File: FieldCacheImpl.java    License: Apache License 2.0 6 votes vote down vote up
public SortedDocValues getTermsIndex(LeafReader reader, String field, float acceptableOverheadRatio) throws IOException {
  SortedDocValues valuesIn = reader.getSortedDocValues(field);
  if (valuesIn != null) {
    // Not cached here by FieldCacheImpl (cached instead
    // per-thread by SegmentReader):
    return valuesIn;
  } else {
    final FieldInfo info = reader.getFieldInfos().fieldInfo(field);
    if (info == null) {
      return DocValues.emptySorted();
    } else if (info.getDocValuesType() != DocValuesType.NONE) {
      // we don't try to build a sorted instance from numeric/binary doc
      // values because dedup can be very costly
      throw new IllegalStateException("Type mismatch: " + field + " was indexed as " + info.getDocValuesType());
    } else if (info.getIndexOptions() == IndexOptions.NONE) {
      return DocValues.emptySorted();
    }
    SortedDocValuesImpl impl = (SortedDocValuesImpl) caches.get(SortedDocValues.class).get(reader, new CacheKey(field, acceptableOverheadRatio));
    return impl.iterator();
  }
}
 
Example 17
ReplaceMissing(SortedDocValues in, BytesRef term) {
    this.in = in;
    this.substituteTerm = term;
    int sub = in.lookupTerm(term);
    if (sub < 0) {
        substituteOrd = -sub-1;
        exists = false;
    } else {
        substituteOrd = sub;
        exists = true;
    }
}
 
Example 18
Source Project: lucene-solr   Source File: FieldUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static OrdValues getOrdValues(SortedDocValues singleDv, DocIdSetIterator disi) {
  if (singleDv instanceof FieldCacheImpl.SortedDocValuesImpl.Iter) {
    FieldCacheImpl.SortedDocValuesImpl.Iter fc = (FieldCacheImpl.SortedDocValuesImpl.Iter) singleDv;
    return new FCOrdValues(fc, disi);
  }
  return new DVOrdValues(singleDv, disi);
}
 
Example 19
@Override
public MultiGeoPointValues getGeoPointValues() {
    final RandomAccessOrds ords = ordinals.ordinals();
    final SortedDocValues singleOrds = DocValues.unwrapSingleton(ords);
    final GeoPoint point = new GeoPoint(Double.NaN, Double.NaN);
    if (singleOrds != null) {
        final GeoPointValues values = new GeoPointValues() {
            @Override
            public GeoPoint get(int docID) {
                final int ord = singleOrds.getOrd(docID);
                if (ord >= 0) {
                    return point.resetFromIndexHash(indexedPoints.get(ord));
                }
                return point.reset(Double.NaN, Double.NaN);
            }
        };
        return FieldData.singleton(values, DocValues.docsWithValue(singleOrds, maxDoc));
    }
    return new MultiGeoPointValues() {
        @Override
        public GeoPoint valueAt(int index) {
            return point.resetFromIndexHash(indexedPoints.get(ords.ordAt(index)));
        }

        @Override
        public void setDocument(int docId) {
            ords.setDocument(docId);
        }

        @Override
        public int count() {
            return ords.cardinality();
        }
    };
}
 
Example 20
Source Project: Elasticsearch   Source File: ParentChildAtomicFieldData.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public SortedDocValues getOrdinalsValues(String type) {
    AtomicOrdinalsFieldData atomicFieldData = typeToIds.get(type);
    if (atomicFieldData != null) {
        return MultiValueMode.MIN.select(atomicFieldData.getOrdinalsValues());
    } else {
        return DocValues.emptySorted();
    }
}
 
Example 21
Source Project: Elasticsearch   Source File: ChildrenQuery.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Scorer scorer(LeafReaderContext context) throws IOException {
    DocIdSet parentsSet = parentFilter.getDocIdSet(context, null);
    if (Lucene.isEmpty(parentsSet) || remaining == 0) {
        return null;
    }

    // We can't be sure of the fact that liveDocs have been applied, so we apply it here. The "remaining"
    // count down (short circuit) logic will then work as expected.
    DocIdSetIterator parents = BitsFilteredDocIdSet.wrap(parentsSet, context.reader().getLiveDocs()).iterator();

    if (parents != null) {
        SortedDocValues bytesValues = collector.globalIfd.load(context).getOrdinalsValues(parentType);
        if (bytesValues == null) {
            return null;
        }

        if (minChildren > 0 || maxChildren != 0 || scoreType == ScoreType.NONE) {
            switch (scoreType) {
            case NONE:
                DocIdSetIterator parentIdIterator = new CountParentOrdIterator(this, parents, collector, bytesValues,
                        minChildren, maxChildren);
                return ConstantScorer.create(parentIdIterator, this, queryWeight);
            case AVG:
                return new AvgParentCountScorer(this, parents, collector, bytesValues, minChildren, maxChildren);
            default:
                return new ParentCountScorer(this, parents, collector, bytesValues, minChildren, maxChildren);
            }
        }
        switch (scoreType) {
        case AVG:
            return new AvgParentScorer(this, parents, collector, bytesValues);
        default:
            return new ParentScorer(this, parents, collector, bytesValues);
        }
    }
    return null;
}
 
Example 22
Source Project: lucene-solr   Source File: CollapsingQParserPlugin.java    License: Apache License 2.0 5 votes vote down vote up
public OrdValueSourceStrategy(int maxDoc,
                              int nullPolicy,
                              int valueCount,
                              GroupHeadSelector groupHeadSelector,
                              boolean needsScores4Collapsing,
                              boolean needsScores,
                              IntIntHashMap boostDocs,
                              FunctionQuery funcQuery,
                              IndexSearcher searcher,
                              SortedDocValues values) throws IOException {
  super(maxDoc, valueCount, nullPolicy, needsScores, boostDocs, values);
  this.needsScores4Collapsing = needsScores4Collapsing;
  this.valueSource = funcQuery.getValueSource();
  this.rcontext = ValueSource.newContext(searcher);

  assert GroupHeadSelectorType.MIN_MAX.contains(groupHeadSelector.type);

  if (GroupHeadSelectorType.MAX.equals(groupHeadSelector.type)) {
    comp = new MaxFloatComp();
    this.ordVals = new IntFloatDynamicMap(valueCount, -Float.MAX_VALUE);
  } else {
    this.nullVal = Float.MAX_VALUE;
    comp = new MinFloatComp();
    this.ordVals = new IntFloatDynamicMap(valueCount, Float.MAX_VALUE);
  }

  collapseScore.setupIfNeeded(groupHeadSelector, rcontext);
}
 
Example 23
Source Project: Elasticsearch   Source File: ChildrenQuery.java    License: Apache License 2.0 5 votes vote down vote up
private CountParentOrdIterator(ParentWeight parentWeight, DocIdSetIterator innerIterator, ParentCollector collector, SortedDocValues ordinals, int minChildren, int maxChildren) {
    super(innerIterator);
    this.parentIds = ((CountCollector) collector).parentIdxs;
    this.occurrences = ((CountCollector) collector).occurrences;
    this.ordinals = ordinals;
    this.parentWeight = parentWeight;
    this.minChildren = minChildren;
    this.maxChildren = maxChildren == 0 ? Integer.MAX_VALUE : maxChildren;
}
 
Example 24
protected void runGisDocValueTest(String s) throws IOException {
  DirectoryReader reader = DirectoryReader.open(_dir);
  AtomicReader atomicReader = reader.leaves().get(0).reader();
  SortedDocValues sortedDocValues = atomicReader.getSortedDocValues("fam.geo");
  BytesRef result = new BytesRef();
  sortedDocValues.get(0, result);
  assertEquals(s, result.utf8ToString());
  System.out.println(result.utf8ToString());
  reader.close();
}
 
Example 25
Source Project: lucene-solr   Source File: FacetFieldProcessorByArrayDV.java    License: Apache License 2.0 5 votes vote down vote up
private void collectDocs(SortedDocValues singleDv, DocIdSetIterator disi, LongValues toGlobal) throws IOException {
  int doc;
  while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
    if (singleDv.advanceExact(doc)) {
      int segOrd = singleDv.ordValue();
      collect(doc, segOrd, toGlobal);
    }
  }
}
 
Example 26
Source Project: lucene-solr   Source File: DocValuesAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private Optional<DocValues> createSortedDocValues(int docid, String field, DocValuesType dvType)
    throws IOException {
  SortedDocValues svalues = IndexUtils.getSortedDocValues(reader, field);

  if (svalues.advanceExact(docid)) {
    DocValues dv = DocValues.of(
        dvType,
        Collections.singletonList(BytesRef.deepCopyOf(svalues.binaryValue())),
        Collections.emptyList()
    );
    return Optional.of(dv);
  }

  return Optional.empty();
}
 
Example 27
Source Project: incubator-retired-blur   Source File: SecureAtomicReader.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public SortedDocValues getSortedDocValues(String field) throws IOException {
  final SortedDocValues sortedDocValues = in.getSortedDocValues(field);
  if (sortedDocValues == null) {
    return null;
  }
  return new SortedDocValues() {

    @Override
    public void lookupOrd(int ord, BytesRef result) {
      sortedDocValues.lookupOrd(ord, result);
    }

    @Override
    public int getValueCount() {
      return sortedDocValues.getValueCount();
    }

    @Override
    public int getOrd(int docID) {
      try {
        if (_accessControl.hasAccess(ReadType.SORTED_DOC_VALUE, docID)) {
          return sortedDocValues.getOrd(docID);
        }
        return -1; // Default missing value.
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
  };
}
 
Example 28
Source Project: lucene-solr   Source File: FieldUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static SortedDocValues getSortedDocValues(QueryContext context, SchemaField field, QParser qparser) throws IOException {
  SortedDocValues si = context.searcher().getSlowAtomicReader().getSortedDocValues( field.getName() );
  // if (!field.hasDocValues() && (field.getType() instanceof StrField || field.getType() instanceof TextField)) {
  // }

  return si == null ? DocValues.emptySorted() : si;
}
 
Example 29
Source Project: lucene-solr   Source File: BlockJoinSelector.java    License: Apache License 2.0 5 votes vote down vote up
/** Wraps the provided {@link SortedSetDocValues} in order to only select
 *  one value per parent among its {@code children} using the configured
 *  {@code selection} type. */
public static SortedDocValues wrap(SortedSetDocValues sortedSet, Type selection, BitSet parents, DocIdSetIterator children) {
  SortedDocValues values;
  switch (selection) {
    case MIN:
      values = SortedSetSelector.wrap(sortedSet, SortedSetSelector.Type.MIN);
      break;
    case MAX:
      values = SortedSetSelector.wrap(sortedSet, SortedSetSelector.Type.MAX);
      break;
    default:
      throw new AssertionError();
  }
  return wrap(values, selection, parents, children);
}
 
Example 30
Source Project: lucene-solr   Source File: BlockJoinSelector.java    License: Apache License 2.0 5 votes vote down vote up
/** Wraps the provided {@link SortedDocValues} in order to only select
 *  one value per parent among its {@code children} using the configured
 *  {@code selection} type. */
public static SortedDocValues wrap(final SortedDocValues values, Type selection, BitSet parents, DocIdSetIterator children) {
  if (values.docID() != -1) {
    throw new IllegalArgumentException("values iterator was already consumed: values.docID=" + values.docID());
  }
  return ToParentDocValues.wrap(values, selection, parents, children);
}