zjuwangg commented on code in PR #8839:
URL: https://github.com/apache/incubator-gluten/pull/8839#discussion_r1977103996


##########
gluten-flink/runtime/src/main/java/org/apache/gluten/table/runtime/operators/GlutenCalOperator.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gluten.table.runtime.operators;
+
+import org.apache.gluten.backendsapi.FlinkBackend;
+import org.apache.gluten.table.runtime.operators.GlutenOperator;
+import org.apache.gluten.vectorized.VLNativeRowVector;
+
+import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.runtime.operators.TableStreamOperator;
+
+/** Calculate operator in gluten, which will call Velox to run. */
+public class GlutenCalOperator extends TableStreamOperator<RowData>
+        implements OneInputStreamOperator<RowData, RowData>, GlutenOperator {
+
+    private final byte[] glutenPlan;
+
+    private StreamRecord outElement = null;
+
+    private int nativeExecutor;
+
+    public GlutenCalOperator(byte[] plan) {
+        this.glutenPlan = plan;
+    }
+
+    @Override
+    public void open() throws Exception {
+        super.open();
+        outElement = new StreamRecord(null);
+
+        nativeExecutor = 
FlinkBackend.flinkPlanExecApi().generateOperator(glutenPlan);
+    }
+
+    @Override
+    public void processElement(StreamRecord<RowData> element) throws Exception 
{
+        // TODO: use velox jni methods to run?
+        long res = nativeProcessElement(
+            nativeExecutor,
+            VLNativeRowVector.fromRowData(element.getValue()).rowAddress());
+        if (res > 0) {
+            output.collect(outElement.replace(new 
VLNativeRowVector(res).toRowData()));
+        }
+    }
+
+    private native long nativeProcessElement(int executor, long data);

Review Comment:
   Still lack the native implementation here?



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