Skip to content

Commit 0a37e7f

Browse files
authored
Merge pull request #12 from clement-tourriere/7.4
Migrate to elasticsearch 7.4
2 parents 1a00d96 + edd6421 commit 0a37e7f

File tree

9 files changed

+66
-64
lines changed

9 files changed

+66
-64
lines changed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
es_version = 7.2.0
2-
plugin_version = 7.2.0.1
1+
es_version = 7.4.0
2+
plugin_version = 7.4.0.1
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#Wed Oct 02 17:45:26 CEST 2019
2+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
13
distributionBase=GRADLE_USER_HOME
24
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
4-
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6+
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ if $darwin; then
125125
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
126126
fi
127127

128-
# For Cygwin, switch paths to Windows format before running java
129-
if $cygwin ; then
128+
# For Cygwin or MSYS, switch paths to Windows format before running java
129+
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
130130
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131131
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132132
JAVACMD=`cygpath --unix "$JAVACMD"`

src/main/java/org/opendatasoft/elasticsearch/search/aggregations/bucket/DateHierarchyAggregationBuilder.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.opendatasoft.elasticsearch.search.aggregations.bucket;
22

3+
import org.elasticsearch.Version;
34
import org.elasticsearch.common.ParseField;
45
import org.elasticsearch.common.Rounding;
56
import org.elasticsearch.common.io.stream.StreamInput;
@@ -159,7 +160,7 @@ private DateHierarchyAggregationBuilder(String name, ValueType valueType) {
159160
}
160161

