GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — add CachingClusteredClient benchmark, refactor some stuff by clintropolis · Pull Request #8089 · apache/druid Conversation
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
LGTM overall. Would you fix the Line 198 of BrokerServerView? It should be |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…-client-benchmark
…rStrategy and remove getWeight since felt artificial, default mergeResults in toolchest implementation for topn, search, select
| new TopNQueryRunnerFactory( | ||
| new StupidPool<>( | ||
| "TopNQueryRunnerFactory-bufferPool", | ||
| () -> ByteBuffer.allocate(10 * 1024 * 1024) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please extract this 10 * 1024 * 1024 together with the one above in the code if they have to be equal or as different constants if they don't have to be equal and comment about that.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| .aggregators(new LongSumAggregatorFactory("sumLongSequential", "sumLongSequential")) | ||
| .granularity(Granularity.fromString(queryGranularity)) | ||
| .metric("sumLongSequential") | ||
| .threshold(20480) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment explaining something about this number, e. g. why it has to be 20480.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I talked to @jihoonson (who wrote the benchmark originally) and we don't believe the number is actually significant, it was just an arbitrarily large number to make the result meaningful. I changed it to 10000 and have added a comment about it. I think it likely this will maybe be moved into a benchmark parameter in the future to compare merges for different thresholds, but I will save that until I actually have different merges to compare.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think I set it to 20480 in #6629, but don't remember where this number came from. I think threshold could be any number if it's not too small so that parallel merge can help with merging results.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| */ | ||
| public interface BinaryFn<Type1, Type2, OutType> | ||
| @FunctionalInterface | ||
| public interface CombiningFunction<T> |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please use the standard BinaryOperator or add a Javadoc comment justifying the existence of CombiningFunction.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ah, good point. All of our custom functions gave me tunnel vision and I forgot that Java exists 😅. I don't think the existence of CombiningFunction is really justified since it's just for vanity/cosmetic reasons to clarify what it's doing, which I don't think are necessary.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I have removed this interface with the latest commit to this PR.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -40,9 +40,11 @@ public BaseSequence( | |||
| public <OutType> OutType accumulate(OutType initValue, final Accumulator<OutType, T> fn) | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can now make initValue final.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * Creates an ordering comparator that is used to order results. This ordering function is used in the defaul | ||
| * {@link ResultMergeQueryRunner} provided by {@link QueryToolChest#mergeResults(QueryRunner)} | ||
| */ | ||
| public Ordering<ResultType> createOrderingFn(Query<ResultType> query) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please use Comparator or explain in the Javadoc comment why Ordering is used here instead of Comparator.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It's currently producing an Ordering because the CombiningSequence created by ResultMergeQueryRunner takes that instead of a Comparator. However, it looks like the Ordering in CombiningSequence can be swapped to use a regular Comparator, so I think this could likely be safely changed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I have swapped uses of Ordering with Comparator in CombiningSequence, ResultMergeQueryRunner, the QueryToolChest implementations, and the GroupByStrategy implementations.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| public int compare(Result<Object> r1, Result<Object> r2) | ||
| { | ||
| return r1.getTimestamp().compareTo(r2.getTimestamp()); | ||
| (r1, r2) -> r1.getTimestamp().compareTo(r2.getTimestamp()), |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please use Comparator.comparing(Result::getTimestamp)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| public class TopNMetricSpecOptimizationsTest | ||
| { | ||
| private static final List<AggregatorFactory> aggs = Lists.newArrayList( |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please call static final constant with all caps
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| && !segmentWatcherConfig.getWatchedDataSources().contains(input.rhs.getDataSource())) { | ||
| return false; | ||
| } | ||
| this.segmentFilter = metadataAndSegment -> { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Type of metadataAndSegment is not obvious, please use (Pair<DruidServerMetadata, DataSegment> metadataAndSegment) -> ...
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (arg2 == null) { | ||
| return arg1; | ||
| } | ||
| private final CombiningFunction<Integer> plus = (arg1, arg2) -> { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please make this function static. I would call it PLUS_NULLABLE to highlight why it's not just Integer::sum.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return arg2; | ||
| } | ||
| return arg1; | ||
| (arg1, arg2) -> { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Could you please extract GuavaUtils.firstNonNull and use a method reference here? The doc for that method should note that Objects.firstNonNull() cannot be used itself because it's one of those methods causing Guava incompatibility (see #6948). Please also add Guava's Objects.firstNonNull() this method to forbidden-apis.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This pattern is in a lot of places, but this is the only place specifically where it's done to just return one or the other, not as a mechanism to bail early before doing some sort of combine. Is it still worth moving to GuavaUtils or should it just be a private static method of this class?
Additionally, this method seems @Nullable which makes it have a different contract than Objects.firstNonNull, which requires one of the 2 arguments not be null. Prohibiting it on this functions behalf doesn't seem necessary, so are we doing it for a reason in #6948?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and did this ^ with the latest commits, extracting to GuavaUtils.firstNonNull and adding to forbidden api
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…of Ordering, other review adjustments
| * null. | ||
| */ | ||
| @Nullable | ||
| public static <T> T firstNonNull(T arg1, T arg2) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please annotate both parameters @Nullable
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| /** | ||
| * Creates an ordering comparator that is used to order results. This ordering function is used in the defaul | ||
| * Creates an ordering comparator that is used to order results. This comparator is used in the defaul |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Typo: "defaul"
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * {@link ResultMergeQueryRunner} provided by {@link QueryToolChest#mergeResults(QueryRunner)} | ||
| */ | ||
| public Ordering<ResultType> createOrderingFn(Query<ResultType> query) | ||
| public Comparator<ResultType> createComparator(Query<ResultType> query) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Optional: maybe call it createResultComparator.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| */ | ||
| @Nullable | ||
| default Ordering<Row> createOrderingFn(Query<Row> queryParam) | ||
| default Comparator<Row> createComparator(Query<Row> queryParam) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think createResultComparator would be a clearer name for this method
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…Null nullable parameters
|
Thanks for review @leventov and @jihoonson! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
* add CachingClusteredClient benchmark, refactor some stuff * revert WeightedServerSelectorStrategy to ConnectionCountServerSelectorStrategy and remove getWeight since felt artificial, default mergeResults in toolchest implementation for topn, search, select * adjust javadoc * adjustments * oops * use it * use BinaryOperator, remove CombiningFunction, use Comparator instead of Ordering, other review adjustments * rename createComparator to createResultComparator, fix typo, firstNonNull nullable parameters
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.