This is an automated email from the ASF dual-hosted git repository.
hongze pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git
The following commit(s) were added to refs/heads/main by this push:
new d721f71161 [CORE] Merge SubstraitUtil classes (#10587)
d721f71161 is described below
commit d721f7116106d7f21e5f3baa86362fd22f1f8654
Author: kevinwilfong <[email protected]>
AuthorDate: Thu Sep 4 01:59:13 2025 -0700
[CORE] Merge SubstraitUtil classes (#10587)
---
.../gluten/substrait/rel/LocalFilesNode.java | 2 +-
.../gluten/substrait/utils/SubstraitUtil.java | 51 ----------------------
.../org/apache/gluten/utils/SubstraitUtil.scala | 16 +++++++
3 files changed, 17 insertions(+), 52 deletions(-)
diff --git
a/gluten-substrait/src/main/java/org/apache/gluten/substrait/rel/LocalFilesNode.java
b/gluten-substrait/src/main/java/org/apache/gluten/substrait/rel/LocalFilesNode.java
index f3faee09e7..7a17372ec2 100644
---
a/gluten-substrait/src/main/java/org/apache/gluten/substrait/rel/LocalFilesNode.java
+++
b/gluten-substrait/src/main/java/org/apache/gluten/substrait/rel/LocalFilesNode.java
@@ -18,7 +18,7 @@ package org.apache.gluten.substrait.rel;
import org.apache.gluten.config.GlutenConfig;
import org.apache.gluten.expression.ConverterUtils;
-import org.apache.gluten.substrait.utils.SubstraitUtil;
+import org.apache.gluten.utils.SubstraitUtil;
import io.substrait.proto.NamedStruct;
import io.substrait.proto.ReadRel;
diff --git
a/gluten-substrait/src/main/java/org/apache/gluten/substrait/utils/SubstraitUtil.java
b/gluten-substrait/src/main/java/org/apache/gluten/substrait/utils/SubstraitUtil.java
deleted file mode 100644
index 3bdd475ec0..0000000000
---
a/gluten-substrait/src/main/java/org/apache/gluten/substrait/utils/SubstraitUtil.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.substrait.utils;
-
-import org.apache.gluten.backendsapi.BackendsApiManager;
-
-import com.google.protobuf.Any;
-import com.google.protobuf.DoubleValue;
-import com.google.protobuf.Int32Value;
-import com.google.protobuf.Int64Value;
-import com.google.protobuf.Message;
-import com.google.protobuf.StringValue;
-
-public class SubstraitUtil {
-
- private SubstraitUtil() {}
-
- public static Any convertJavaObjectToAny(Object obj) {
- if (obj == null) return null;
- Message msg = null;
- if (obj instanceof String) {
- msg = StringValue.newBuilder().setValue(obj.toString()).build();
- } else if (obj instanceof Integer) {
- msg =
Int32Value.newBuilder().setValue(Integer.valueOf(obj.toString())).build();
- } else if (obj instanceof Long) {
- msg =
Int64Value.newBuilder().setValue(Long.valueOf(obj.toString())).build();
- } else if (obj instanceof Double) {
- msg =
DoubleValue.newBuilder().setValue(Double.valueOf(obj.toString())).build();
- } else {
- // TODO: generate the message according to the object type
- msg = StringValue.newBuilder().setValue(obj.toString()).build();
- }
-
- if (msg == null) return null;
- return BackendsApiManager.getTransformerApiInstance().packPBMessage(msg);
- }
-}
diff --git
a/gluten-substrait/src/main/scala/org/apache/gluten/utils/SubstraitUtil.scala
b/gluten-substrait/src/main/scala/org/apache/gluten/utils/SubstraitUtil.scala
index 9e11170852..a0fdde31ca 100644
---
a/gluten-substrait/src/main/scala/org/apache/gluten/utils/SubstraitUtil.scala
+++
b/gluten-substrait/src/main/scala/org/apache/gluten/utils/SubstraitUtil.scala
@@ -25,8 +25,10 @@ import org.apache.gluten.substrait.expression.ExpressionNode
import org.apache.spark.sql.catalyst.expressions.{Attribute, Expression}
import org.apache.spark.sql.catalyst.plans.{ExistenceJoin, FullOuter,
InnerLike, JoinType, LeftAnti, LeftOuter, LeftSemi, RightOuter}
+import com.google.protobuf.{Any, DoubleValue, Int32Value, Int64Value, Message,
StringValue}
import io.substrait.proto.{CrossRel, JoinRel, NamedStruct, Type}
+import java.lang.{Double => JDouble, Long => JLong}
import java.util.{Collections, List => JList}
import scala.collection.JavaConverters._
@@ -107,4 +109,18 @@ object SubstraitUtil {
val nameList = ConverterUtils.collectAttributeNamesWithExprId(output)
createNameStructBuilder(typeList, nameList,
Collections.emptyList()).build()
}
+
+ def convertJavaObjectToAny(obj: AnyRef): Any = {
+ if (obj == null) return null
+ val msg: Message = obj match {
+ case s: String => StringValue.newBuilder.setValue(s).build
+ case i: Integer => Int32Value.newBuilder.setValue(i).build
+ case l: JLong => Int64Value.newBuilder.setValue(l).build
+ case d: JDouble => DoubleValue.newBuilder.setValue(d).build
+ case _ =>
+ // TODO: generate the message according to the object type
+ StringValue.newBuilder.setValue(obj.toString).build
+ }
+ BackendsApiManager.getTransformerApiInstance.packPBMessage(msg)
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]