Skip to content
This repository has been archived by the owner on Mar 27, 2021. It is now read-only.

Commit

Permalink
eliminate dup code
Browse files Browse the repository at this point in the history
  • Loading branch information
adsail committed Dec 18, 2020
1 parent c4568c7 commit fcf7e6b
Showing 1 changed file with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,27 +236,21 @@ public AsyncFuture<WriteMetadata> write(
try (Scope ignored = tracer.withSpan(span)) {
span.putAttribute("index", AttributeValue.stringAttributeValue(index));

if (indexResourceIdentifiers) {
if (!writeCache.acquire(Pair.of(index, series.getHashCode()),
reporter::reportWriteDroppedByCacheHit)) {
span.setStatus(
Status
.ALREADY_EXISTS
.withDescription("Write dropped by cache hit"));
span.end();
continue;
}
} else {
if (!writeCache.acquire(Pair.of(index, series.getHashCodeTagOnly()),
reporter::reportWriteDroppedByCacheHit)) {
span.setStatus(
Status
.ALREADY_EXISTS
.withDescription("Write dropped by cache hit"));
span.end();
continue;
}
HashCode hc =
indexResourceIdentifiers ?
series.getHashCode() :
series.getHashCodeTagOnly();

if (!writeCache.acquire(Pair.of(index, hc),
reporter::reportWriteDroppedByCacheHit)) {
span.setStatus(
Status
.ALREADY_EXISTS
.withDescription("Write dropped by cache hit"));
span.end();
continue;
}

indexSpans.add(span);

final XContentBuilder source = XContentFactory.jsonBuilder();
Expand Down

0 comments on commit fcf7e6b

Please sign in to comment.