/** * Implementation of {@link ReadQuery#executeLocally(ReadExecutionController)}. * * @param executionController - the {@code ReadExecutionController} protecting the read. * @param sort - whether to sort the inner commands by partition key, required for merging the iterator * later on. This will be false when called by {@link ReadQuery#executeInternal(ReadExecutionController)} * because in this case it is safe to do so as there is no merging involved and we don't want to * change the old behavior which was to not sort by partition. * * @return - the iterator that can be used to retrieve the query result. */ private UnfilteredPartitionIterator executeLocally(ReadExecutionController executionController, boolean sort) { List<Pair<DecoratedKey, UnfilteredPartitionIterator>> partitions = new ArrayList<>(commands.size()); for (SinglePartitionReadCommand cmd : commands) partitions.add(Pair.of(cmd.partitionKey, cmd.executeLocally(executionController))); if (sort) Collections.sort(partitions, (p1, p2) -> p1.getLeft().compareTo(p2.getLeft())); return UnfilteredPartitionIterators.concat(partitions.stream().map(p -> p.getRight()).collect(Collectors.toList())); }
/** * Implementation of {@link ReadQuery#executeLocally(ReadExecutionController)}. * * @param executionController - the {@code ReadExecutionController} protecting the read. * @param sort - whether to sort the inner commands by partition key, required for merging the iterator * later on. This will be false when called by {@link ReadQuery#executeInternal(ReadExecutionController)} * because in this case it is safe to do so as there is no merging involved and we don't want to * change the old behavior which was to not sort by partition. * * @return - the iterator that can be used to retrieve the query result. */ private UnfilteredPartitionIterator executeLocally(ReadExecutionController executionController, boolean sort) { List<Pair<DecoratedKey, UnfilteredPartitionIterator>> partitions = new ArrayList<>(commands.size()); for (SinglePartitionReadCommand cmd : commands) partitions.add(Pair.of(cmd.partitionKey, cmd.executeLocally(executionController))); if (sort) Collections.sort(partitions, (p1, p2) -> p1.getLeft().compareTo(p2.getLeft())); return UnfilteredPartitionIterators.concat(partitions.stream().map(p -> p.getRight()).collect(Collectors.toList())); }
/** * Implementation of {@link ReadQuery#executeLocally(ReadExecutionController)}. * * @param executionController - the {@code ReadExecutionController} protecting the read. * @param sort - whether to sort the inner commands by partition key, required for merging the iterator * later on. This will be false when called by {@link ReadQuery#executeInternal(ReadExecutionController)} * because in this case it is safe to do so as there is no merging involved and we don't want to * change the old behavior which was to not sort by partition. * * @return - the iterator that can be used to retrieve the query result. */ private UnfilteredPartitionIterator executeLocally(ReadExecutionController executionController, boolean sort) { List<Pair<DecoratedKey, UnfilteredPartitionIterator>> partitions = new ArrayList<>(commands.size()); for (SinglePartitionReadCommand cmd : commands) partitions.add(Pair.of(cmd.partitionKey, cmd.executeLocally(executionController))); if (sort) Collections.sort(partitions, (p1, p2) -> p1.getLeft().compareTo(p2.getLeft())); return UnfilteredPartitionIterators.concat(partitions.stream().map(p -> p.getRight()).collect(Collectors.toList())); }