mirror of https://github.com/apache/druid.git
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:
parent
9dca5ec76b
commit
d8effff30b
|
@ -90,12 +90,15 @@ public class PartitionHolder<T> implements Iterable<PartitionChunk<T>>
|
||||||
Iterator<PartitionChunk<T>> iter = holderSet.iterator();
|
Iterator<PartitionChunk<T>> iter = holderSet.iterator();
|
||||||
|
|
||||||
PartitionChunk<T> curr = iter.next();
|
PartitionChunk<T> curr = iter.next();
|
||||||
boolean endSeen = curr.isEnd();
|
|
||||||
|
|
||||||
if (!curr.isStart()) {
|
if (!curr.isStart()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (curr.isEnd()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
PartitionChunk<T> next = iter.next();
|
PartitionChunk<T> next = iter.next();
|
||||||
if (!curr.abuts(next)) {
|
if (!curr.abuts(next)) {
|
||||||
|
@ -103,12 +106,12 @@ public class PartitionHolder<T> implements Iterable<PartitionChunk<T>>
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next.isEnd()) {
|
if (next.isEnd()) {
|
||||||
endSeen = true;
|
return true;
|
||||||
}
|
}
|
||||||
curr = next;
|
curr = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return endSeen;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PartitionChunk<T> getChunk(final int partitionNum)
|
public PartitionChunk<T> getChunk(final int partitionNum)
|
||||||
|
|
Loading…
Reference in New Issue