Skip to content

Commit a039c1b

Browse files
author
Hendrik Muhs
committed
apply spotless
1 parent 89254be commit a039c1b

File tree

5 files changed

+43
-52
lines changed

5 files changed

+43
-52
lines changed

x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/TransformIndexer.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -891,11 +891,7 @@ private IterationResult<TransformIndexerPosition> processBuckets(final SearchRes
891891
runState = RunState.IDENTIFY_CHANGES;
892892

893893
// advance the cursor for changed bucket detection
894-
return new IterationResult<>(
895-
Stream.empty(),
896-
new TransformIndexerPosition(null, nextChangeCollectorBucketPosition),
897-
false
898-
);
894+
return new IterationResult<>(Stream.empty(), new TransformIndexerPosition(null, nextChangeCollectorBucketPosition), false);
899895
}
900896

901897
Stream<IndexRequest> indexRequestStream = indexRequestStreamAndCursor.v1();

x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/common/AbstractCompositeAggFunction.java

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,16 @@ public void preview(
8080
final Aggregations aggregations = r.getAggregations();
8181
if (aggregations == null) {
8282
listener.onFailure(
83-
new ElasticsearchStatusException("Source indices have been deleted or closed.", RestStatus.BAD_REQUEST));
83+
new ElasticsearchStatusException("Source indices have been deleted or closed.", RestStatus.BAD_REQUEST)
84+
);
8485
return;
8586
}
8687
final CompositeAggregation agg = aggregations.get(COMPOSITE_AGGREGATION_NAME);
8788
TransformIndexerStats stats = new TransformIndexerStats();
8889

89-
List<Map<String, Object>> docs = extractResults(agg, fieldTypeMap, stats, null)
90-
.map(this::documentTransformationFunction)
91-
.collect(Collectors.toList());
90+
List<Map<String, Object>> docs = extractResults(agg, fieldTypeMap, stats, null).map(
91+
this::documentTransformationFunction
92+
).collect(Collectors.toList());
9293

9394
listener.onResponse(docs);
9495
} catch (AggregationResultUtils.AggregationExtractionException extractionException) {
@@ -108,11 +109,10 @@ public void validateQuery(Client client, SourceConfig sourceConfig, ActionListen
108109
}
109110
if (response.status() != RestStatus.OK) {
110111
listener.onFailure(
111-
new ValidationException()
112-
.addValidationError(
113-
new ParameterizedMessage("Unexpected status from response of test query: {}", response.status())
114-
.getFormattedMessage()
115-
)
112+
new ValidationException().addValidationError(
113+
new ParameterizedMessage("Unexpected status from response of test query: {}", response.status())
114+
.getFormattedMessage()
115+
)
116116
);
117117
return;
118118
}
@@ -123,10 +123,9 @@ public void validateQuery(Client client, SourceConfig sourceConfig, ActionListen
123123
? ((ElasticsearchException) unwrapped).status()
124124
: RestStatus.SERVICE_UNAVAILABLE;
125125
listener.onFailure(
126-
new ValidationException(unwrapped)
127-
.addValidationError(
128-
new ParameterizedMessage("Failed to test query, received status: {}", status).getFormattedMessage()
129-
)
126+
new ValidationException(unwrapped).addValidationError(
127+
new ParameterizedMessage("Failed to test query, received status: {}", status).getFormattedMessage()
128+
)
130129
);
131130
}));
132131
}
@@ -153,16 +152,15 @@ public Tuple<Stream<IndexRequest>, Map<String, Object>> processSearchResponse(
153152
return null;
154153
}
155154

156-
Stream<IndexRequest> indexRequestStream = extractResults(compositeAgg, fieldTypeMap, stats, progress)
157-
.map(doc -> {
158-
String docId = (String)doc.remove(TransformField.DOCUMENT_ID_FIELD);
159-
return DocumentConversionUtils.convertDocumentToIndexRequest(
160-
docId,
161-
documentTransformationFunction(doc),
162-
destinationIndex,
163-
destinationPipeline
164-
);
165-
});
155+
Stream<IndexRequest> indexRequestStream = extractResults(compositeAgg, fieldTypeMap, stats, progress).map(doc -> {
156+
String docId = (String) doc.remove(TransformField.DOCUMENT_ID_FIELD);
157+
return DocumentConversionUtils.convertDocumentToIndexRequest(
158+
docId,
159+
documentTransformationFunction(doc),
160+
destinationIndex,
161+
destinationPipeline
162+
);
163+
});
166164

167165
return Tuple.tuple(indexRequestStream, compositeAgg.afterKey());
168166
}
@@ -177,13 +175,10 @@ protected abstract Stream<Map<String, Object>> extractResults(
177175
);
178176

