You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by wu...@apache.org on 2018/08/19 14:46:24 UTC

[incubator-skywalking-oal-tool] branch master updated: Build the primary key. (#2)

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

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking-oal-tool.git


The following commit(s) were added to refs/heads/master by this push:
     new 7b3f884  Build the primary key. (#2)
7b3f884 is described below

commit 7b3f8849d7aab8695127dbb766512b560e7199f7
Author: 彭勇升 pengys <80...@qq.com>
AuthorDate: Sun Aug 19 22:46:23 2018 +0800

    Build the primary key. (#2)
---
 .../src/main/resources/code-templates/IndicatorImplementor.ftl   | 9 ++++++++-
 .../resources/expectedFiles/IndicatorImplementorExpected.java    | 5 ++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/oal-parser/src/main/resources/code-templates/IndicatorImplementor.ftl b/oal-parser/src/main/resources/code-templates/IndicatorImplementor.ftl
index 25d56c7..5721686 100644
--- a/oal-parser/src/main/resources/code-templates/IndicatorImplementor.ftl
+++ b/oal-parser/src/main/resources/code-templates/IndicatorImplementor.ftl
@@ -20,6 +20,7 @@ package org.apache.skywalking.oap.server.core.analysis.generated.${packageName};
 
 import java.util.*;
 import lombok.*;
+import org.apache.skywalking.oap.server.core.Const;
 import org.apache.skywalking.oap.server.core.analysis.indicator.*;
 import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
 import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
@@ -42,7 +43,13 @@ public class ${metricName}Indicator extends ${indicatorClassName} {
 </#list>
 
     @Override public String id() {
-        return String.valueOf(id);
+        String splitJointId = String.valueOf(getTimeBucket());
+<#list fieldsFromSource as sourceField>
+    <#if sourceField.isID()>
+        splitJointId += Const.ID_SPLIT + String.valueOf(${sourceField.fieldName});
+    </#if>
+</#list>
+        return splitJointId;
     }
 
     @Override public int hashCode() {
diff --git a/oal-parser/src/test/resources/expectedFiles/IndicatorImplementorExpected.java b/oal-parser/src/test/resources/expectedFiles/IndicatorImplementorExpected.java
index 95fd194..f8161e3 100644
--- a/oal-parser/src/test/resources/expectedFiles/IndicatorImplementorExpected.java
+++ b/oal-parser/src/test/resources/expectedFiles/IndicatorImplementorExpected.java
@@ -20,6 +20,7 @@ package org.apache.skywalking.oap.server.core.analysis.generated.service.service
 
 import java.util.*;
 import lombok.*;
+import org.apache.skywalking.oap.server.core.Const;
 import org.apache.skywalking.oap.server.core.analysis.indicator.*;
 import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
 import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
@@ -40,7 +41,9 @@ public class ServiceAvgIndicator extends AvgIndicator {
     @Setter @Getter @Column(columnName = "id") private int id;
 
     @Override public String id() {
-        return String.valueOf(id);
+        String splitJointId = String.valueOf(getTimeBucket());
+        splitJointId += Const.ID_SPLIT + String.valueOf(id);
+        return splitJointId;
     }
 
     @Override public int hashCode() {