Repository: kylin
Updated Branches:
  refs/heads/master a77fbc850 -> 3cb0894c4


minor


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/3cb0894c
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/3cb0894c
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/3cb0894c

Branch: refs/heads/master
Commit: 3cb0894c4ff329d985513775c172ee47ed05ac67
Parents: a77fbc8
Author: Hongbin Ma <mahong...@apache.org>
Authored: Wed Aug 31 14:36:26 2016 +0800
Committer: Hongbin Ma <mahong...@apache.org>
Committed: Wed Aug 31 14:36:41 2016 +0800

----------------------------------------------------------------------
 .../filter/EvaluatableLikeFunction.java         | 26 +++++++++++++++++---
 1 file changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/3cb0894c/core-metadata/src/main/java/org/apache/kylin/metadata/filter/EvaluatableLikeFunction.java
----------------------------------------------------------------------
diff --git 
a/core-metadata/src/main/java/org/apache/kylin/metadata/filter/EvaluatableLikeFunction.java
 
b/core-metadata/src/main/java/org/apache/kylin/metadata/filter/EvaluatableLikeFunction.java
index 59961ac..28e544b 100644
--- 
a/core-metadata/src/main/java/org/apache/kylin/metadata/filter/EvaluatableLikeFunction.java
+++ 
b/core-metadata/src/main/java/org/apache/kylin/metadata/filter/EvaluatableLikeFunction.java
@@ -27,8 +27,13 @@ import org.apache.kylin.metadata.datatype.DataType;
 import org.apache.kylin.metadata.datatype.StringSerializer;
 import org.apache.kylin.metadata.tuple.IEvaluatableTuple;
 
+/**
+ * typically like will be handled by BuiltInFunctionTupleFilter rather than 
this
+ */
 public class EvaluatableLikeFunction extends BuiltInFunctionTupleFilter {
 
+    private boolean patternExtracted;
+
     public EvaluatableLikeFunction(String name) {
         super(name, FilterOperatorEnum.LIKE);
     }
@@ -86,11 +91,24 @@ public class EvaluatableLikeFunction extends 
BuiltInFunctionTupleFilter {
         return (filter instanceof ConstantTupleFilter) || (filter instanceof 
DynamicTupleFilter);
     }
 
+    @Override
+    public Object invokeFunction(Object input) throws 
InvocationTargetException, IllegalAccessException {
+        if (!patternExtracted) {
+            this.getLikePattern();
+        }
+        return super.invokeFunction(input);
+    }
+
+    //will replace the ByteArray pattern to String type
     public String getLikePattern() {
-        ByteArray byteArray = (ByteArray) methodParams.get(1);
-        StringSerializer s = new StringSerializer(DataType.getType("string"));
-        String pattern = s.deserialize(ByteBuffer.wrap(byteArray.array(), 
byteArray.offset(), byteArray.length()));
-        return pattern;
+        if (!patternExtracted) {
+            ByteArray byteArray = (ByteArray) methodParams.get(1);
+            StringSerializer s = new 
StringSerializer(DataType.getType("string"));
+            String pattern = s.deserialize(ByteBuffer.wrap(byteArray.array(), 
byteArray.offset(), byteArray.length()));
+            methodParams.set(1, pattern);
+            patternExtracted = true;
+        }
+        return (String) methodParams.get(1);
     }
 
 }

Reply via email to