179177
private SearchRequest buildSearchRequest(SourceConfig sourceConfig, Map<String, Object> position, int pageSize) {
180-
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder()
181-
.query(sourceConfig.getQueryConfig().getQuery())
178+
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder().query(sourceConfig.getQueryConfig().getQuery())
182179
.runtimeMappings(sourceConfig.getRuntimeMappings());
183180
buildSearchQuery(sourceBuilder, null, pageSize);
184-
return new SearchRequest(sourceConfig.getIndex())
185-
.source(sourceBuilder)
186-
.indicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN);
181+
return new SearchRequest(sourceConfig.getIndex()).source(sourceBuilder).indicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN);
187182
}
188183

189184
@Override

x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/latest/Latest.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,13 @@ public Latest(LatestConfig config) {
5353
}
5454

5555
private static CompositeAggregationBuilder createCompositeAggregation(LatestConfig config) {
56-
List<CompositeValuesSourceBuilder<?>> sources =
57-
config.getUniqueKey().stream()
58-
.map(field -> new TermsValuesSourceBuilder(field).field(field).missingBucket(true))
59-
.collect(toList());
60-
TopHitsAggregationBuilder topHitsAgg =
61-
AggregationBuilders.topHits(TOP_HITS_AGGREGATION_NAME)
62-
.size(1) // we are only interested in the top-1
63-
.sorts(config.getSorts()); // we copy the sort config directly from the function config
56+
List<CompositeValuesSourceBuilder<?>> sources = config.getUniqueKey()
57+
.stream()
58+
.map(field -> new TermsValuesSourceBuilder(field).field(field).missingBucket(true))
59+
.collect(toList());
60+
TopHitsAggregationBuilder topHitsAgg = AggregationBuilders.topHits(TOP_HITS_AGGREGATION_NAME)
61+
.size(1) // we are only interested in the top-1
62+
.sorts(config.getSorts()); // we copy the sort config directly from the function config
6463
return AggregationBuilders.composite(COMPOSITE_AGGREGATION_NAME, sources).subAggregation(topHitsAgg);
6564
}
6665

@@ -74,10 +73,12 @@ public ChangeCollector buildChangeCollector(String synchronizationField) {
7473
return new LatestChangeCollector(synchronizationField);
7574
}
7675

77-
private static Map<String, Object> convertBucketToDocument(CompositeAggregation.Bucket bucket,
78-
LatestConfig config,
79-
TransformIndexerStats transformIndexerStats,
80-
TransformProgress progress) {
76+
private static Map<String, Object> convertBucketToDocument(
77+
CompositeAggregation.Bucket bucket,
78+
LatestConfig config,
79+
TransformIndexerStats transformIndexerStats,
80+
TransformProgress progress
81+
) {
8182
transformIndexerStats.incrementNumDocuments(bucket.getDocCount());
8283
if (progress != null) {
8384
progress.incrementDocsProcessed(bucket.getDocCount());
@@ -87,7 +88,9 @@ private static Map<String, Object> convertBucketToDocument(CompositeAggregation.
8788
TopHits topHits = bucket.getAggregations().get(TOP_HITS_AGGREGATION_NAME);
8889
if (topHits.getHits().getHits().length != 1) {
8990
throw new ElasticsearchException(
90-
"Unexpected number of hits in the top_hits aggregation result. Wanted: 1, was: {}", topHits.getHits().getHits().length);
91+
"Unexpected number of hits in the top_hits aggregation result. Wanted: 1, was: {}",
92+
topHits.getHits().getHits().length
93+
);
9194
}
9295
Map<String, Object> document = topHits.getHits().getHits()[0].getSourceAsMap();
9396

x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/pivot/AggregationResultUtils.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,8 @@ static class GeoShapeMetricAggExtractor implements AggValueExtractor {
457457

458458
@Override
459459
public Object value(Aggregation aggregation, Map<String, String> fieldTypeMap, String lookupFieldPrefix) {
460-
assert aggregation instanceof GeoShapeMetricAggregation : "Unexpected type ["
461-
+ aggregation.getClass().getName()
462-
+ "] for aggregation ["
463-
+ aggregation.getName()
464-
+ "]";
460+
assert aggregation instanceof GeoShapeMetricAggregation
461+
: "Unexpected type [" + aggregation.getClass().getName() + "] for aggregation [" + aggregation.getName() + "]";
465462
return ((GeoShapeMetricAggregation) aggregation).geoJSONGeometry();
466463
}
467464
}

x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/transforms/pivot/AggregationResultUtilsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
package org.elasticsearch.xpack.transform.transforms.pivot;
99

10-
import org.elasticsearch.common.xcontent.ParseField;
1110
import org.elasticsearch.common.geo.GeoPoint;
1211
import org.elasticsearch.common.io.stream.StreamOutput;
1312
import org.elasticsearch.common.xcontent.ContextParser;
1413
import org.elasticsearch.common.xcontent.DeprecationHandler;
1514
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
15+
import org.elasticsearch.common.xcontent.ParseField;
1616
import org.elasticsearch.common.xcontent.XContentBuilder;
1717
import org.elasticsearch.common.xcontent.XContentFactory;
1818
import org.elasticsearch.common.xcontent.XContentParser;

0 commit comments

Comments
 (0)