You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/10/12 03:33:34 UTC

[GitHub] [skywalking] kezhenxu94 commented on a change in pull request #7907: Support `(str->long)` and `(str->int)` cast statements in OAL core engine.

kezhenxu94 commented on a change in pull request #7907:
URL: https://github.com/apache/skywalking/pull/7907#discussion_r726733524



##########
File path: oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/util/TypeCastUtil.java
##########
@@ -0,0 +1,43 @@
+/*
+ * 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.util;
+
+public class TypeCastUtil {
+    /**
+     * @param castType           to change the value of given original expression.
+     * @param originalExpression to read the value
+     * @return cast expression if cast type exists and is legal.
+     */
+    public static String withCast(String castType, String originalExpression) {
+        if (castType == null) {
+            return originalExpression;
+        }
+        switch (castType) {
+            case "(str->long)":
+            case "(long)":

Review comment:
       This is what I meant, if we provide `str->long`, we can provide `long(str)` instead, I know we don't have static type checking from day one, this is the same as what filters do, we provide methods with different argument types, and the actual parameter can find the best-fit one:
   
   We have methods like this 👇 and all of `int < int`, `long < long`, `float < float` can find a method to invoke, without checking the static types.
   
   ```java
   public class LessEqualMatch {
       public boolean match(int left, int right) {
           return left <= right;
       }
   
       public boolean match(long left, long right) {
           return left <= right;
       }
   
       public boolean match(float left, float right) {
           return left <= right;
       }
   
       public boolean match(double left, double right) {
           return left <= right;
       }
   // ...
   }
   ```

##########
File path: CHANGES.md
##########
@@ -6,23 +6,33 @@ Release Notes.
 ------------------
 
 #### OAP Server
+
 * Add component definition for `Jackson`.
 * Fix that zipkin-receiver plugin is not packaged into dist.
 * Replace e2e cases to e2e-v2: Lua Nginx/SelfObservability.
 * Upgrade Armeria to 1.12, upgrade OpenSearch test version to 1.1.0.
 * Add component definition for `Apache-Kylin`.
 * Enhance `get` generation mechanism of OAL engine, support map type of source's field.
 * Replace e2e cases to e2e-v2: Gateway.
+* Add `tag`(Map) into All, Service, ServiceInstance and Endpoint sources.
+* Fix `funcParamExpression` and `literalExpression` can't be used in the same aggregation function.
+* Support cast statement in the OAL core engine.
+* Support `(str->long)` and `(long)` for string to long cast statement.

Review comment:
       What's the point to provide 2 different syntaxes for one feature?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org