Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up date_histogram without children #63643

Merged
merged 60 commits into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
3eb94bc
Execute date_histo agg as date_range agg
nik9000 Oct 8, 2020
3f99f04
factor out collector
nik9000 Oct 12, 2020
6c8cb0b
ordered
nik9000 Oct 12, 2020
995ca24
refactor
nik9000 Oct 12, 2020
d7becd8
Fixup
nik9000 Oct 12, 2020
0a1987d
Better name
nik9000 Oct 12, 2020
1258ad4
Experiment
nik9000 Oct 12, 2020
da02047
Rework
nik9000 Oct 12, 2020
9157f00
Use query
nik9000 Oct 13, 2020
20047dc
Super hack
nik9000 Oct 13, 2020
e69628e
Shuffle
nik9000 Oct 13, 2020
607ae5f
Tests
nik9000 Oct 13, 2020
0e68cad
look
nik9000 Oct 13, 2020
9754fb0
no looking
nik9000 Oct 13, 2020
0750aa8
tests
nik9000 Oct 13, 2020
c57c98a
Handle unbounded ranges
nik9000 Oct 13, 2020
4021327
Test for max and min
nik9000 Oct 13, 2020
7a44c21
Merge branch 'master' into date_histo_as_range
nik9000 Oct 14, 2020
73aaa45
Fixup profiler
nik9000 Oct 14, 2020
b73df70
Rate agg
nik9000 Oct 14, 2020
b7e8dcc
WIP
nik9000 Oct 14, 2020
7c18141
Fixup weird formats
nik9000 Oct 14, 2020
2d04e35
Feh
nik9000 Oct 14, 2020
102e526
Shift
nik9000 Oct 14, 2020
e333cbb
Forbidden
nik9000 Oct 14, 2020
e2fd164
Moar tests
nik9000 Oct 15, 2020
46a1015
test
nik9000 Oct 15, 2020
deb5684
Fixup tests
nik9000 Oct 15, 2020
de96179
precommit
nik9000 Oct 15, 2020
4e9c918
Merge branch 'master' into date_histo_as_range
nik9000 Oct 16, 2020
f13a8ae
Drop old extra test
nik9000 Oct 16, 2020
6b33247
TODO
nik9000 Oct 19, 2020
14b4962
Merge branch 'master' into date_histo_as_range
nik9000 Oct 20, 2020
2fd7e53
Don't attempt the optimization if rounding would break it
nik9000 Oct 20, 2020
97c35cd
move building
nik9000 Oct 20, 2020
6c7eaa1
Computers are hard
nik9000 Oct 20, 2020
5b5ac7b
Merge branch 'master' into date_histo_as_range
nik9000 Oct 20, 2020
117eb77
Moar javadoc
nik9000 Oct 20, 2020
08fee6c
Merge branch 'master' into date_histo_as_range
nik9000 Oct 22, 2020
ce640e3
Test cases we can't do it
nik9000 Oct 22, 2020
523d420
Fix broken test
nik9000 Oct 22, 2020
f1ae980
Zap
nik9000 Oct 22, 2020
9da87c5
Words
nik9000 Oct 22, 2020
3d3ea19
Coment
nik9000 Oct 22, 2020
4291b70
Add fancy query
nik9000 Oct 22, 2020
ff41cdb
NOCOMMIT
nik9000 Oct 26, 2020
a5f0009
Merge branch 'master' into date_histo_as_range
nik9000 Oct 28, 2020
ec5bf41
tests
nik9000 Oct 28, 2020
6b5c09a
missing tests
nik9000 Oct 28, 2020
9c26fd8
remove!
nik9000 Oct 28, 2020
c5b0464
Merge branch 'master' into date_histo_as_range
nik9000 Oct 29, 2020
66684f2
I think this is more normal
nik9000 Oct 29, 2020
b1c79b2
Merge branch 'master' into date_histo_as_range
nik9000 Nov 5, 2020
997e9b9
Feedback
nik9000 Nov 5, 2020
9494447
Merge branch 'master' into date_histo_as_range
nik9000 Nov 5, 2020
bfb10bd
Merge branch 'master' into date_histo_as_range
nik9000 Nov 6, 2020
1e1b1dd
ConstantScoreWeight
nik9000 Nov 6, 2020
ca09463
Merge branch 'master' into date_histo_as_range
nik9000 Nov 6, 2020
5b5d6cc
Iter
nik9000 Nov 9, 2020
fc1444d
Merge branch 'master' into date_histo_as_range
nik9000 Nov 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -600,5 +600,10 @@ public void preCollection() throws IOException {}

