zhoujinsong commented on code in PR #3314:
URL: https://github.com/apache/amoro/pull/3314#discussion_r1837961933


##########
amoro-ams/src/main/java/org/apache/amoro/server/utils/IcebergTableUtil.java:
##########
@@ -202,4 +216,94 @@ public static Set<String> getAllManifestFiles(Table table) 
{
 
     return allManifestFiles;
   }
+
+  public static AbstractOptimizingEvaluator createOptimizingEvaluator(
+      TableRuntime tableRuntime,
+      MixedTable table,
+      TableSnapshot snapshot,
+      int maxPendingPartitions) {
+    ServerTableIdentifier identifier = tableRuntime.getTableIdentifier();
+    OptimizingConfig config = tableRuntime.getOptimizingConfig();
+    long lastMinor = tableRuntime.getLastMinorOptimizingTime();
+    long lastFull = tableRuntime.getLastFullOptimizingTime();
+    if (TableFormat.ICEBERG.in(table.format())) {
+      return new IcebergOptimizerEvaluator(
+          identifier, config, table, snapshot, maxPendingPartitions, 
lastMinor, lastFull);
+    } else if (TableFormat.MIXED_ICEBERG.in(table.format())) {
+      return new MixedIcebergOptimizingEvaluator(
+          identifier, config, table, snapshot, maxPendingPartitions, 
lastMinor, lastFull);
+    } else if (TableFormat.MIXED_HIVE.in(table.format())) {
+      return new MixedHiveOptimizingEvaluator(
+          identifier, config, table, snapshot, maxPendingPartitions, 
lastMinor, lastFull);
+    }
+    throw new IllegalStateException("Un-supported table-format:" + 
table.format().toString());
+  }
+
+  public static AbstractOptimizingEvaluator createOptimizingEvaluator(
+      TableRuntime tableRuntime, MixedTable table, int maxPendingPartitions) {
+    TableSnapshot snapshot = IcebergTableUtil.getSnapshot(table, tableRuntime);
+    return createOptimizingEvaluator(tableRuntime, table, snapshot, 
maxPendingPartitions);
+  }
+
+  public static AbstractOptimizingPlanner createOptimizingPlanner(
+      TableRuntime tableRuntime,
+      MixedTable table,
+      double availableCore,
+      long maxInputSizePerThread) {
+    Expression partitionFilter =
+        tableRuntime.getPendingInput() == null
+            ? Expressions.alwaysTrue()
+            : 
tableRuntime.getPendingInput().getPartitions().entrySet().stream()
+                .map(
+                    entry ->
+                        ExpressionUtil.convertPartitionDataToDataFilter(
+                            table, entry.getKey(), entry.getValue()))
+                .reduce(Expressions::or)
+                .orElse(Expressions.alwaysTrue());
+    long planTime = System.currentTimeMillis();
+    long processId = Math.max(tableRuntime.getNewestProcessId() + 1, planTime);
+    ServerTableIdentifier identifier = tableRuntime.getTableIdentifier();
+    OptimizingConfig config = tableRuntime.getOptimizingConfig();
+    long lastMinor = tableRuntime.getLastMinorOptimizingTime();
+    long lastFull = tableRuntime.getLastFullOptimizingTime();
+    TableSnapshot snapshot = IcebergTableUtil.getSnapshot(table, tableRuntime);
+    if (TableFormat.ICEBERG.in(table.format())) {

Review Comment:
   ```suggestion
       if (TableFormat.ICEBERG.equals(table.format())) {
   ```



##########
amoro-ams/src/main/java/org/apache/amoro/server/utils/IcebergTableUtil.java:
##########
@@ -202,4 +216,94 @@ public static Set<String> getAllManifestFiles(Table table) 
{
 
     return allManifestFiles;
   }
+
+  public static AbstractOptimizingEvaluator createOptimizingEvaluator(
+      TableRuntime tableRuntime,
+      MixedTable table,
+      TableSnapshot snapshot,
+      int maxPendingPartitions) {
+    ServerTableIdentifier identifier = tableRuntime.getTableIdentifier();
+    OptimizingConfig config = tableRuntime.getOptimizingConfig();
+    long lastMinor = tableRuntime.getLastMinorOptimizingTime();
+    long lastFull = tableRuntime.getLastFullOptimizingTime();
+    if (TableFormat.ICEBERG.in(table.format())) {
+      return new IcebergOptimizerEvaluator(
+          identifier, config, table, snapshot, maxPendingPartitions, 
lastMinor, lastFull);
+    } else if (TableFormat.MIXED_ICEBERG.in(table.format())) {
+      return new MixedIcebergOptimizingEvaluator(
+          identifier, config, table, snapshot, maxPendingPartitions, 
lastMinor, lastFull);
+    } else if (TableFormat.MIXED_HIVE.in(table.format())) {
+      return new MixedHiveOptimizingEvaluator(
+          identifier, config, table, snapshot, maxPendingPartitions, 
lastMinor, lastFull);
+    }
+    throw new IllegalStateException("Un-supported table-format:" + 
table.format().toString());
+  }
+
+  public static AbstractOptimizingEvaluator createOptimizingEvaluator(
+      TableRuntime tableRuntime, MixedTable table, int maxPendingPartitions) {
+    TableSnapshot snapshot = IcebergTableUtil.getSnapshot(table, tableRuntime);
+    return createOptimizingEvaluator(tableRuntime, table, snapshot, 
maxPendingPartitions);
+  }
+
+  public static AbstractOptimizingPlanner createOptimizingPlanner(
+      TableRuntime tableRuntime,
+      MixedTable table,
+      double availableCore,
+      long maxInputSizePerThread) {
+    Expression partitionFilter =
+        tableRuntime.getPendingInput() == null
+            ? Expressions.alwaysTrue()
+            : 
tableRuntime.getPendingInput().getPartitions().entrySet().stream()
+                .map(
+                    entry ->
+                        ExpressionUtil.convertPartitionDataToDataFilter(
+                            table, entry.getKey(), entry.getValue()))
+                .reduce(Expressions::or)
+                .orElse(Expressions.alwaysTrue());
+    long planTime = System.currentTimeMillis();
+    long processId = Math.max(tableRuntime.getNewestProcessId() + 1, planTime);
+    ServerTableIdentifier identifier = tableRuntime.getTableIdentifier();
+    OptimizingConfig config = tableRuntime.getOptimizingConfig();
+    long lastMinor = tableRuntime.getLastMinorOptimizingTime();
+    long lastFull = tableRuntime.getLastFullOptimizingTime();
+    TableSnapshot snapshot = IcebergTableUtil.getSnapshot(table, tableRuntime);
+    if (TableFormat.ICEBERG.in(table.format())) {
+      return new IcebergOptimizingPlanner(
+          identifier,
+          config,
+          table,
+          snapshot,
+          partitionFilter,
+          processId,
+          availableCore,
+          maxInputSizePerThread,
+          lastMinor,
+          lastFull);
+    } else if (TableFormat.MIXED_ICEBERG.in(table.format())) {
+      return new MixedIcebergOptimizingPlanner(
+          identifier,
+          config,
+          table,
+          snapshot,
+          partitionFilter,
+          processId,
+          availableCore,
+          maxInputSizePerThread,
+          lastMinor,
+          lastFull);
+    } else if (TableFormat.MIXED_HIVE.in(table.format())) {
+      return new MixedHiveOptimizingPlanner(
+          identifier,
+          config,
+          table,
+          snapshot,
+          partitionFilter,
+          processId,
+          availableCore,
+          maxInputSizePerThread,
+          lastMinor,
+          lastFull);
+    }
+    throw new IllegalStateException("Un-supported table-format:" + 
table.format().toString());

Review Comment:
   ```suggestion
       throw new IllegalStateException("Unsupported table format:" + 
table.format().toString());
   ```



-- 
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]

Reply via email to