github-code-scanning[bot] commented on code in PR #15024:
URL: https://github.com/apache/druid/pull/15024#discussion_r1340119020


##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/querykit/groupby/GroupByPreShuffleFrameProcessor.java:
##########
@@ -97,6 +104,37 @@
     );
   }
 
+  private GroupByQuery prepareGroupByQuery(GroupByQuery query)
+  {
+    ImmutableMap<String, Object> overridingContext = ImmutableMap.<String, 
Object>builder()
+                                                                 
.put(GroupByQueryConfig.CTX_KEY_APPLY_LIMIT_PUSH_DOWN, 
query.isApplyLimitPushDown())
+                                                                 
.put(GroupByQueryConfig.CTX_KEY_ARRAY_RESULT_ROWS, true)
+                                                                 .build();
+    return query.withOverriddenContext(overridingContext);
+  }
+
+  @Override
+  protected ReturnOrAwait<Long> runWithLoadedSegment(SegmentWithDescriptor 
segment) throws IOException
+  {
+    if (resultYielder == null) {
+      Pair<LoadedSegmentDataProvider.DataServerQueryStatus, 
Yielder<ResultRow>> statusSequencePair =
+          segment.fetchRowsFromDataServer(prepareGroupByQuery(query), 
Function.identity(), ResultRow.class, closer);
+      if 
(LoadedSegmentDataProvider.DataServerQueryStatus.HANDOFF.equals(statusSequencePair.lhs))
 {
+        log.info("Segment[%s] was handed off, falling back to fetching the 
segment from deep storage.", segment);

Review Comment:
   ## Use of default toString()
   
   Default toString(): SegmentWithDescriptor inherits toString() from Object, 
and so is not suitable for printing.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/5828)



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/querykit/scan/ScanQueryFrameProcessor.java:
##########
@@ -154,6 +166,62 @@
     closer.close();
   }
 
+  public static Sequence<Object[]> mappingFunction(Sequence<ScanResultValue> 
inputSequence)
+  {
+    return inputSequence.flatMap(resultRow -> {
+      List<List<Object>> events = (List<List<Object>>) resultRow.getEvents();
+      return Sequences.simple(events);
+    }).map(List::toArray);
+  }
+
+  @Override
+  protected ReturnOrAwait<Long> runWithLoadedSegment(final 
SegmentWithDescriptor segment) throws IOException
+  {
+    if (cursor == null) {
+      final Pair<LoadedSegmentDataProvider.DataServerQueryStatus, 
Yielder<Object[]>> statusSequencePair =
+          segment.fetchRowsFromDataServer(
+              query,
+              ScanQueryFrameProcessor::mappingFunction,
+              ScanResultValue.class,
+              closer
+          );
+      if 
(LoadedSegmentDataProvider.DataServerQueryStatus.HANDOFF.equals(statusSequencePair.lhs))
 {
+        log.info("Segment[%s] was handed off, falling back to fetching the 
segment from deep storage.", segment);

Review Comment:
   ## Use of default toString()
   
   Default toString(): SegmentWithDescriptor inherits toString() from Object, 
and so is not suitable for printing.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/5829)



-- 
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]

Reply via email to