Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
3 changes: 2 additions & 1 deletion benchmarks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies {
// us to invoke the JMH uberjar as usual.
exclude group: 'net.sf.jopt-simple', module: 'jopt-simple'
}
api(project(':modules:aggregations'))
expression(project(path: ':modules:lang-expression', configuration: 'zip'))
painless(project(path: ':modules:lang-painless', configuration: 'zip'))
api "org.openjdk.jmh:jmh-core:$versions.jmh"
Expand All @@ -49,7 +50,7 @@ tasks.register('copyExpression', Copy) {
into "${buildDir}/plugins/expression"
}

tasks.register("copyPainless", Copy) {
tasks.register("copyPainless", Copy) {
dependsOn configurations.painless
from { configurations.painless.collect { zipTree(it) } }
into "${buildDir}/plugins/painless"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

package org.elasticsearch.benchmark.search.aggregations.bucket.terms;

import org.elasticsearch.aggregations.bucket.histogram.AutoDateHistogramAggregationBuilder;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.util.PageCacheRecycler;
import org.elasticsearch.search.aggregations.CardinalityUpperBound;
import org.elasticsearch.search.aggregations.bucket.histogram.AutoDateHistogramAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.terms.LongKeyedBucketOrds;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
import org.elasticsearch.action.search.SearchScrollRequest;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.aggregations.bucket.AdjacencyMatrixAggregationBuilder;
import org.elasticsearch.aggregations.bucket.ParsedAdjacencyMatrix;
import org.elasticsearch.aggregations.bucket.adjacency.AdjacencyMatrixAggregationBuilder;
import org.elasticsearch.aggregations.bucket.adjacency.ParsedAdjacencyMatrix;
import org.elasticsearch.aggregations.bucket.histogram.AutoDateHistogramAggregationBuilder;
import org.elasticsearch.aggregations.bucket.histogram.ParsedAutoDateHistogram;
import org.elasticsearch.client.analytics.ParsedStringStats;
import org.elasticsearch.client.analytics.ParsedTopMetrics;
import org.elasticsearch.client.analytics.StringStatsAggregationBuilder;
Expand Down Expand Up @@ -77,10 +79,8 @@
import org.elasticsearch.search.aggregations.bucket.geogrid.ParsedGeoTileGrid;
import org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.global.ParsedGlobal;
import org.elasticsearch.search.aggregations.bucket.histogram.AutoDateHistogramAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.histogram.ParsedAutoDateHistogram;
import org.elasticsearch.search.aggregations.bucket.histogram.ParsedDateHistogram;
import org.elasticsearch.search.aggregations.bucket.histogram.ParsedHistogram;
import org.elasticsearch.search.aggregations.bucket.histogram.ParsedVariableWidthHistogram;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import org.elasticsearch.action.search.SearchPhaseExecutionException;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.aggregations.AggregationsPlugin;
import org.elasticsearch.aggregations.bucket.AdjacencyMatrix.Bucket;
import org.elasticsearch.aggregations.bucket.adjacency.AdjacencyMatrix;
import org.elasticsearch.aggregations.bucket.adjacency.AdjacencyMatrix.Bucket;
import org.elasticsearch.aggregations.bucket.adjacency.AdjacencyMatrixAggregationBuilder;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.plugins.Plugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@
* Side Public License, v 1.
*/

package org.elasticsearch.search.aggregations.pipeline;
package org.elasticsearch.aggregations.pipeline;
Copy link
Member Author

@martijnvg martijnvg Oct 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This java integration test is also using: PipelineAggregationHelperTests. So I already moved this integration test to the aggregations module, for the same reason why the other pipeline unit tests were moved.


import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.aggregations.AggregationsPlugin;
import org.elasticsearch.common.collect.EvictingQueue;
import org.elasticsearch.common.util.Maps;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers;
import org.elasticsearch.search.aggregations.pipeline.SimpleValue;
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -66,6 +71,12 @@ public String toString() {
}
}

// TODO: maybe add base class that overwrites nodePlugins(...) for all tests that will be added to this module.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add base test classes in a followup change, so that we will not have to add AggregationsPlugin to each test class to will exist in this module.

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return List.of(AggregationsPlugin.class);
}

