[
https://issues.apache.org/jira/browse/DRILL-7450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16984387#comment-16984387
]
ASF GitHub Bot commented on DRILL-7450:
---------------------------------------
arina-ielchiieva commented on pull request #1907: DRILL-7450: Improve
performance for ANALYZE command
URL: https://github.com/apache/drill/pull/1907#discussion_r350232283
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/ConvertMetadataAggregateToDirectScanRule.java
##########
@@ -232,40 +223,51 @@ private DirectGroupScan
populateRecords(Collection<SchemaPath> interestingColumn
statsValue = columnStatistics.get(statisticsKind);
}
String columnStatisticsFieldName =
AnalyzeColumnUtils.getColumnStatisticsFieldName(schemaPath.getRootSegmentPath(),
statisticsKind);
- fieldIndexes.putIfAbsent(columnStatisticsFieldName, index++);
- record.add(fieldIndexes.get(columnStatisticsFieldName), statsValue);
if (statsValue != null) {
schema.putIfAbsent(
columnStatisticsFieldName,
statsValue.getClass());
+ recordsTable.put(columnStatisticsFieldName, rowIndex, statsValue);
}
}
}
// populates record list with row group metadata
for (StatisticsKind<?> statisticsKind :
AnalyzeColumnUtils.META_STATISTICS_FUNCTIONS.keySet()) {
String metadataStatisticsFieldName =
AnalyzeColumnUtils.getMetadataStatisticsFieldName(statisticsKind);
- fieldIndexes.putIfAbsent(metadataStatisticsFieldName, index++);
- record.add(fieldIndexes.get(metadataStatisticsFieldName),
rowGroupMetadata.getStatistic(statisticsKind));
+ Object statisticsValue = rowGroupMetadata.getStatistic(statisticsKind);
+
+ if (statisticsValue != null) {
+ schema.putIfAbsent(metadataStatisticsFieldName,
statisticsValue.getClass());
+ recordsTable.put(metadataStatisticsFieldName, rowIndex,
statisticsValue);
+ }
}
// populates record list internal columns
- record.add(fieldIndexes.get(MetastoreAnalyzeConstants.SCHEMA_FIELD),
rowGroupMetadata.getSchema().jsonString());
- record.add(fieldIndexes.get(rgs),
Long.toString(rowGroupMetadata.getStatistic(() ->
ExactStatisticsConstants.START)));
- record.add(fieldIndexes.get(rgl),
Long.toString(rowGroupMetadata.getStatistic(() ->
ExactStatisticsConstants.LENGTH)));
- record.add(fieldIndexes.get(lmt),
String.valueOf(fileSystem.getFileStatus(path).getModificationTime()));
+ recordsTable.put(MetastoreAnalyzeConstants.SCHEMA_FIELD, rowIndex,
rowGroupMetadata.getSchema().jsonString());
+ recordsTable.put(rgs, rowIndex,
Long.toString(rowGroupMetadata.getStatistic(() ->
ExactStatisticsConstants.START)));
+ recordsTable.put(rgl, rowIndex,
Long.toString(rowGroupMetadata.getStatistic(() ->
ExactStatisticsConstants.LENGTH)));
+ recordsTable.put(lmt, rowIndex,
String.valueOf(fileSystem.getFileStatus(path).getModificationTime()));
- records.add(record);
+ rowIndex++;
}
- LinkedHashMap<String, Class<?>> orderedSchema = new LinkedHashMap<>();
-
// DynamicPojoRecordReader requires LinkedHashMap with fields order
// which corresponds to the value position in record list.
- // Sorts fieldIndexes by index and puts field names in required order to
orderedSchema
- fieldIndexes.entrySet().stream()
- .sorted(Comparator.comparingInt(Map.Entry::getValue))
- .forEach(entry -> orderedSchema.put(entry.getKey(),
schema.get(entry.getKey())));
+ LinkedHashMap<String, Class<?>> orderedSchema =
recordsTable.rowKeySet().stream()
+ .collect(Collectors.toMap(
+ Function.identity(),
+ column -> schema.getOrDefault(column, Integer.class),
+ (a, b) -> b,
Review comment:
Better use: (o, n) -> n
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
> Improve performance for ANALYZE command
> ---------------------------------------
>
> Key: DRILL-7450
> URL: https://issues.apache.org/jira/browse/DRILL-7450
> Project: Apache Drill
> Issue Type: Bug
> Affects Versions: 1.17.0
> Reporter: Vova Vysotskyi
> Assignee: Vova Vysotskyi
> Priority: Critical
> Fix For: 1.17.0
>
>
> In the scope of DRILL-7273 was introduced ANALYZE command for collecting
> metadata and storing it to the metastore.
> But current implementation uses too much memory and is low-performant. It
> uses stream aggregate for collecting metadata, but all incoming data should
> be sorted before producing the aggregation. Memory usage may be reduced by
> using hash aggregate, so sort may not be produced and it should increase
> performance.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)