/** 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, BitSet 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); }
/** Wraps the provided {@link SortedNumericDocValues} in order to only select * one value per parent among its {@code children} using the configured * {@code selection} type. */ public static NumericDocValues wrap(SortedNumericDocValues sortedNumerics, Type selection, BitSet parents, BitSet children) { NumericDocValues values; switch (selection) { case MIN: values = SortedNumericSelector.wrap(sortedNumerics, SortedNumericSelector.Type.MIN, SortField.Type.LONG); break; case MAX: values = SortedNumericSelector.wrap(sortedNumerics, SortedNumericSelector.Type.MAX, SortField.Type.LONG); break; default: throw new AssertionError(); } return wrap(values, DocValues.docsWithValue(sortedNumerics, parents.length()), selection, parents, children); }
@Override protected NumericDocValues getNumericDocValues(LeafReaderContext context, String field) throws IOException { SortedNumericDocValues sortedNumeric = DocValues.getSortedNumeric(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.emptyNumeric(); } return BlockJoinSelector.wrap(sortedNumeric, type, parents, children); } @Override
@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, children); }
@Override protected NumericDocValues getNumericDocValues(LeafReaderContext context, String field) throws IOException { SortedNumericDocValues sortedNumeric = DocValues.getSortedNumeric(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.emptyNumeric(); } return BlockJoinSelector.wrap(sortedNumeric, type, parents, children); } @Override
@Override protected NumericDocValues getNumericDocValues(LeafReaderContext context, String field) throws IOException { SortedNumericDocValues sortedNumeric = DocValues.getSortedNumeric(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.emptyNumeric(); } final NumericDocValues view = BlockJoinSelector.wrap(sortedNumeric, type, parents, children); // undo the numericutils sortability return new NumericDocValues() { @Override public long get(int docID) { return NumericUtils.sortableDoubleBits(view.get(docID)); } }; } @Override
@Override protected NumericDocValues getNumericDocValues(LeafReaderContext context, String field) throws IOException { SortedNumericDocValues sortedNumeric = DocValues.getSortedNumeric(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.emptyNumeric(); } final NumericDocValues view = BlockJoinSelector.wrap(sortedNumeric, type, parents, children); // undo the numericutils sortability return new NumericDocValues() { @Override public long get(int docID) { return NumericUtils.sortableFloatBits((int) view.get(docID)); } }; } };
@Override protected Bits getDocsWithValue(LeafReaderContext context, String field) throws IOException { final Bits docsWithValue = DocValues.getDocsWithField(context.reader(), field); final BitSet parents = parentFilter.getBitSet(context); final BitSet children = childFilter.getBitSet(context); if (children == null) { return new Bits.MatchNoBits(context.reader().maxDoc()); } return BlockJoinSelector.wrap(docsWithValue, parents, children); } };
@Override protected Bits getDocsWithValue(LeafReaderContext context, String field) throws IOException { final Bits docsWithValue = DocValues.getDocsWithField(context.reader(), field); final BitSet parents = parentFilter.getBitSet(context); final BitSet children = childFilter.getBitSet(context); if (children == null) { return new Bits.MatchNoBits(context.reader().maxDoc()); } return BlockJoinSelector.wrap(docsWithValue, parents, children); } };
@Override protected Bits getDocsWithValue(LeafReaderContext context, String field) throws IOException { final Bits docsWithValue = DocValues.getDocsWithField(context.reader(), field); final BitSet parents = parentFilter.getBitSet(context); final BitSet children = childFilter.getBitSet(context); if (children == null) { return new Bits.MatchNoBits(context.reader().maxDoc()); } return BlockJoinSelector.wrap(docsWithValue, parents, children); } };