private ValuesSourceAggregationBuilder<? extends ValuesSourceAggregationBuilder<?>> randomMetric(String name, String field) {
int rand = randomIntBetween(0, 3);

Expand Down
3 changes: 2 additions & 1 deletion modules/aggregations/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
requires org.elasticsearch.xcontent;
requires org.apache.lucene.core;

exports org.elasticsearch.aggregations.bucket;
exports org.elasticsearch.aggregations.bucket.histogram;
exports org.elasticsearch.aggregations.bucket.adjacency;

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

package org.elasticsearch.aggregations;

import org.elasticsearch.aggregations.bucket.AdjacencyMatrixAggregationBuilder;
import org.elasticsearch.aggregations.bucket.InternalAdjacencyMatrix;
import org.elasticsearch.aggregations.bucket.adjacency.AdjacencyMatrixAggregationBuilder;
import org.elasticsearch.aggregations.bucket.adjacency.InternalAdjacencyMatrix;
import org.elasticsearch.aggregations.bucket.histogram.AutoDateHistogramAggregationBuilder;
import org.elasticsearch.aggregations.bucket.histogram.InternalAutoDateHistogram;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.SearchPlugin;

Expand All @@ -24,7 +26,13 @@ public List<AggregationSpec> getAggregations() {
AdjacencyMatrixAggregationBuilder.NAME,
AdjacencyMatrixAggregationBuilder::new,
AdjacencyMatrixAggregationBuilder::parse
).addResultReader(InternalAdjacencyMatrix::new)
).addResultReader(InternalAdjacencyMatrix::new),
new AggregationSpec(
AutoDateHistogramAggregationBuilder.NAME,
AutoDateHistogramAggregationBuilder::new,
AutoDateHistogramAggregationBuilder.PARSER
).addResultReader(InternalAutoDateHistogram::new)
.setAggregatorRegistrar(AutoDateHistogramAggregationBuilder::registerAggregators)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.aggregations.bucket;
package org.elasticsearch.aggregations.bucket.adjacency;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At one point we were actually trying to reduce the number of packages. I'm not 100% sure why - they don't make a big difference to me either way. I guess I'd prefer they all be in a aggregation.bucket package or something.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I'd prefer they all be in a aggregation.bucket package or something.

This is what I prefer too, but then I realise it can become a bit messy too. When we move aggregations like term agg that have many helper classes the list of classes the in the bucket package can become overwhelming. Some of these classes due to their name are sorted in a place not close to the actual builder, factory and aggregator classes. Maybe we should change the names of these classes or turn these classes into inner classes? I'm not sure, but then the PRs that move aggregators to the aggregation module also do renames. Maybe we can assess this later and if we decide we want less packages then make these changes in separate PRs?

Note that some packages already share multiple aggregators. Like the histogram or terms package.

At one point we were actually trying to reduce the number of packages.

That is true, but the way I remember this was, avoiding packages to have with just a small number of classes. For example a package with 3 classes or less, is something we should avoid. Most of these aggregator packages have more classes. Enough imo that having its own package is okay.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. Let's keep going then.


import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* Side Public License, v 1.
*/

package org.elasticsearch.aggregations.bucket;
package org.elasticsearch.aggregations.bucket.adjacency;

import org.apache.lucene.search.IndexSearcher;
import org.elasticsearch.Version;
import org.elasticsearch.aggregations.bucket.AdjacencyMatrixAggregator.KeyedFilter;
import org.elasticsearch.aggregations.bucket.adjacency.AdjacencyMatrixAggregator.KeyedFilter;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.util.Maps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.aggregations.bucket;
package org.elasticsearch.aggregations.bucket.adjacency;

import org.apache.lucene.search.Weight;
import org.apache.lucene.util.Bits;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
* Side Public License, v 1.
*/

