Committed by
Gerrit Code Review
Reduce the nubmer of access to consistent map for performance
Change-Id: Ia57edfca4e0b5f264e181ed5bbaef74ebb46724a
Showing
1 changed file
with
11 additions
and
3 deletions
| ... | @@ -441,9 +441,17 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour | ... | @@ -441,9 +441,17 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour |
| 441 | .filter(x -> x.id().equals(parent.child(cls))) | 441 | .filter(x -> x.id().equals(parent.child(cls))) |
| 442 | .filter(x -> x instanceof ContinuousResource) | 442 | .filter(x -> x instanceof ContinuousResource) |
| 443 | .map(x -> (ContinuousResource) x) | 443 | .map(x -> (ContinuousResource) x) |
| 444 | - .filter(x -> continuousConsumers.containsKey(x.id())) | 444 | + // we don't use cascading simple predicates like follows to reduce accesses to consistent map |
| 445 | - .filter(x -> continuousConsumers.get(x.id()) != null) | 445 | + // .filter(x -> continuousConsumers.containsKey(x.id())) |
| 446 | - .filter(x -> !continuousConsumers.get(x.id()).value().allocations().isEmpty()); | 446 | + // .filter(x -> continuousConsumers.get(x.id()) != null) |
| 447 | + // .filter(x -> !continuousConsumers.get(x.id()).value().allocations().isEmpty()); | ||
| 448 | + .filter(resource -> { | ||
| 449 | + Versioned<ContinuousResourceAllocation> allocation = continuousConsumers.get(resource.id()); | ||
| 450 | + if (allocation == null) { | ||
| 451 | + return false; | ||
| 452 | + } | ||
| 453 | + return !allocation.value().allocations().isEmpty(); | ||
| 454 | + }); | ||
| 447 | 455 | ||
| 448 | return Stream.concat(discrete, continuous).collect(Collectors.toList()); | 456 | return Stream.concat(discrete, continuous).collect(Collectors.toList()); |
| 449 | } | 457 | } | ... | ... |
-
Please register or login to post a comment