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
This commit is contained in:
Gian Merlino 2018-05-16 09:16:50 -07:00 committed by GitHub
parent 9dca5ec76b
commit d8effff30b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -90,12 +90,15 @@ public class PartitionHolder<T> implements Iterable<PartitionChunk<T>>
Iterator<PartitionChunk<T>> iter = holderSet.iterator();
PartitionChunk<T> curr = iter.next();
boolean endSeen = curr.isEnd();
if (!curr.isStart()) {
return false;
}
if (curr.isEnd()) {
return true;
}
while (iter.hasNext()) {
PartitionChunk<T> next = iter.next();
if (!curr.abuts(next)) {
@ -103,12 +106,12 @@ public class PartitionHolder<T> implements Iterable<PartitionChunk<T>>
}
if (next.isEnd()) {
endSeen = true;
return true;
}
curr = next;
}
return endSeen;
return false;
}
public PartitionChunk<T> getChunk(final int partitionNum)