@Override public boolean needsScores() { return valuesSource != null && valuesSource.needsScores(); }
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { if (valuesSource == null) { return LeafBucketCollector.NO_OP_COLLECTOR; } final BigArrays bigArrays = context.bigArrays(); final SortedBinaryDocValues values = valuesSource.bytesValues(ctx); return new LeafBucketCollectorBase(sub, values) { @Override public void collect(int doc, long bucket) throws IOException { counts = bigArrays.grow(counts, bucket + 1); if (values.advanceExact(doc)) { counts.increment(bucket, values.docValueCount()); } } }; }
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { final DocValueBits docsWithValue; if (valuesSource != null) { docsWithValue = valuesSource.docsWithValue(ctx); } else { docsWithValue = new DocValueBits() { @Override public boolean advanceExact(int doc) throws IOException { return false; } }; } return new LeafBucketCollectorBase(sub, docsWithValue) { @Override public void collect(int doc, long bucket) throws IOException { if (docsWithValue.advanceExact(doc) == false) { collectBucket(sub, doc, bucket); } } }; }
@Override protected NumericDocValues getKeys(LeafReaderContext context) { try { values = valuesSource.bytesValues(context); } catch (IOException e) { throw new ElasticsearchException("Error reading values", e);
@Override public boolean needsScores() { return (valuesSource != null && valuesSource.needsScores()) || super.needsScores(); }
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { final DocValueBits docsWithValue; if (valuesSource != null) { docsWithValue = valuesSource.docsWithValue(ctx); } else { docsWithValue = new DocValueBits() { @Override public boolean advanceExact(int doc) throws IOException { return false; } }; } return new LeafBucketCollectorBase(sub, docsWithValue) { @Override public void collect(int doc, long bucket) throws IOException { if (docsWithValue.advanceExact(doc) == false) { collectBucket(sub, doc, bucket); } } }; }
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { final SortedBinaryDocValues values = valuesSource.bytesValues(ctx); return new LeafBucketCollectorBase(sub, values) { final BytesRefBuilder previous = new BytesRefBuilder();
for (int i = 0; i < configs.length; i++) { configs[i] = sources.get(i).build(context); if (configs[i].valuesSource().needsScores()) { throw new IllegalArgumentException("[sources] cannot access _score");
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { final DocValueBits docsWithValue; if (valuesSource != null) { docsWithValue = valuesSource.docsWithValue(ctx); } else { docsWithValue = new DocValueBits() { @Override public boolean advanceExact(int doc) throws IOException { return false; } }; } return new LeafBucketCollectorBase(sub, docsWithValue) { @Override public void collect(int doc, long bucket) throws IOException { if (docsWithValue.advanceExact(doc) == false) { collectBucket(sub, doc, bucket); } } }; }
@Override protected NumericDocValues getKeys(LeafReaderContext context) { try { values = valuesSource.bytesValues(context); } catch (IOException e) { throw new ElasticsearchException("Error reading values", e);
public boolean needsScores() { boolean needsScores = false; for (ValuesSource value : values) { needsScores |= value.needsScores(); } return needsScores; }
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { final Bits docsWithValue; if (valuesSource != null) { docsWithValue = valuesSource.docsWithValue(ctx); } else { docsWithValue = new Bits.MatchNoBits(ctx.reader().maxDoc()); } return new LeafBucketCollectorBase(sub, docsWithValue) { @Override public void collect(int doc, long bucket) throws IOException { if (docsWithValue != null && !docsWithValue.get(doc)) { collectBucket(sub, doc, bucket); } } }; }
@Override public SortedBinaryDocValues bytesValues(LeafReaderContext context) throws IOException { return new BytesValues(delegate.bytesValues(context), script.newInstance(context)); }
@Override public boolean needsScores() { return valuesSource != null && valuesSource.needsScores(); }
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { final Bits docsWithValue; if (valuesSource != null) { docsWithValue = valuesSource.docsWithValue(ctx); } else { docsWithValue = new Bits.MatchNoBits(ctx.reader().maxDoc()); } return new LeafBucketCollectorBase(sub, docsWithValue) { @Override public void collect(int doc, long bucket) throws IOException { if (docsWithValue != null && !docsWithValue.get(doc)) { collectBucket(sub, doc, bucket); } } }; }
private Collector pickCollector(LeafReaderContext ctx) throws IOException { if (valuesSource == null) { return new EmptyCollector(); } if (valuesSource instanceof ValuesSource.Numeric) { ValuesSource.Numeric source = (ValuesSource.Numeric) valuesSource; MurmurHash3Values hashValues = source.isFloatingPoint() ? MurmurHash3Values.hash(source.doubleValues(ctx)) : MurmurHash3Values.hash(source.longValues(ctx)); return new DirectCollector(counts, hashValues); } if (valuesSource instanceof ValuesSource.Bytes.WithOrdinals) { ValuesSource.Bytes.WithOrdinals source = (ValuesSource.Bytes.WithOrdinals) valuesSource; final SortedSetDocValues ordinalValues = source.ordinalsValues(ctx); final long maxOrd = ordinalValues.getValueCount(); if (maxOrd == 0) { return new EmptyCollector(); } final long ordinalsMemoryUsage = OrdinalsCollector.memoryOverhead(maxOrd); final long countsMemoryUsage = HyperLogLogPlusPlus.memoryUsage(precision); // only use ordinals if they don't increase memory usage by more than 25% if (ordinalsMemoryUsage < countsMemoryUsage / 4) { return new OrdinalsCollector(counts, ordinalValues, context.bigArrays()); } } return new DirectCollector(counts, MurmurHash3Values.hash(valuesSource.bytesValues(ctx))); }
public boolean needsScores() { boolean needsScores = false; for (ValuesSource value : values) { needsScores |= value.needsScores(); } return needsScores; }
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { if (valuesSource == null) { return LeafBucketCollector.NO_OP_COLLECTOR; } final BigArrays bigArrays = context.bigArrays(); final SortedBinaryDocValues values = valuesSource.bytesValues(ctx); return new LeafBucketCollectorBase(sub, values) { @Override public void collect(int doc, long bucket) throws IOException { counts = bigArrays.grow(counts, bucket + 1); if (values.advanceExact(doc)) { counts.increment(bucket, values.docValueCount()); } } }; }
@Override public boolean needsScores() { return valuesSource != null && valuesSource.needsScores(); }
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { if (valuesSource == null) { return LeafBucketCollector.NO_OP_COLLECTOR; } final BigArrays bigArrays = context.bigArrays(); final SortedBinaryDocValues values = valuesSource.bytesValues(ctx); return new LeafBucketCollectorBase(sub, values) { @Override public void collect(int doc, long bucket) throws IOException { counts = bigArrays.grow(counts, bucket + 1); values.setDocument(doc); counts.increment(bucket, values.count()); } }; }