@Override
public void postCollection() throws IOException {}

@Override
public Aggregator[] subAggregators() {
throw new UnsupportedOperationException();
}
}
}
18 changes: 18 additions & 0 deletions server/src/main/java/org/elasticsearch/common/Rounding.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ public interface Prepared {
* next rounded value in specified units if possible.
*/
double roundingSize(long utcMillis, DateTimeUnit timeUnit);

long[] fixedRoundingPoints();
}
/**
* Prepare to round many times.
Expand Down Expand Up @@ -435,6 +437,11 @@ protected Prepared maybeUseArray(long minUtcMillis, long maxUtcMillis, int max)
}
return new ArrayRounding(values, i, this);
}

@Override
public long[] fixedRoundingPoints() {
return null;
}
}

static class TimeUnitRounding extends Rounding {
Expand Down Expand Up @@ -1253,6 +1260,12 @@ public long nextRoundingValue(long utcMillis) {
public double roundingSize(long utcMillis, DateTimeUnit timeUnit) {
return delegatePrepared.roundingSize(utcMillis, timeUnit);
}

@Override
public long[] fixedRoundingPoints() {
// TODO we can likely translate here
return null;
}
};
}

Expand Down Expand Up @@ -1335,5 +1348,10 @@ public long nextRoundingValue(long utcMillis) {
public double roundingSize(long utcMillis, DateTimeUnit timeUnit) {
return delegate.roundingSize(utcMillis, timeUnit);
}

@Override
public long[] fixedRoundingPoints() {
return Arrays.copyOf(values, max);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package org.elasticsearch.search.aggregations;

import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.ScoreMode;
import org.elasticsearch.search.aggregations.bucket.BucketsAggregator;
import org.elasticsearch.search.internal.SearchContext;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public abstract class AdaptingAggregator extends Aggregator {
private final Aggregator delegate;

public AdaptingAggregator(Aggregator delegate) {
this.delegate = delegate;
}

@Override
public void close() {
delegate.close();
}

@Override
public ScoreMode scoreMode() {
return delegate.scoreMode();
}

@Override
public String name() {
return delegate.name();
}

@Override
public SearchContext context() {
return delegate.context();
}

@Override
public Aggregator parent() {
return delegate.parent();
}

@Override
public Aggregator subAggregator(String name) {
return delegate.subAggregator(name);
}

@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx) throws IOException {
return delegate.getLeafCollector(ctx);
}

@Override
public void preCollection() throws IOException {
delegate.preCollection();
}

@Override
public void postCollection() throws IOException {
delegate.postCollection();
}

@Override
public InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws IOException {
InternalAggregation[] delegateResults = delegate.buildAggregations(owningBucketOrds);
InternalAggregation[] result = new InternalAggregation[owningBucketOrds.length];
for (int ordIdx = 0; ordIdx < owningBucketOrds.length; ordIdx++) {
result[ordIdx] = adapt(delegateResults[ordIdx]);
}
return result;
}

@Override
public InternalAggregation buildEmptyAggregation() {
return adapt(delegate.buildEmptyAggregation());
}

@Override
public Aggregator[] subAggregators() {
return delegate.subAggregators();
}

protected abstract InternalAggregation adapt(InternalAggregation delegateResult);
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ public final InternalAggregation buildTopLevel() throws IOException {
*/
public void collectDebugInfo(BiConsumer<String, Object> add) {}

/**
* Get the aggregators running under this one.
*/
public abstract Aggregator[] subAggregators();

/** Aggregation mode for sub aggregations. */
public enum SubAggCollectionMode implements Writeable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public Aggregator parent() {
return parent;
}

@Override
public Aggregator[] subAggregators() {
return subAggregators;
}
Expand Down Expand Up @@ -277,7 +278,7 @@ protected void doClose() {}
protected void doPostCollection() throws IOException {
}

protected final InternalAggregations buildEmptySubAggregations() {
public final InternalAggregations buildEmptySubAggregations() {
List<InternalAggregation> aggs = new ArrayList<>();
for (Aggregator aggregator : subAggregators) {
aggs.add(aggregator.buildEmptyAggregation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ public Aggregator resolveSortPath(PathElement next, Iterator<PathElement> path)
public BucketComparator bucketComparator(String key, SortOrder order) {
throw new UnsupportedOperationException("Can't sort on deferred aggregations");
}

@Override
public Aggregator[] subAggregators() {
return in.subAggregators();
}
}

}
Loading