cecemei commented on code in PR #18892:
URL: https://github.com/apache/druid/pull/18892#discussion_r2684552635
##########
processing/src/main/java/org/apache/druid/query/metadata/SegmentMetadataQueryRunnerFactory.java:
##########
@@ -67,6 +68,59 @@ public SegmentMetadataQueryRunnerFactory(
this.queryWatcher = queryWatcher;
}
+ public QueryRunner<SegmentAnalysis> createRunner(SegmentReference segmentRef)
+ {
+ if (segmentRef.getDataSegment() == null) {
+ throw DruidException.defensive("Missing Segment[%s]",
segmentRef.getSegmentDescriptor());
+ } else if (segmentRef.getSegmentReference().isEmpty()) {
+ throw DruidException.defensive("Missing Segment[%s]",
segmentRef.getDataSegment().getId());
+ }
+
+ Segment segment = segmentRef.getSegmentReference().get();
+ if (!Objects.equals(segmentRef.getDataSegment().getId(), segment.getId()))
{
+ throw DruidException.defensive(
+ "SegmentId mismatch in DataSegment[%s] and Segment[%s]",
+ segmentRef.getDataSegment().getId(),
+ segment.getId()
+ );
+ }
+
+ return new QueryRunner<>()
+ {
+ @Override
+ public Sequence<SegmentAnalysis> run(QueryPlus<SegmentAnalysis> inQ,
ResponseContext responseContext)
+ {
+ SegmentMetadataQuery updatedQuery = ((SegmentMetadataQuery)
inQ.getQuery()).withFinalizedAnalysisTypes(toolChest.getConfig());
+ final SegmentAnalyzer analyzer = new
SegmentAnalyzer(updatedQuery.getAnalysisTypes());
+
+ Integer numRows = segmentRef.getDataSegment().getTotalRows();
+ if (numRows == null) {
+ numRows = analyzer.numRows(segment);
+ }
+ long totalSize = analyzer.analyzingSize() ?
segmentRef.getDataSegment().getSize() : 0L;
Review Comment:
makes sense! it'd probably be more useful when we add all the columns size
breakdown stuff in the analysis and deprecate the SIZE analysis type, reverted
this change.
--
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]