From d8effff30b0a7a04c12ccccedf6b279258c65d3f Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Wed, 16 May 2018 09:16:50 -0700 Subject: [PATCH] PartitionHolder: Early return from isComplete when we find an end. (#5778) * PartitionHolder: Early return from isComplete when we find an end. Holders are complete if they have a start, sequence of abutting objects, and then an end. There isn't any reason to check whether or not the objects _after_ the end are abutting (the extensible set). This is really a performance patch, since behavior shouldn't be changing. The extensible shardSpecs (where we could have shards after the end) are always abutting each other anyway. Performance doesn't usually matter much in this function, but it can when there are thousands of segments per time chunk. * Remove endSeen --- .../io/druid/timeline/partition/PartitionHolder.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/io/druid/timeline/partition/PartitionHolder.java b/common/src/main/java/io/druid/timeline/partition/PartitionHolder.java index ace26479cb0..4d518d3e9fc 100644 --- a/common/src/main/java/io/druid/timeline/partition/PartitionHolder.java +++ b/common/src/main/java/io/druid/timeline/partition/PartitionHolder.java @@ -90,12 +90,15 @@ public class PartitionHolder implements Iterable> Iterator> iter = holderSet.iterator(); PartitionChunk curr = iter.next(); - boolean endSeen = curr.isEnd(); if (!curr.isStart()) { return false; } + if (curr.isEnd()) { + return true; + } + while (iter.hasNext()) { PartitionChunk next = iter.next(); if (!curr.abuts(next)) { @@ -103,12 +106,12 @@ public class PartitionHolder implements Iterable> } if (next.isEnd()) { - endSeen = true; + return true; } curr = next; } - return endSeen; + return false; } public PartitionChunk getChunk(final int partitionNum)