Skip to content

Commit

Permalink
Reduces differences between Elasticsearch 2.x and 5 (#1383)
Browse files Browse the repository at this point in the history
Elasticsearch 2.x supports an alias of zero for max int whereas ES 5
does not. Also, we are needlessly converting in and out of strings.
  • Loading branch information
adriancole authored Nov 3, 2016
1 parent ce7d386 commit 4aa179d
Showing 1 changed file with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,7 @@ public int compare(List<Span> left, List<Span> right) {

return transform(traceIds, new AsyncFunction<List<String>, List<List<Span>>>() {
@Override public ListenableFuture<List<List<Span>>> apply(List<String> input) {
List<Long> traceIds = new ArrayList<>(input.size());
for (String bucket : input) {
traceIds.add(Util.lowerHexToUnsignedLong(bucket));
}
return getTracesByIds(traceIds, indices);
return getTracesByIds(input, indices);
}
}
);
Expand All @@ -170,12 +166,8 @@ public int compare(List<Span> left, List<Span> right) {
return client.findSpans(catchAll, termQuery("traceId", Util.toLowerHex(traceId)));
}

ListenableFuture<List<List<Span>>> getTracesByIds(Collection<Long> traceIds, String[] indices) {
List<String> traceIdsStr = new ArrayList<>(traceIds.size());
for (long traceId : traceIds) {
traceIdsStr.add(Util.toLowerHex(traceId));
}
return Futures.transform(client.findSpans(indices, termsQuery("traceId", traceIdsStr)),
ListenableFuture<List<List<Span>>> getTracesByIds(Collection<String> traceIds, String[] indices) {
return Futures.transform(client.findSpans(indices, termsQuery("traceId", traceIds)),
ConvertTracesResponse.INSTANCE);
}

Expand All @@ -202,12 +194,12 @@ enum ConvertTracesResponse implements Function<List<Span>, List<List<Span>>> {
.path("annotations")
.subAggregation(AggregationBuilders.terms("annotationsServiceName_agg")
.field("annotations.endpoint.serviceName")
.size(0)),
.size(Integer.MAX_VALUE)),
AggregationBuilders.nested("binaryAnnotations_agg")
.path("binaryAnnotations")
.subAggregation(AggregationBuilders.terms("binaryAnnotationsServiceName_agg")
.field("binaryAnnotations.endpoint.serviceName")
.size(0)));
.size(Integer.MAX_VALUE)));
}

@Override public ListenableFuture<List<String>> getSpanNames(String serviceName) {
Expand All @@ -227,7 +219,7 @@ enum ConvertTracesResponse implements Function<List<Span>, List<List<Span>>> {
AggregationBuilders.terms("name_agg")
.order(Order.term(true))
.field("name")
.size(0));
.size(Integer.MAX_VALUE));
}

@Override public ListenableFuture<List<DependencyLink>> getDependencies(long endMillis,
Expand Down

0 comments on commit 4aa179d

Please sign in to comment.