cryptoe commented on a change in pull request #12139:
URL: https://github.com/apache/druid/pull/12139#discussion_r783645116
##########
File path:
server/src/main/java/org/apache/druid/server/ClientQuerySegmentWalker.java
##########
@@ -592,6 +642,48 @@ private DataSource insertSubqueryIds(
return InlineDataSource.fromIterable(resultList, signature);
}
+ private static long estimateResultRowSize(Object[] row, RowSignature
rowSignature)
+ {
+ int estimate = 0;
+ if (row == null) {
+ return 0;
+ }
+ estimate += 24; // Add memory overhead for the row array
+ for (int i = 0; i < rowSignature.size(); ++i) {
+ Optional<ColumnType> maybeColumnType = rowSignature.getColumnType(i);
+ if (!maybeColumnType.isPresent()) {
+ // This shouldn't be encountered
+ continue;
+ }
+ ColumnType columnType = maybeColumnType.get();
+ if (columnType.equals(ColumnType.LONG)) {
+ estimate += Long.BYTES;
+ } else if (columnType.equals(ColumnType.FLOAT)) {
+ estimate += Float.BYTES;
+ } else if (columnType.equals(ColumnType.DOUBLE)) {
+ estimate += Double.BYTES;
+ } else if (columnType.equals(ColumnType.STRING)
+ || columnType.equals(ColumnType.STRING_ARRAY)
+ || columnType.equals(ColumnType.LONG_ARRAY)
+ || columnType.equals(ColumnType.DOUBLE_ARRAY)) {
+ if (row[i] instanceof String) {
+ estimate += 28 + 16 + 2 * (((String) row[i]).length());
+ } else if (row[i] instanceof Long) {
+ estimate += Long.BYTES;
+ } else if (row[i] instanceof Double) {
+ estimate += Double.BYTES;
+ } else if (row[i] instanceof Float) {
+ estimate += Float.BYTES;
+ } else {
+ estimate += 0;
Review comment:
We might want to call out that we do a conservative/underestimate in
case of unknown col's somewhere in the property documentation.
--
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]