161162
@Override
162-
protected boolean serializeTargetValueType() {
163+
protected boolean serializeTargetValueType(Version version) {
163164
return true;
164165
}
165166

@@ -327,10 +328,10 @@ public int shardSize() {
327328
}
328329

329330
@Override
330-
protected ValuesSourceAggregatorFactory<ValuesSource.Numeric, ?> innerBuild(
331+
protected ValuesSourceAggregatorFactory<ValuesSource.Numeric> innerBuild(
331332
SearchContext context,
332333
ValuesSourceConfig<ValuesSource.Numeric> config,
333-
AggregatorFactory<?> parent,
334+
AggregatorFactory parent,
334335
Builder subFactoriesBuilder) throws IOException {
335336

336337
final List<RoundingInfo> roundingsInfo = buildRoundings();
@@ -358,12 +359,12 @@ protected XContentBuilder doXContentBody(XContentBuilder builder, Params params)
358359
* Used for caching requests, amongst other things.
359360
*/
360361
@Override
361-
protected int innerHashCode() {
362+
public int hashCode() {
362363
return Objects.hash(interval, order, minDocCount, bucketCountThresholds, timeZone);
363364
}
364365

365366
@Override
366-
protected boolean innerEquals(Object obj) {
367+
public boolean equals(Object obj) {
367368
DateHierarchyAggregationBuilder other = (DateHierarchyAggregationBuilder) obj;
368369
return Objects.equals(interval, other.interval)
369370
&& Objects.equals(order, other.order)

src/main/java/org/opendatasoft/elasticsearch/search/aggregations/bucket/DateHierarchyAggregatorFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* The factory of aggregators.
2424
* ValuesSourceAggregatorFactory extends {@link AggregatorFactory}
2525
*/
26-
class DateHierarchyAggregatorFactory extends ValuesSourceAggregatorFactory<ValuesSource.Numeric, DateHierarchyAggregatorFactory> {
26+
class DateHierarchyAggregatorFactory extends ValuesSourceAggregatorFactory<ValuesSource.Numeric> {
2727

2828
private long minDocCount;
2929
private BucketOrder order;
@@ -37,7 +37,7 @@ class DateHierarchyAggregatorFactory extends ValuesSourceAggregatorFactory<Value
3737
long minDocCount,
3838
DateHierarchyAggregator.BucketCountThresholds bucketCountThresholds,
3939
SearchContext context,
40-
AggregatorFactory<?> parent,
40+
AggregatorFactory parent,
4141
AggregatorFactories.Builder subFactoriesBuilder,
4242
Map<String, Object> metaData
4343
) throws IOException {

src/main/java/org/opendatasoft/elasticsearch/search/aggregations/bucket/InternalDateHierarchy.java

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public InternalBucket(StreamInput in) throws IOException {
6161
key = in.readBytesRef();
6262
name = in.readString();
6363
docCount = in.readLong();
64-
aggregations = InternalAggregations.readAggregations(in);
64+
aggregations = new InternalAggregations(in);
6565
level = in.readInt();
6666
int pathsSize = in.readInt();
6767
paths = new String[pathsSize];
@@ -111,24 +111,6 @@ public Aggregations getAggregations() {
111111
return aggregations;
112112
}
113113

114-
/**
115-
* Utility method of InternalDateHierarchy.doReduce()
116-
*/
117-
InternalBucket reduce(List<InternalBucket> buckets, ReduceContext context) {
118-
List<InternalAggregations> aggregationsList = new ArrayList<>(buckets.size());
119-
InternalBucket reduced = null;
120-
for (InternalBucket bucket : buckets) {
121-
if (reduced == null) {
122-
reduced = bucket;
123-
} else {
124-
reduced.docCount += bucket.docCount;
125-
}
126-
aggregationsList.add(bucket.aggregations);
127-
}
128-
reduced.aggregations = InternalAggregations.reduce(aggregationsList, context);
129-
return reduced;
130-
}
131-
132114
@Override
133115
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
134116
builder.startObject();
@@ -262,7 +244,7 @@ public InternalDateHierarchy doReduce(List<InternalAggregation> aggregations, Re
262244
PathSortedTree<String, InternalBucket> ordered = new PathSortedTree<>(order.comparator(null), size);
263245
for (List<InternalBucket> sameTermBuckets : buckets.values()) {
264246

265-
final InternalBucket b = sameTermBuckets.get(0).reduce(sameTermBuckets, reduceContext);
247+
final InternalBucket b = reduceBucket(sameTermBuckets, reduceContext);
266248
if (b.getDocCount() >= minDocCount || !reduceContext.isFinalReduce()) {
267249
reduceContext.consumeBucketsAndMaybeBreak(1);
268250
ordered.add(b.paths, b);
@@ -276,6 +258,22 @@ public InternalDateHierarchy doReduce(List<InternalAggregation> aggregations, Re
276258
sum_other_hierarchy_nodes, pipelineAggregators(), getMetaData());
277259
}
278260

261+
@Override
262+
protected InternalBucket reduceBucket(List<InternalBucket> buckets, ReduceContext context) {
263+
List<InternalAggregations> aggregationsList = new ArrayList<>(buckets.size());
264+
InternalBucket reduced = null;
265+
for (InternalBucket bucket : buckets) {
266+
if (reduced == null) {
267+
reduced = bucket;
268+
} else {
269+
reduced.docCount += bucket.docCount;
270+
}
271+
aggregationsList.add(bucket.aggregations);
272+
}
273+
reduced.aggregations = InternalAggregations.reduce(aggregationsList, context);
274+
return reduced;
275+
}
276+
279277
@Override
280278
public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
281279
Iterator<InternalBucket> bucketIterator = buckets.iterator();
@@ -323,12 +321,12 @@ public XContentBuilder doXContentBody(XContentBuilder builder, Params params) th
323321
}
324322

325323
@Override
326-
protected int doHashCode() {
324+
public int hashCode() {
327325
return Objects.hash(buckets, order, requiredSize, shardSize, otherHierarchyNodes, minDocCount);
328326
}
329327

330328
@Override
331-
protected boolean doEquals(Object obj) {
329+
public boolean equals(Object obj) {
332330
InternalDateHierarchy that = (InternalDateHierarchy) obj;
333331
return Objects.equals(buckets, that.buckets)
334332
&& Objects.equals(order, that.order)

src/main/java/org/opendatasoft/elasticsearch/search/aggregations/bucket/InternalPathHierarchy.java

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public InternalBucket(long docCount, InternalAggregations aggregations, String b
6767
public InternalBucket(StreamInput in) throws IOException {
6868
termBytes = in.readBytesRef();
6969
docCount = in.readLong();
70-
aggregations = InternalAggregations.readAggregations(in);
70+
aggregations = new InternalAggregations(in);
7171
level = in.readInt();
7272
minDepth = in.readInt();
7373
basename = in.readString();
@@ -120,24 +120,6 @@ public Aggregations getAggregations() {
120120
return aggregations;
121121
}
122122

123-
/**
124-
* Utility method of InternalPathHierarchy.doReduce()
125-
*/
126-
InternalBucket reduce(List<InternalBucket> buckets, ReduceContext context) {
127-
List<InternalAggregations> aggregationsList = new ArrayList<>(buckets.size());
128-
InternalBucket reduced = null;
129-
for (InternalBucket bucket : buckets) {
130-
if (reduced == null) {
131-
reduced = bucket;
132-
} else {
133-
reduced.docCount += bucket.docCount;
134-
}
135-
aggregationsList.add(bucket.aggregations);
136-
}
137-
reduced.aggregations = InternalAggregations.reduce(aggregationsList, context);
138-
return reduced;
139-
}
140-
141123
@Override
142124
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
143125
builder.startObject();
@@ -275,7 +257,7 @@ public InternalPathHierarchy doReduce(List<InternalAggregation> aggregations, Re
275257
final int size = !reduceContext.isFinalReduce() ? buckets.size() : Math.min(requiredSize, buckets.size());
276258
PathSortedTree<String, InternalBucket> ordered = new PathSortedTree<>(order.comparator(null), size);
277259
for (List<InternalBucket> sameTermBuckets : buckets.values()) {
278-
final InternalBucket b = sameTermBuckets.get(0).reduce(sameTermBuckets, reduceContext);
260+
final InternalBucket b = reduceBucket(sameTermBuckets, reduceContext);
279261
if (b.getDocCount() >= minDocCount || !reduceContext.isFinalReduce()) {
280262
reduceContext.consumeBucketsAndMaybeBreak(1);
281263
String [] pathsForTree;
@@ -295,6 +277,25 @@ public InternalPathHierarchy doReduce(List<InternalAggregation> aggregations, Re
295277
sum_other_hierarchy_nodes, separator, pipelineAggregators(), getMetaData());
296278
}
297279

280+
/**
281+
* Utility method of InternalPathHierarchy.doReduce()
282+
*/
283+
@Override
284+
protected InternalBucket reduceBucket(List<InternalBucket> buckets, ReduceContext context) {
285+
List<InternalAggregations> aggregationsList = new ArrayList<>(buckets.size());
286+
InternalBucket reduced = null;
287+
for (InternalBucket bucket : buckets) {
288+
if (reduced == null) {
289+
reduced = bucket;
290+
} else {
291+
reduced.docCount += bucket.docCount;
292+
}
293+
aggregationsList.add(bucket.aggregations);
294+
}
295+
reduced.aggregations = InternalAggregations.reduce(aggregationsList, context);
296+
return reduced;
297+
}
298+
298299
@Override
299300
public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
300301
// builder.field(SUM_OF_OTHER_HIERARCHY_NODES.getPreferredName(), otherHierarchyNodes);
@@ -344,12 +345,12 @@ public XContentBuilder doXContentBody(XContentBuilder builder, Params params) th
344345
}
345346

346347
@Override
347-
protected int doHashCode() {
348+
public int hashCode() {
348349
return Objects.hash(buckets, separator, order, requiredSize, shardSize, otherHierarchyNodes, minDocCount);
349350
}
350351

351352
@Override
352-
protected boolean doEquals(Object obj) {
353+
public boolean equals(Object obj) {
353354
InternalPathHierarchy that = (InternalPathHierarchy) obj;
354355
return Objects.equals(buckets, that.buckets)
355356
&& Objects.equals(separator, that.separator)

src/main/java/org/opendatasoft/elasticsearch/search/aggregations/bucket/PathHierarchyAggregationBuilder.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.opendatasoft.elasticsearch.search.aggregations.bucket;
22

3+
import org.elasticsearch.Version;
34
import org.elasticsearch.common.ParseField;
45
import org.elasticsearch.common.io.stream.StreamInput;
56
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -88,7 +89,7 @@ private PathHierarchyAggregationBuilder(String name, ValueType valueType) {
8889
}
8990

9091
@Override
91-
protected boolean serializeTargetValueType() {
92+
protected boolean serializeTargetValueType(Version version) {
9293
return true;
9394
}
9495

@@ -244,10 +245,10 @@ public int shardSize() {
244245
}
245246

246247
@Override
247-
protected ValuesSourceAggregatorFactory<ValuesSource, ?> innerBuild(
248+
protected ValuesSourceAggregatorFactory<ValuesSource> innerBuild(
248249
SearchContext context,
249250
ValuesSourceConfig<ValuesSource> config,
250-
AggregatorFactory<?> parent,
251+
AggregatorFactory parent,
251252
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
252253

253254
if (minDepth > maxDepth)
@@ -301,12 +302,12 @@ protected XContentBuilder doXContentBody(XContentBuilder builder, Params params)
301302
* Used for caching requests, amongst other things.
302303
*/
303304
@Override
304-
protected int innerHashCode() {
305+
public int hashCode() {
305306
return Objects.hash(separator, minDepth, maxDepth, depth, order, minDocCount, bucketCountThresholds);
306307
}
307308

308309
@Override
309-
protected boolean innerEquals(Object obj) {
310+
public boolean equals(Object obj) {
310311
PathHierarchyAggregationBuilder other = (PathHierarchyAggregationBuilder) obj;
311312
return Objects.equals(separator, other.separator)
312313
&& Objects.equals(minDepth, other.minDepth)

src/main/java/org/opendatasoft/elasticsearch/search/aggregations/bucket/PathHierarchyAggregatorFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* The factory of aggregators.
3131
* ValuesSourceAggregatorFactory extends {@link AggregatorFactory}
3232
*/
33-
class PathHierarchyAggregatorFactory extends ValuesSourceAggregatorFactory<ValuesSource, PathHierarchyAggregatorFactory> {
33+
class PathHierarchyAggregatorFactory extends ValuesSourceAggregatorFactory<ValuesSource> {
3434

3535
private BytesRef separator;
3636
private int minDepth;
@@ -50,7 +50,7 @@ class PathHierarchyAggregatorFactory extends ValuesSourceAggregatorFactory<Value
5050
long minDocCount,
5151
PathHierarchyAggregator.BucketCountThresholds bucketCountThresholds,
5252
SearchContext context,
53-
AggregatorFactory<?> parent,
53+
AggregatorFactory parent,
5454
AggregatorFactories.Builder subFactoriesBuilder,
5555
Map<String, Object> metaData
5656
) throws IOException {

0 commit comments

Comments
 (0)