Skip to content

Commit e08f264

Browse files
committed
[FLINK] Bind native callback target for Gluten operators
1 parent 9202345 commit e08f264

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

.github/workflows/flink.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ jobs:
6969
export VELOX_DEPENDENCY_SOURCE=BUNDLED
7070
export fmt_SOURCE=BUNDLED
7171
export folly_SOURCE=BUNDLED
72-
git clone -b gluten-0530 https://github.com/bigo-sg/velox4j.git
73-
cd velox4j && git reset --hard 115edf79d265a61c30d45dfcc6ce932ad92378ca
72+
git clone -b feature/native-callback-bridge https://github.com/bigo-sg/velox4j.git
73+
cd velox4j && git reset --hard c2c193ead7bf88f632838bca58921ef699c89c11
7474
git apply $GITHUB_WORKSPACE/gluten-flink/patches/fix-velox4j.patch
7575
$GITHUB_WORKSPACE/build/mvn clean install -DskipTests -Dgpg.skip -Dspotless.skip=true
7676
cd ..

gluten-flink/runtime/src/main/java/org/apache/gluten/table/runtime/operators/GlutenOneInputOperator.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import io.github.zhztheplayer.velox4j.query.Query;
3232
import io.github.zhztheplayer.velox4j.query.SerialTask;
3333
import io.github.zhztheplayer.velox4j.serde.Serde;
34+
import io.github.zhztheplayer.velox4j.stateful.NativeCallbackTarget;
3435
import io.github.zhztheplayer.velox4j.stateful.StatefulElement;
3536
import io.github.zhztheplayer.velox4j.stateful.StatefulRecord;
3637
import io.github.zhztheplayer.velox4j.stateful.StatefulWatermark;
@@ -49,7 +50,7 @@
4950

5051
/** Calculate operator in gluten, which will call Velox to run. */
5152
public class GlutenOneInputOperator<IN, OUT> extends TableStreamOperator<OUT>
52-
implements OneInputStreamOperator<IN, OUT>, GlutenOperator {
53+
implements OneInputStreamOperator<IN, OUT>, GlutenOperator, NativeCallbackTarget {
5354

5455
private final StatefulPlanNode glutenPlan;
5556
private final String id;
@@ -143,6 +144,7 @@ void initSession() {
143144
VeloxQueryConfig.getConfig(getRuntimeContext()),
144145
VeloxConnectorConfig.getConfig(getRuntimeContext()));
145146
task = sessionResource.getSession().queryOps().execute(query);
147+
task.bindNativeCallbackTarget(this);
146148
task.addSplit(
147149
id, new ExternalStreamConnectorSplit("connector-external-stream", inputQueue.id()));
148150
task.noMoreSplits(id);
@@ -186,6 +188,11 @@ public void scheduleProcessElementOnMailbox() {
186188
scheduleDrainOnMailbox(this::drainTaskOutput);
187189
}
188190

191+
@Override
192+
public void onProcessElement() {
193+
scheduleProcessElementOnMailbox();
194+
}
195+
189196
@Override
190197
public void processElementInternal() {
191198
drainOutput(this::drainTaskOutput);

gluten-flink/runtime/src/main/java/org/apache/gluten/table/runtime/operators/GlutenTwoInputOperator.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import io.github.zhztheplayer.velox4j.plan.StatefulPlanNode;
2929
import io.github.zhztheplayer.velox4j.query.Query;
3030
import io.github.zhztheplayer.velox4j.query.SerialTask;
31+
import io.github.zhztheplayer.velox4j.stateful.NativeCallbackTarget;
3132
import io.github.zhztheplayer.velox4j.stateful.StatefulElement;
3233
import io.github.zhztheplayer.velox4j.stateful.StatefulRecord;
3334
import io.github.zhztheplayer.velox4j.stateful.StatefulWatermark;
@@ -50,7 +51,7 @@
5051
* instead of flink RowData.
5152
*/
5253
public class GlutenTwoInputOperator<IN, OUT> extends AbstractStreamOperator<OUT>
53-
implements TwoInputStreamOperator<IN, IN, OUT>, GlutenOperator {
54+
implements TwoInputStreamOperator<IN, IN, OUT>, GlutenOperator, NativeCallbackTarget {
5455

5556
private static final Logger LOG = LoggerFactory.getLogger(GlutenTwoInputOperator.class);
5657

@@ -139,6 +140,11 @@ public void scheduleProcessElementOnMailbox() {
139140
scheduleDrainOnMailbox(this::drainTaskOutput);
140141
}
141142

143+
@Override
144+
public void onProcessElement() {
145+
scheduleProcessElementOnMailbox();
146+
}
147+
142148
@Override
143149
public void processElement1(StreamRecord<IN> element) {
144150
StatefulRecord statefulRecord =
@@ -296,6 +302,7 @@ private void initSession() {
296302
VeloxQueryConfig.getConfig(getRuntimeContext()),
297303
VeloxConnectorConfig.getConfig(getRuntimeContext()));
298304
task = sessionResource.getSession().queryOps().execute(query);
305+
task.bindNativeCallbackTarget(this);
299306

300307
ExternalStreamConnectorSplit leftSplit =
301308
new ExternalStreamConnectorSplit("connector-external-stream", leftInputQueue.id());

0 commit comments

Comments
 (0)