lgbo-ustc commented on code in PR #11589:
URL: 
https://github.com/apache/incubator-gluten/pull/11589#discussion_r2867118094


##########
gluten-flink/runtime/src/main/java/org/apache/gluten/client/OffloadedJobGraphGenerator.java:
##########
@@ -248,6 +249,21 @@ private void createOffloadedOneInputOperator(
             inClass,
             outClass,
             sourceOperator.getDescription());
+    if (sourceOperator instanceof WindowAggOperator) {

Review Comment:
   should use if-else
   ```java
   
   if (sourceOperator instanceof WindowAggOperator) {
       // create new windowAggOperator
       offloadedOpConfig.setStreamOperator(newOneInputOp);
   } else {
       // the default handle
       offloadedOpConfig.setStreamOperator(newOneInputOp);
   }
   ```



##########
gluten-flink/runtime/src/main/java/org/apache/gluten/client/OffloadedJobGraphGenerator.java:
##########
@@ -248,6 +249,21 @@ private void createOffloadedOneInputOperator(
             inClass,
             outClass,
             sourceOperator.getDescription());
+    if (sourceOperator instanceof WindowAggOperator) {

Review Comment:
   Let's make the code simpler
   1. Add a new method in `GlutenOneInputOperator`
   ```java
     public <NIN, NOUT> GlutenOneInputOperator<NIN, NOUT> cloneWith(
         Class<NIN> newInClass, Class<NOUT> newOutClass) {
       return new GlutenOneInputOperator<>(
           this.glutenPlan,
           this.id,
           this.inputType,
           this.outputTypes,
           newInClass,
           newOutClass,
           this.description);
     }
   ```
   2. Override `cloneWith` in `WindowAggOperator`
   ```java
     @Override
     public <NIN, NOUT> WindowAggOperator<NIN, NOUT, W> cloneWith(
         Class<NIN> newInClass, Class<NOUT> newOutClass) {
       return new WindowAggOperator<>(
           getPlanNode(),
           getId(),
           getInputType(),
           getOutputTypes(),
           newInClass,
           newOutClass,
           getDescription(),
           keyType,
           accNames,
           accTypes);
     }
   ```
   3. Then only need to make following in `OffloadedJobGraphGenerator`
   ```java
       GlutenOneInputOperator<?, ?> newOneInputOp = 
sourceOperator.cloneWith(inClass, outClass);
   ```
   
   



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

Reply via email to