This is an automated email from the ASF dual-hosted git repository.
richox pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/auron.git
The following commit(s) were added to refs/heads/master by this push:
new bd83f3db Introduce FlinkAuronAdaptor and FlinkAuronAdaptorProvider
(#2056)
bd83f3db is described below
commit bd83f3dbf3ef8ffff1af60a3e7d8ac8b66780f65
Author: zhangmang <[email protected]>
AuthorDate: Tue Mar 3 10:38:47 2026 +0800
Introduce FlinkAuronAdaptor and FlinkAuronAdaptorProvider (#2056)
# Which issue does this PR close?
Closes #1855
# Rationale for this change
* Introduce FlinkAuronAdaptor and FlinkAuronAdaptorProvider
# What changes are included in this PR?
* add FlinkAuronAdaptor
* add FlinkAuronAdaptorProvider
# Are there any user-facing changes?
* NO
# How was this patch tested?
* Test vim UT FlinkAuronAdaptorTest#testCreateAuronAdaptor
---
.../org/apache/auron/jni/FlinkAuronAdaptor.java | 75 ++++++++++++++++++++++
.../auron/jni/FlinkAuronAdaptorProvider.java | 27 ++++++++
.../org.apache.auron.jni.AuronAdaptorProvider | 17 +++++
.../auron/flink/jni/FlinkAuronAdaptorTest.java | 36 +++++++++++
.../org.apache.auron.jni.AuronAdaptorProvider | 17 +++++
5 files changed, 172 insertions(+)
diff --git
a/auron-flink-extension/auron-flink-runtime/src/main/java/org/apache/auron/jni/FlinkAuronAdaptor.java
b/auron-flink-extension/auron-flink-runtime/src/main/java/org/apache/auron/jni/FlinkAuronAdaptor.java
new file mode 100644
index 00000000..11a40498
--- /dev/null
+++
b/auron-flink-extension/auron-flink-runtime/src/main/java/org/apache/auron/jni/FlinkAuronAdaptor.java
@@ -0,0 +1,75 @@
+/*
+ * 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.auron.jni;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import org.apache.auron.configuration.AuronConfiguration;
+import org.apache.auron.flink.configuration.FlinkAuronConfiguration;
+import org.apache.auron.functions.AuronUDFWrapperContext;
+
+/**
+ * The adaptor for flink to call auron native library.
+ */
+public class FlinkAuronAdaptor extends AuronAdaptor {
+
+ @Override
+ public void loadAuronLib() {
+ String libName = System.mapLibraryName("auron");
+ ClassLoader classLoader = AuronAdaptor.class.getClassLoader();
+ try {
+ InputStream libInputStream =
classLoader.getResourceAsStream(libName);
+ File tempFile = File.createTempFile("libauron-", ".tmp");
+ tempFile.deleteOnExit();
+ Files.copy(libInputStream, tempFile.toPath(),
StandardCopyOption.REPLACE_EXISTING);
+ System.load(tempFile.getAbsolutePath());
+ } catch (IOException e) {
+ throw new IllegalStateException("error loading native libraries: "
+ e);
+ }
+ }
+
+ @Override
+ public String getDirectWriteSpillToDiskFile() throws IOException {
+ File tempFile = File.createTempFile("auron-spill-", ".tmp", new
File(System.getenv("PWD")));
+ tempFile.deleteOnExit();
+ return tempFile.getAbsolutePath();
+ }
+
+ @Override
+ public Object getThreadContext() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+
+ @Override
+ public void setThreadContext(Object context) {
+ Thread.currentThread().setContextClassLoader((ClassLoader) context);
+ }
+
+ @Override
+ public AuronConfiguration getAuronConfiguration() {
+ return new FlinkAuronConfiguration();
+ }
+
+ @Override
+ public AuronUDFWrapperContext getAuronUDFWrapperContext(ByteBuffer
byteBuffer) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git
a/auron-flink-extension/auron-flink-runtime/src/main/java/org/apache/auron/jni/FlinkAuronAdaptorProvider.java
b/auron-flink-extension/auron-flink-runtime/src/main/java/org/apache/auron/jni/FlinkAuronAdaptorProvider.java
new file mode 100644
index 00000000..22816f1d
--- /dev/null
+++
b/auron-flink-extension/auron-flink-runtime/src/main/java/org/apache/auron/jni/FlinkAuronAdaptorProvider.java
@@ -0,0 +1,27 @@
+/*
+ * 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.auron.jni;
+
+/**
+ * FlinkAuronAdaptorProvider is used to create FlinkAuronAdaptor.
+ */
+public class FlinkAuronAdaptorProvider implements AuronAdaptorProvider {
+ @Override
+ public AuronAdaptor create() {
+ return new FlinkAuronAdaptor();
+ }
+}
diff --git
a/auron-flink-extension/auron-flink-runtime/src/main/resources/META-INF/services/org.apache.auron.jni.AuronAdaptorProvider
b/auron-flink-extension/auron-flink-runtime/src/main/resources/META-INF/services/org.apache.auron.jni.AuronAdaptorProvider
new file mode 100644
index 00000000..619d4fe1
--- /dev/null
+++
b/auron-flink-extension/auron-flink-runtime/src/main/resources/META-INF/services/org.apache.auron.jni.AuronAdaptorProvider
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+org.apache.auron.jni.FlinkAuronAdaptorProvider
\ No newline at end of file
diff --git
a/auron-flink-extension/auron-flink-runtime/src/test/java/org/apache/auron/flink/jni/FlinkAuronAdaptorTest.java
b/auron-flink-extension/auron-flink-runtime/src/test/java/org/apache/auron/flink/jni/FlinkAuronAdaptorTest.java
new file mode 100644
index 00000000..7c6026ce
--- /dev/null
+++
b/auron-flink-extension/auron-flink-runtime/src/test/java/org/apache/auron/flink/jni/FlinkAuronAdaptorTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.auron.flink.jni;
+
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+
+import org.apache.auron.jni.AuronAdaptor;
+import org.apache.auron.jni.FlinkAuronAdaptor;
+import org.junit.jupiter.api.Test;
+
+/**
+ * This class is used to test the FlinkAuronAdaptor class.
+ */
+public class FlinkAuronAdaptorTest {
+
+ @Test
+ public void testCreateAuronAdaptor() {
+ AuronAdaptor flinkAuronAdaptor = AuronAdaptor.getInstance();
+ assertInstanceOf(
+ FlinkAuronAdaptor.class, flinkAuronAdaptor, "SPI should
discover and instantiate FlinkAuronAdaptor");
+ }
+}
diff --git
a/auron-flink-extension/auron-flink-runtime/src/test/resources/META-INF/services/org.apache.auron.jni.AuronAdaptorProvider
b/auron-flink-extension/auron-flink-runtime/src/test/resources/META-INF/services/org.apache.auron.jni.AuronAdaptorProvider
new file mode 100644
index 00000000..619d4fe1
--- /dev/null
+++
b/auron-flink-extension/auron-flink-runtime/src/test/resources/META-INF/services/org.apache.auron.jni.AuronAdaptorProvider
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+org.apache.auron.jni.FlinkAuronAdaptorProvider
\ No newline at end of file