Kikyou1997 commented on code in PR #10170: URL: https://github.com/apache/doris/pull/10170#discussion_r982254090
########## fe/fe-core/src/main/java/org/apache/doris/analysis/TupleDescriptor.java: ########## @@ -159,6 +164,80 @@ public void setTable(TableIf tbl) { table = tbl; } + public Set<Long> getSampleTabletIds() { + return sampleTabletIds; + } + + /** + * First, determine how many rows to sample from each partition according to the number of partitions. + * Then determine the number of Tablets to be selected for each partition according to the average number + * of rows of Tablet, + * If seek is not specified, the specified number of Tablets are pseudo-randomly selected from each partition. + * If seek is specified, it will be selected sequentially from the seek tablet of the partition. + * And add the manually specified Tablet id to the selected Tablet. + * simpleTabletNums = simpleRows / partitionNums / (partitionRows / partitionTabletNums) + */ + public void computeSampleTabletIds(List<Long> tabletIds, TableSample tableSample) { + if (table.getType() != TableType.OLAP) { + return; + } + sampleTabletIds.addAll(tabletIds); + if (tableSample == null) { + return; + } + OlapTable olapTable = (OlapTable) table; + long sampleRows; // The total number of sample rows + long hitRows = 1; // The total number of rows hit by the tablet + long totalRows = 0; // The total number of partition rows hit + long totalTablet = 0; // The total number of tablets in the hit partition + if (tableSample.isPercent()) { + sampleRows = (long) Math.max(olapTable.getRowCount() * (tableSample.getSampleValues() / 100.0), 1); + } else { + sampleRows = Math.max(tableSample.getSampleValues(), 1); Review Comment: Since sample rows has been promised to be a positive integer, I think this `max` call is redandunt -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org