This is an automated email from the ASF dual-hosted git repository.

yuanzhou 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 4592e07fd [CORE] Avoid copy in ByteLiteralNode (#5763)
4592e07fd is described below

commit 4592e07fdb4179c68e41405b020e7cae202d7336
Author: Jin Chengcheng <[email protected]>
AuthorDate: Tue May 28 08:21:26 2024 +0800

    [CORE] Avoid copy in ByteLiteralNode (#5763)
    
    Optimize the serialized bloom filter to avoid extra copy
---
 .../gluten/substrait/expression/BinaryLiteralNode.java      | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git 
a/gluten-core/src/main/java/org/apache/gluten/substrait/expression/BinaryLiteralNode.java
 
b/gluten-core/src/main/java/org/apache/gluten/substrait/expression/BinaryLiteralNode.java
index 864aeb741..3d1ee5174 100644
--- 
a/gluten-core/src/main/java/org/apache/gluten/substrait/expression/BinaryLiteralNode.java
+++ 
b/gluten-core/src/main/java/org/apache/gluten/substrait/expression/BinaryLiteralNode.java
@@ -22,6 +22,9 @@ import org.apache.gluten.substrait.type.TypeNode;
 import com.google.protobuf.ByteString;
 import io.substrait.proto.Expression.Literal.Builder;
 
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
 public class BinaryLiteralNode extends LiteralNodeWithValue<byte[]> {
   public BinaryLiteralNode(byte[] value) {
     super(value, new BinaryTypeNode(true));
@@ -33,6 +36,14 @@ public class BinaryLiteralNode extends 
LiteralNodeWithValue<byte[]> {
 
   @Override
   protected void updateLiteralBuilder(Builder literalBuilder, byte[] value) {
-    literalBuilder.setBinary(ByteString.copyFrom(value));
+    ByteString byteValue;
+    try {
+      Method m = ByteString.class.getDeclaredMethod("wrap", byte[].class);
+      m.setAccessible(true);
+      byteValue = (ByteString) m.invoke(null, value);
+    } catch (NoSuchMethodException | InvocationTargetException | 
IllegalAccessException e) {
+      throw new RuntimeException(e);
+    }
+    literalBuilder.setBinary(byteValue);
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to