package org.elasticsearch.aggregations.bucket;
package org.elasticsearch.aggregations.bucket.adjacency;

import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreMode;
import org.apache.lucene.search.Weight;
import org.elasticsearch.aggregations.bucket.AdjacencyMatrixAggregator.KeyedFilter;
import org.elasticsearch.aggregations.bucket.adjacency.AdjacencyMatrixAggregator.KeyedFilter;
import org.elasticsearch.search.aggregations.Aggregator;
import org.elasticsearch.search.aggregations.AggregatorFactories;
import org.elasticsearch.search.aggregations.AggregatorFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.aggregations.bucket;
package org.elasticsearch.aggregations.bucket.adjacency;

import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.aggregations.bucket;
package org.elasticsearch.aggregations.bucket.adjacency;

import org.elasticsearch.common.util.Maps;
import org.elasticsearch.search.aggregations.ParsedMultiBucketAggregation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.search.aggregations.bucket.histogram;
package org.elasticsearch.aggregations.bucket.histogram;

import org.elasticsearch.Version;
import org.elasticsearch.common.Rounding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.search.aggregations.bucket.histogram;
package org.elasticsearch.aggregations.bucket.histogram;

import org.apache.lucene.index.SortedNumericDocValues;
import org.apache.lucene.search.ScoreMode;
import org.apache.lucene.util.CollectionUtil;
import org.elasticsearch.aggregations.bucket.histogram.AutoDateHistogramAggregationBuilder.RoundingInfo;
import org.elasticsearch.common.Rounding;
import org.elasticsearch.common.util.ByteArray;
import org.elasticsearch.common.util.IntArray;
Expand All @@ -27,7 +28,6 @@
import org.elasticsearch.search.aggregations.bucket.BestBucketsDeferringCollector;
import org.elasticsearch.search.aggregations.bucket.DeferableBucketAggregator;
import org.elasticsearch.search.aggregations.bucket.DeferringBucketCollector;
import org.elasticsearch.search.aggregations.bucket.histogram.AutoDateHistogramAggregationBuilder.RoundingInfo;
import org.elasticsearch.search.aggregations.bucket.terms.LongKeyedBucketOrds;
import org.elasticsearch.search.aggregations.support.AggregationContext;
import org.elasticsearch.search.aggregations.support.ValuesSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
* Side Public License, v 1.
*/

package org.elasticsearch.search.aggregations.bucket.histogram;
package org.elasticsearch.aggregations.bucket.histogram;

import org.elasticsearch.aggregations.bucket.histogram.AutoDateHistogramAggregationBuilder.RoundingInfo;
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.search.aggregations.Aggregator;
import org.elasticsearch.search.aggregations.AggregatorFactories;
import org.elasticsearch.search.aggregations.AggregatorFactory;
import org.elasticsearch.search.aggregations.CardinalityUpperBound;
import org.elasticsearch.search.aggregations.bucket.histogram.AutoDateHistogramAggregationBuilder.RoundingInfo;
import org.elasticsearch.search.aggregations.support.AggregationContext;
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.search.aggregations.bucket.histogram;
package org.elasticsearch.aggregations.bucket.histogram;

import org.elasticsearch.core.Nullable;
import org.elasticsearch.search.aggregations.Aggregator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.search.aggregations.bucket.histogram;
package org.elasticsearch.aggregations.bucket.histogram;

import org.apache.lucene.util.PriorityQueue;
import org.elasticsearch.Version;
import org.elasticsearch.aggregations.bucket.histogram.AutoDateHistogramAggregationBuilder.RoundingInfo;
import org.elasticsearch.common.Rounding;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand All @@ -21,7 +22,9 @@
import org.elasticsearch.search.aggregations.KeyComparable;
import org.elasticsearch.search.aggregations.bucket.IteratorAndCurrent;
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation;
import org.elasticsearch.search.aggregations.bucket.histogram.AutoDateHistogramAggregationBuilder.RoundingInfo;
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.aggregations.bucket.histogram.HistogramFactory;
import org.elasticsearch.search.aggregations.support.SamplingContext;
import org.elasticsearch.xcontent.XContentBuilder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
* Side Public License, v 1.
*/

