You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2021/10/12 09:26:26 UTC

[skywalking] branch oal3 updated: * Refactor the OAL context to improve readability. * Fix wrong generated codes of `hashCode` and `remoteHashCode` methods for numeric fields.

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

wusheng pushed a commit to branch oal3
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/oal3 by this push:
     new bf5e264  * Refactor the OAL context to improve readability. * Fix wrong generated codes of `hashCode` and `remoteHashCode` methods for numeric fields.
bf5e264 is described below

commit bf5e264e804b7545dbf240de84f47ece340bfbef
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Tue Oct 12 17:26:07 2021 +0800

    * Refactor the OAL context to improve readability.
    * Fix wrong generated codes of `hashCode` and `remoteHashCode` methods for numeric fields.
---
 CHANGES.md                                         |   2 +
 .../oal/rt/parser/AggregationFuncStmt.java         |  70 ++++++++++++++
 .../skywalking/oal/rt/parser/AnalysisResult.java   | 102 ++++++++++-----------
 .../skywalking/oal/rt/parser/DeepAnalysis.java     |  11 +--
 .../skywalking/oal/rt/parser/OALListener.java      |  12 +--
 .../resources/code-templates/metrics/hashCode.ftl  |   2 +-
 .../code-templates/metrics/remoteHashCode.ftl      |   2 +-
 .../skywalking/oal/rt/parser/DeepAnalysisTest.java |  12 +--
 .../skywalking/oal/rt/parser/ScriptParserTest.java |  32 +++----
 9 files changed, 153 insertions(+), 92 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index dce98e4..2ecf4af 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -23,6 +23,8 @@ Release Notes.
 * Support literal `string` as parameter of aggregation function.
 * Add `attributeExpression` and `attributeExpressionSegment` in the OAL grammar tree to support `map` type for the
   attribute expression.
+* Refactor the OAL context to improve readability.
+* Fix wrong generated codes of `hashCode` and `remoteHashCode` methods for numeric fields.
 
 #### UI
 
