jerryshao commented on code in PR #8450:
URL: https://github.com/apache/gravitino/pull/8450#discussion_r2342929756
##########
core/src/main/java/org/apache/gravitino/stats/storage/LancePartitionStatisticStorage.java:
##########
@@ -197,95 +262,39 @@ public void updateStatistics(
}
}
- private void appendStatisticsImpl(Long tableId,
List<PartitionStatisticsUpdate> updates) {
- String fileName = getFilePath(tableId);
- try (Dataset datasetRead = open(fileName)) {
- List<FragmentMetadata> fragmentMetas;
- int count = 0;
- try (VectorSchemaRoot root = VectorSchemaRoot.create(SCHEMA, allocator))
{
- for (PartitionStatisticsUpdate update : updates) {
- count += update.statistics().size();
+ private void appendStatisticsImpl(Long tableId,
List<PartitionStatisticsUpdate> updates)
+ throws JsonProcessingException {
+ Dataset datasetRead = null;
+ Dataset newDataset = null;
+ try {
+ datasetRead = getDataset(tableId);
+ List<FragmentMetadata> fragmentMetas = createFragmentMetadata(tableId,
updates);
+
+ Transaction appendTxn =
+ datasetRead
+ .newTransactionBuilder()
+ .operation(Append.builder().fragments(fragmentMetas).build())
+ .transactionProperties(Collections.emptyMap())
+ .build();
+ newDataset = appendTxn.commit();
+
+ Dataset finalNewDataset = newDataset;
+ datasetCache.ifPresent(cache -> cache.put(tableId, finalNewDataset));
+ } finally {
+ if (!datasetCache.isPresent()) {
Review Comment:
Can you please change to `isEmpty`? That looks more straightforward.
--
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]