package org.elasticsearch.search.aggregations.bucket.histogram;
package org.elasticsearch.aggregations.bucket.histogram;

import org.elasticsearch.search.aggregations.ParsedMultiBucketAggregation;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.xcontent.ObjectParser;
import org.elasticsearch.xcontent.ParseField;
import org.elasticsearch.xcontent.XContentBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.aggregations.bucket;
package org.elasticsearch.aggregations.bucket.adjacency;

import org.apache.lucene.search.IndexSearcher;
import org.elasticsearch.aggregations.AggregationsPlugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.aggregations.bucket;
package org.elasticsearch.aggregations.bucket.adjacency;

import org.elasticsearch.aggregations.AggregationsPlugin;
import org.elasticsearch.common.util.Maps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.aggregations.bucket;
package org.elasticsearch.aggregations.bucket.adjacency;

import org.elasticsearch.aggregations.AggregationsPlugin;
import org.elasticsearch.common.util.CollectionUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.search.aggregations.bucket.histogram;
package org.elasticsearch.aggregations.bucket.histogram;

import org.elasticsearch.test.ESTestCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.search.aggregations.bucket.histogram;
package org.elasticsearch.aggregations.bucket.histogram;

import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
Expand All @@ -25,6 +25,7 @@
import org.apache.lucene.tests.index.RandomIndexWriter;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.Version;
import org.elasticsearch.aggregations.AggregationsPlugin;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.CheckedBiConsumer;
import org.elasticsearch.common.network.InetAddresses;
Expand All @@ -37,10 +38,15 @@
import org.elasticsearch.index.mapper.KeywordFieldMapper;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.NumberFieldMapper;
import org.elasticsearch.plugins.SearchPlugin;
import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilder;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.MultiBucketConsumerService;
import org.elasticsearch.search.aggregations.bucket.DateHistogramAggregatorTestCase;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram;
import org.elasticsearch.search.aggregations.bucket.range.InternalBinaryRange;
import org.elasticsearch.search.aggregations.bucket.range.InternalRange;
import org.elasticsearch.search.aggregations.bucket.range.IpRangeAggregationBuilder;
Expand Down Expand Up @@ -99,6 +105,12 @@ public class AutoDateHistogramAggregatorTests extends DateHistogramAggregatorTes

private static final Query DEFAULT_QUERY = new MatchAllDocsQuery();

// TODO: maybe add base class that overwrites getSearchPlugins(...) for all tests that will be added to this module.
@Override
protected List<SearchPlugin> getSearchPlugins() {
return List.of(new AggregationsPlugin());
}

public void testMatchNoDocs() throws IOException {
testSearchCase(
new MatchNoDocsQuery(),
Expand Down Expand Up @@ -907,10 +919,13 @@ public void testWithPipelineReductions() throws IOException {
InternalHistogram histo = (InternalHistogram) bucket.getAggregations().asList().get(0);
assertThat(histo.getBuckets().size(), equalTo(10));
for (int i = 0; i < 10; i++) {
assertThat(histo.getBuckets().get(i).key, equalTo((double) i));
assertThat(((Max) histo.getBuckets().get(i).aggregations.get("max")).value(), equalTo((double) i));
assertThat(histo.getBuckets().get(i).getKey(), equalTo((double) i));
assertThat(((Max) histo.getBuckets().get(i).getAggregations().get("max")).value(), equalTo((double) i));
if (i > 0) {
assertThat(((InternalSimpleValue) histo.getBuckets().get(i).aggregations.get("deriv")).getValue(), equalTo(1.0));
assertThat(
((InternalSimpleValue) histo.getBuckets().get(i).getAggregations().get("deriv")).getValue(),
equalTo(1.0)
);
}
}

Expand Down
Loading