diff --git a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/AggregationFuncStmt.java b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/AggregationFuncStmt.java
new file mode 100644
index 0000000..adb5471
--- /dev/null
+++ b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/AggregationFuncStmt.java
@@ -0,0 +1,70 @@
+/*
+ * 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.skywalking.oal.rt.parser;
+
+import java.util.LinkedList;
+import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
+
+@Setter
+@Getter
+public class AggregationFuncStmt {
+    private String aggregationFunctionName;
+
+    private List<ConditionExpression> funcConditionExpressions;
+
+    private int funcConditionExpressionGetIdx = 0;
+
+    private List<Argument> funcArgs;
+
+    private int argGetIdx = 0;
+
+    private String nextArgCast = null;
+
+    public void addFuncConditionExpression(ConditionExpression conditionExpression) {
+        if (funcConditionExpressions == null) {
+            funcConditionExpressions = new LinkedList<>();
+        }
+        funcConditionExpressions.add(conditionExpression);
+    }
+
+    public ConditionExpression getNextFuncConditionExpression() {
+        return funcConditionExpressions.get(funcConditionExpressionGetIdx++);
+    }
+
+    public void addFuncArg(Argument argument) {
+        if (funcArgs == null) {
+            funcArgs = new LinkedList<>();
+        }
+        if (nextArgCast != null) {
+            argument.setCastType(nextArgCast);
+            nextArgCast = null;
+        }
+        funcArgs.add(argument);
+    }
+
+    public Argument getLastArgument() {
+        return funcArgs.get(funcArgs.size() - 1);
+    }
+
+    public Argument getNextFuncArg() {
+        return funcArgs.get(argGetIdx++);
+    }
+}
diff --git a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/AnalysisResult.java b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/AnalysisResult.java
index 136ad26..acaa5e9 100644
--- a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/AnalysisResult.java
+++ b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/AnalysisResult.java
@@ -24,45 +24,69 @@ import lombok.Getter;
 import lombok.Setter;
 import org.apache.skywalking.oap.server.core.storage.type.StorageDataComplexObject;
 
+/**
+ * OAL analysis result.
+ */
 @Getter
 @Setter
 public class AnalysisResult {
+    /**
+     * Variable name of one OAL expression.
+     */
     private String varName;
-
+    /**
+     * Generated metric name.
+     */
     private String metricsName;
-
+    /**
+     * Package name of generated metric class.
+     */
     private String metricsClassPackage;
-
+    /**
+     * Table name for the storage.
+     */
     private String tableName;
-
-    private String packageName;
-
+    /**
+     * The package name of source class from {@link org.apache.skywalking.oap.server.core.oal.rt.OALDefine}
+     */
     private String sourcePackage;
-
+    /**
+     * The class name of generated metric class.
+     */
     private String metricsClassName;
-
+    /**
+     * The raw parsed result of from statement.
+     */
     private FromStmt from = new FromStmt();
-
+    /**
+     * The raw parsed result of filter statements.
+     */
     private FilterStmts filters = new FilterStmts();
-
-    private String aggregationFunctionName;
-
+    /**
+     * The raw parsed result of aggregation function with arguments.
+     */
+    private AggregationFuncStmt aggregationFuncStmt = new AggregationFuncStmt();
+
+    /**
+     * Generated through {@link #aggregationFuncStmt}
+     */
     private EntryMethod entryMethod;
 
-    private List<ConditionExpression> funcConditionExpressions;
-
-    private int funcConditionExpressionGetIdx = 0;
-
-    private List<Argument> funcArgs;
-
-    private int argGetIdx = 0;
-
-    private String nextArgCast = null;
-
+    /**
+     * Persistent columns are generated by {@link org.apache.skywalking.oap.server.core.storage.annotation.Column}
+     * definition of {@link org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsFunction}.
+     */
     private List<DataColumn> persistentFields;
-
+    /**
+     * Fields of metric class are generated by the fields annotated {@link org.apache.skywalking.oap.server.core.source.ScopeDefaultColumn.DefinedByField}
+     * and class level definition through {@link org.apache.skywalking.oap.server.core.source.ScopeDefaultColumn.VirtualColumnDefinition}
+     * in the {@link org.apache.skywalking.oap.server.core.source.Source}
+     */
     private List<SourceColumn> fieldsFromSource;
-
+    /**
+     * Fields generated by {@link #fieldsFromSource} and {@link #persistentFields}. These fields are used in final
+     * persistence.
+     */
     private PersistenceColumns serializeFields;
 
     public void addPersistentField(String fieldName, String columnName, Class<?> type) {
@@ -73,36 +97,6 @@ public class AnalysisResult {
         persistentFields.add(dataColumn);
     }
 
-    public void addFuncConditionExpression(ConditionExpression conditionExpression) {
-        if (funcConditionExpressions == null) {
-            funcConditionExpressions = new LinkedList<>();
-        }
-        funcConditionExpressions.add(conditionExpression);
-    }
-
-    public ConditionExpression getNextFuncConditionExpression() {
-        return funcConditionExpressions.get(funcConditionExpressionGetIdx++);
-    }
-
-    public void addFuncArg(Argument argument) {
-        if (funcArgs == null) {
-            funcArgs = new LinkedList<>();
-        }
-        if (nextArgCast != null) {
-            argument.setCastType(nextArgCast);
-            nextArgCast = null;
-        }
-        funcArgs.add(argument);
-    }
-
-    public Argument getLastArgument() {
-        return funcArgs.get(funcArgs.size() - 1);
-    }
-
-    public Argument getNextFuncArg() {
-        return funcArgs.get(argGetIdx++);
-    }
-
     public void generateSerializeFields() {
         serializeFields = new PersistenceColumns();
         for (SourceColumn sourceColumn : fieldsFromSource) {
diff --git a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/DeepAnalysis.java b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/DeepAnalysis.java
index f24a73e..4e1341a 100644
--- a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/DeepAnalysis.java
+++ b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/DeepAnalysis.java
@@ -37,9 +37,7 @@ import static java.util.Objects.isNull;
 public class DeepAnalysis {
     public AnalysisResult analysis(AnalysisResult result) {
         // 1. Set sub package name by source.metrics
-        result.setPackageName(result.getFrom().getSourceName().toLowerCase());
-
-        Class<? extends Metrics> metricsClass = MetricsHolder.find(result.getAggregationFunctionName());
+        Class<? extends Metrics> metricsClass = MetricsHolder.find(result.getAggregationFuncStmt().getAggregationFunctionName());
         String metricsClassSimpleName = metricsClass.getSimpleName();
 
         result.setMetricsClassName(metricsClassSimpleName);
@@ -104,11 +102,12 @@ public class DeepAnalysis {
             } else if (annotation instanceof ConstOne) {
                 entryMethod.addArg(parameterType, "1");
             } else if (annotation instanceof org.apache.skywalking.oap.server.core.analysis.metrics.annotation.Expression) {
-                if (isNull(result.getFuncConditionExpressions()) || result.getFuncConditionExpressions().isEmpty()) {
+                if (isNull(result.getAggregationFuncStmt().getFuncConditionExpressions())
+                    || result.getAggregationFuncStmt().getFuncConditionExpressions().isEmpty()) {
                     throw new IllegalArgumentException(
                         "Entrance method:" + entranceMethod + " argument can't find funcParamExpression.");
                 } else {
-                    ConditionExpression expression = result.getNextFuncConditionExpression();
+                    ConditionExpression expression = result.getAggregationFuncStmt().getNextFuncConditionExpression();
                     final FilterMatchers.MatcherInfo matcherInfo = FilterMatchers.INSTANCE.find(
                         expression.getExpressionType());
 
@@ -124,7 +123,7 @@ public class DeepAnalysis {
                     entryMethod.addArg(argExpression);
                 }
             } else if (annotation instanceof Arg) {
-                entryMethod.addArg(parameterType, result.getNextFuncArg());
+                entryMethod.addArg(parameterType, result.getAggregationFuncStmt().getNextFuncArg());
             } else {
                 throw new IllegalArgumentException(
                     "Entrance method:" + entranceMethod + " doesn't the expected annotation.");
diff --git a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/OALListener.java b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/OALListener.java
index b2bfaa5..3621a06 100644
--- a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/OALListener.java
+++ b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/OALListener.java
@@ -82,7 +82,7 @@ public class OALListener extends OALParserBaseListener {
 
     @Override
     public void enterFunctionName(OALParser.FunctionNameContext ctx) {
-        current.setAggregationFunctionName(ctx.getText());
+        current.getAggregationFuncStmt().setAggregationFunctionName(ctx.getText());
     }
 
     @Override
@@ -103,7 +103,7 @@ public class OALListener extends OALParserBaseListener {
 
     @Override
     public void exitFuncParamExpression(OALParser.FuncParamExpressionContext ctx) {
-        current.addFuncConditionExpression(conditionExpression);
+        current.getAggregationFuncStmt().addFuncConditionExpression(conditionExpression);
         conditionExpression = null;
     }
 
@@ -230,22 +230,22 @@ public class OALListener extends OALParserBaseListener {
 
     @Override
     public void enterLiteralExpression(OALParser.LiteralExpressionContext ctx) {
-        current.addFuncArg(new Argument(EntryMethod.LITERAL_TYPE, Arrays.asList(ctx.getText())));
+        current.getAggregationFuncStmt().addFuncArg(new Argument(EntryMethod.LITERAL_TYPE, Arrays.asList(ctx.getText())));
     }
 
     @Override
     public void enterAttributeExpression(final OALParser.AttributeExpressionContext ctx) {
-        current.addFuncArg(new Argument(EntryMethod.ATTRIBUTE_EXP_TYPE, new ArrayList<>(3)));
+        current.getAggregationFuncStmt().addFuncArg(new Argument(EntryMethod.ATTRIBUTE_EXP_TYPE, new ArrayList<>(3)));
     }
 
     @Override
     public void enterAttributeExpressionSegment(OALParser.AttributeExpressionSegmentContext ctx) {
-        current.getLastArgument().addText(ctx.getText());
+        current.getAggregationFuncStmt().getLastArgument().addText(ctx.getText());
     }
 
     @Override
     public void enterFunctionArgCast(final OALParser.FunctionArgCastContext ctx) {
-        current.getLastArgument().setCastType(ctx.getText());
+        current.getAggregationFuncStmt().getLastArgument().setCastType(ctx.getText());
     }
 
     private String metricsNameFormat(String source) {
diff --git a/oap-server/oal-rt/src/main/resources/code-templates/metrics/hashCode.ftl b/oap-server/oal-rt/src/main/resources/code-templates/metrics/hashCode.ftl
index b4d80d6..bd5889c 100644
--- a/oap-server/oal-rt/src/main/resources/code-templates/metrics/hashCode.ftl
+++ b/oap-server/oal-rt/src/main/resources/code-templates/metrics/hashCode.ftl
@@ -5,7 +5,7 @@ int result = 17;
         <#if sourceField.getTypeName() == "java.lang.String">
             result = 31 * result + ${sourceField.fieldName}.hashCode();
         <#else>
-            result += Const.ID_CONNECTOR + ${sourceField.fieldName};
+            result = 31 * result + ${sourceField.fieldName};
         </#if>
     </#if>
 </#list>
diff --git a/oap-server/oal-rt/src/main/resources/code-templates/metrics/remoteHashCode.ftl b/oap-server/oal-rt/src/main/resources/code-templates/metrics/remoteHashCode.ftl
index 2f6dfe6..0e3a944 100644
--- a/oap-server/oal-rt/src/main/resources/code-templates/metrics/remoteHashCode.ftl
+++ b/oap-server/oal-rt/src/main/resources/code-templates/metrics/remoteHashCode.ftl
@@ -5,7 +5,7 @@ int result = 17;
         <#if sourceField.getTypeName() == "java.lang.String">
             result = 31 * result + ${sourceField.fieldName}.hashCode();
         <#else>
-            result += org.apache.skywalking.oap.server.core.Const.ID_CONNECTOR + ${sourceField.fieldName};
+            result = 31 * result + ${sourceField.fieldName};
         </#if>
     </#if>
 </#list>
diff --git a/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/DeepAnalysisTest.java b/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/DeepAnalysisTest.java
index 12c4cb3..0b5458f 100644
--- a/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/DeepAnalysisTest.java
+++ b/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/DeepAnalysisTest.java
@@ -52,10 +52,9 @@ public class DeepAnalysisTest {
     public void testServiceAnalysis() {
         AnalysisResult result = new AnalysisResult();
         result.getFrom().setSourceName("Service");
-        result.setPackageName("service.serviceavg");
         result.getFrom().getSourceAttribute().add("latency");
         result.setMetricsName("ServiceAvg");
-        result.setAggregationFunctionName("longAvg");
+        result.getAggregationFuncStmt().setAggregationFunctionName("longAvg");
 
         DeepAnalysis analysis = new DeepAnalysis();
         result = analysis.analysis(result);
@@ -76,10 +75,9 @@ public class DeepAnalysisTest {
     public void testEndpointAnalysis() {
         AnalysisResult result = new AnalysisResult();
         result.getFrom().setSourceName("Endpoint");
-        result.setPackageName("endpoint.endpointavg");
         result.getFrom().getSourceAttribute().add("latency");
         result.setMetricsName("EndpointAvg");
-        result.setAggregationFunctionName("longAvg");
+        result.getAggregationFuncStmt().setAggregationFunctionName("longAvg");
 
         DeepAnalysis analysis = new DeepAnalysis();
         result = analysis.analysis(result);
@@ -100,10 +98,9 @@ public class DeepAnalysisTest {
     public void testFilterAnalysis() {
         AnalysisResult result = new AnalysisResult();
         result.getFrom().setSourceName("Endpoint");
-        result.setPackageName("endpoint.endpointavg");
         result.getFrom().getSourceAttribute().add("latency");
         result.setMetricsName("EndpointAvg");
-        result.setAggregationFunctionName("longAvg");
+        result.getAggregationFuncStmt().setAggregationFunctionName("longAvg");
         ConditionExpression expression = new ConditionExpression();
         expression.setExpressionType("stringMatch");
         expression.getAttributes().add("name");
@@ -137,10 +134,9 @@ public class DeepAnalysisTest {
 
         AnalysisResult result = new AnalysisResult();
         result.getFrom().setSourceName("Endpoint");
-        result.setPackageName("endpoint.endpointavg");
         result.getFrom().getSourceAttribute().add("latency");
         result.setMetricsName("EndpointAvg");
-        result.setAggregationFunctionName("longAvg");
+        result.getAggregationFuncStmt().setAggregationFunctionName("longAvg");
 
         DeepAnalysis analysis = new DeepAnalysis();
 
diff --git a/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/ScriptParserTest.java b/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/ScriptParserTest.java
index 50ca552..4b699d5 100644
--- a/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/ScriptParserTest.java
+++ b/oap-server/oal-rt/src/test/java/org/apache/skywalking/oal/rt/parser/ScriptParserTest.java
@@ -58,13 +58,13 @@ public class ScriptParserTest {
         Assert.assertEquals("EndpointAvg", endpointAvg.getMetricsName());
         Assert.assertEquals("Endpoint", endpointAvg.getFrom().getSourceName());
         Assert.assertEquals("[latency]", endpointAvg.getFrom().getSourceAttribute().toString());
-        Assert.assertEquals("longAvg", endpointAvg.getAggregationFunctionName());
+        Assert.assertEquals("longAvg", endpointAvg.getAggregationFuncStmt().getAggregationFunctionName());
 
         AnalysisResult serviceAvg = results.get(1);
         Assert.assertEquals("ServiceAvg", serviceAvg.getMetricsName());
         Assert.assertEquals("Service", serviceAvg.getFrom().getSourceName());
         Assert.assertEquals("[latency]", serviceAvg.getFrom().getSourceAttribute().toString());
-        Assert.assertEquals("longAvg", serviceAvg.getAggregationFunctionName());
+        Assert.assertEquals("longAvg", serviceAvg.getAggregationFuncStmt().getAggregationFunctionName());
     }
 
     @Test
@@ -77,7 +77,7 @@ public class ScriptParserTest {
         Assert.assertEquals("EndpointPercent", endpointPercent.getMetricsName());
         Assert.assertEquals("Endpoint", endpointPercent.getFrom().getSourceName());
         Assert.assertEquals("[*]", endpointPercent.getFrom().getSourceAttribute().toString());
-        Assert.assertEquals("percent", endpointPercent.getAggregationFunctionName());
+        Assert.assertEquals("percent", endpointPercent.getAggregationFuncStmt().getAggregationFunctionName());
         EntryMethod entryMethod = endpointPercent.getEntryMethod();
         List<Object> methodArgsExpressions = entryMethod.getArgsExpressions();
         Assert.assertEquals(1, methodArgsExpressions.size());
@@ -95,7 +95,7 @@ public class ScriptParserTest {
         Assert.assertEquals("EndpointPercent", endpointPercent.getMetricsName());
         Assert.assertEquals("Endpoint", endpointPercent.getFrom().getSourceName());
         Assert.assertEquals("[*]", endpointPercent.getFrom().getSourceAttribute().toString());
-        Assert.assertEquals("longAvg", endpointPercent.getAggregationFunctionName());
+        Assert.assertEquals("longAvg", endpointPercent.getAggregationFuncStmt().getAggregationFunctionName());
         List<ConditionExpression> expressions = endpointPercent.getFilters().getFilterExpressionsParserResult();
 
         Assert.assertEquals(2, expressions.size());
@@ -126,7 +126,7 @@ public class ScriptParserTest {
         Assert.assertEquals("ServiceResponseS1Summary", responseSummary.getMetricsName());
         Assert.assertEquals("Service", responseSummary.getFrom().getSourceName());
         Assert.assertEquals("[latency]", responseSummary.getFrom().getSourceAttribute().toString());
-        Assert.assertEquals("sum", responseSummary.getAggregationFunctionName());
+        Assert.assertEquals("sum", responseSummary.getAggregationFuncStmt().getAggregationFunctionName());
         List<ConditionExpression> expressions = responseSummary.getFilters().getFilterExpressionsParserResult();
 
         Assert.assertEquals(1, expressions.size());
@@ -176,15 +176,15 @@ public class ScriptParserTest {
         List<AnalysisResult> results = parser.parse().getMetricsStmts();
         Assert.assertEquals(1, results.size());
         AnalysisResult result = results.get(0);
-        Assert.assertEquals("rate", result.getAggregationFunctionName());
-        Assert.assertEquals(2, result.getFuncConditionExpressions().size());
+        Assert.assertEquals("rate", result.getAggregationFuncStmt().getAggregationFunctionName());
+        Assert.assertEquals(2, result.getAggregationFuncStmt().getFuncConditionExpressions().size());
 
-        ConditionExpression expression1 = result.getFuncConditionExpressions().get(0);
+        ConditionExpression expression1 = result.getAggregationFuncStmt().getFuncConditionExpressions().get(0);
         Assert.assertEquals("[param1]", expression1.getAttributes().toString());
         Assert.assertEquals("booleanMatch", expression1.getExpressionType());
         Assert.assertEquals("true", expression1.getValue());
 
-        ConditionExpression expression2 = result.getFuncConditionExpressions().get(1);
+        ConditionExpression expression2 = result.getAggregationFuncStmt().getFuncConditionExpressions().get(1);
         Assert.assertEquals("[param2]", expression2.getAttributes().toString());
         Assert.assertEquals("booleanMatch", expression2.getExpressionType());
         Assert.assertEquals("false", expression2.getValue());
@@ -265,7 +265,7 @@ public class ScriptParserTest {
         final List<Expression> filterExpressions = servicePercent.getFilters().getFilterExpressions();
         Assert.assertEquals(1, filterExpressions.size());
         Assert.assertEquals("source.getSidecar().getInternalError()", filterExpressions.get(0).getLeft());
-        Assert.assertEquals("percent", servicePercent.getAggregationFunctionName());
+        Assert.assertEquals("percent", servicePercent.getAggregationFuncStmt().getAggregationFunctionName());
         EntryMethod entryMethod = servicePercent.getEntryMethod();
         List<Object> methodArgsExpressions = entryMethod.getArgsExpressions();
         Assert.assertEquals(1, methodArgsExpressions.size());
@@ -283,7 +283,7 @@ public class ScriptParserTest {
         final List<Expression> filterExpressions = clientCpm.getFilters().getFilterExpressions();
         Assert.assertEquals(1, filterExpressions.size());
         Assert.assertEquals("source.getComponentId()", filterExpressions.get(0).getLeft());
-        Assert.assertEquals("cpm", clientCpm.getAggregationFunctionName());
+        Assert.assertEquals("cpm", clientCpm.getAggregationFuncStmt().getAggregationFunctionName());
         EntryMethod entryMethod = clientCpm.getEntryMethod();
         List<Object> methodArgsExpressions = entryMethod.getArgsExpressions();
         Assert.assertEquals(1, methodArgsExpressions.size());
@@ -300,8 +300,8 @@ public class ScriptParserTest {
         final List<Expression> filterExpressions = clientCpm.getFilters().getFilterExpressions();
         Assert.assertEquals(1, filterExpressions.size());
         Assert.assertEquals("source.getTag(\"http.method\")", filterExpressions.get(0).getLeft());
-        Assert.assertEquals(1, clientCpm.getFuncArgs().size());
-        Assert.assertEquals("[tag[\"http.method\"]]", clientCpm.getFuncArgs().get(0).getText().toString());
+        Assert.assertEquals(1, clientCpm.getAggregationFuncStmt().getFuncArgs().size());
+        Assert.assertEquals("[tag[\"http.method\"]]", clientCpm.getAggregationFuncStmt().getFuncArgs().get(0).getText().toString());
     }
 
     @Test
@@ -317,9 +317,9 @@ public class ScriptParserTest {
         Assert.assertEquals(1, filterExpressions.size());
         Assert.assertEquals(
             "Long.parseLong(source.getTag(\"transmission.latency\"))", filterExpressions.get(0).getLeft());
-        Assert.assertEquals("(str->long)", castExp.getFuncConditionExpressions().get(0).getCastType());
-        Assert.assertEquals(EntryMethod.ATTRIBUTE_EXP_TYPE, castExp.getFuncArgs().get(0).getType());
-        Assert.assertEquals("(str->long)", castExp.getFuncArgs().get(0).getCastType());
+        Assert.assertEquals("(str->long)", castExp.getAggregationFuncStmt().getFuncConditionExpressions().get(0).getCastType());
+        Assert.assertEquals(EntryMethod.ATTRIBUTE_EXP_TYPE, castExp.getAggregationFuncStmt().getFuncArgs().get(0).getType());
+        Assert.assertEquals("(str->long)", castExp.getAggregationFuncStmt().getFuncArgs().get(0).getCastType());
     }
 
     @Test