imply-cheddar commented on code in PR #13085:
URL: https://github.com/apache/druid/pull/13085#discussion_r997604250
##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/querykit/InputNumberDataSource.java:
##########
@@ -81,6 +92,36 @@ public boolean isConcrete()
return false;
}
+ @Override
+ public Function<SegmentReference, SegmentReference> createSegmentMapFunction(
+ Query query,
+ AtomicLong cpuTime
+ )
+ {
+ if (broadcastJoinHelper == null) {
+ throw new IAE(
+ "No helper for broadcast join found on data source [%s]. "
+ + "Please make sure to set this before this call. ",
+ query.getDataSource()
+ );
+ }
+ final DataSource dataSourceWithInlinedChannelData =
broadcastJoinHelper.inlineChannelData(query.getDataSource());
+ final DataSourceAnalysis analysis =
DataSourceAnalysis.forDataSource(dataSourceWithInlinedChannelData);
+ return analysis.getDataSource().createSegmentMapFunction(query, new
AtomicLong());
Review Comment:
Pass through the cpuTime that was passed into this method please.
##########
processing/src/main/java/org/apache/druid/query/DataSource.java:
##########
@@ -83,8 +89,40 @@
* Returns true if this datasource represents concrete data that can be
scanned via a
* {@link org.apache.druid.segment.Segment} adapter of some kind. True for
e.g. 'table' but not for 'query' or 'join'.
*
- * @see org.apache.druid.query.planning.DataSourceAnalysis#isConcreteBased()
which uses this
- * @see
org.apache.druid.query.planning.DataSourceAnalysis#isConcreteTableBased() which
uses this
+ * @see DataSourceAnalysis#isConcreteBased() which uses this
+ * @see DataSourceAnalysis#isConcreteTableBased() which uses this
*/
boolean isConcrete();
+
+ /**
+ * Returns a segment function on to how to segment should be modified.
+ *
+ * @param query the input query
+ * @param cpuTimeAcc the cpu time accumulator
+ * @return the segment function
+ */
+ Function<SegmentReference, SegmentReference> createSegmentMapFunction(Query
query, AtomicLong cpuTimeAcc);
+
+ /**
+ * Returns an updated datasource based on the specified new source.
+ *
+ * @param newSource the new datasource to be used to update an existing query
+ * @return the updated datasource to be used
+ */
+ DataSource withUpdatedDataSource(DataSource newSource);
+
+ /**
+ * Compute a cache key prefix for a data source. This includes the data
sources that participate in the RHS of a
+ * join as well as any query specific constructs associated with join data
source such as base table filter. This key prefix
+ * can be used in segment level cache or result level cache. The function
can return following
+ * - Non-empty byte array - If there is join datasource involved and caching
is possible. The result includes
+ * join condition expression, join type and cache key returned by joinable
factory for each {@link PreJoinableClause}
+ * - NULL - There is a join but caching is not possible. It may happen if
one of the participating datasource
+ * in the JOIN is not cacheable.
+ *
+ * @return the cache key to be used as part of query cache key
+ * @throws {@link IAE} if this operation is called on a non-join data source
+ */
+ byte[] getCacheKey();
Review Comment:
Yeah, that javadoc on the `throws` is old. It should never actually throw.
At this point, this is only for joins, the semantics that we introduced,
though, give the different datasources the ability to completely opt-out of
caching if a meaningful cache key cannot be created. The refactor is actually
making this explicit and the various implementations are now opting in/out of
caching on their own (by either returning `null` or `new byte[]{}`)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]