From a4c7705ddf0c229c50a158ffabd3f013fc5d9109 Mon Sep 17 00:00:00 2001 From: Wan Kai Date: Sat, 5 Aug 2023 11:46:17 +0800 Subject: [PATCH] Move MQE codes to independent Maven module in`oap-server`. (#11176) --- .gitignore | 2 +- .../mqe-grammar/pom.xml | 5 +- .../skywalking/mqe/rt/grammar/MQELexer.g4 | 0 .../skywalking/mqe/rt/grammar/MQEParser.g4 | 0 oap-server/mqe-rt/pom.xml | 49 ++++ .../skywalking/mqe/rt/MQEVisitorBase.java | 209 ++++++++++++++++++ .../exception/IllegalExpressionException.java | 2 +- .../mqe/rt/exception/ParseErrorListener.java | 4 +- .../mqe/rt/operation/AggregateLabelsOp.java | 24 +- .../mqe/rt/operation/AggregationOp.java | 12 +- .../mqe/rt/operation/BinaryOp.java | 12 +- .../mqe/rt/operation/FunctionOp.java | 6 +- .../aggregatelabels/AggregateLabelsFunc.java | 4 +- .../AggregateLabelsFuncFactory.java | 4 +- .../AvgAggregateLabelsFunc.java | 4 +- .../MaxAggregateLabelsFunc.java | 4 +- .../MinAggregateLabelsFunc.java | 4 +- .../SumAggregateLabelsFunc.java | 4 +- .../mqe/rt/type}/ExpressionResult.java | 2 +- .../mqe/rt/type}/ExpressionResultType.java | 2 +- .../skywalking/mqe/rt/type}/MQEValue.java | 2 +- .../skywalking/mqe/rt/type}/MQEValues.java | 2 +- .../skywalking/mqe/rt/type}/Metadata.java | 2 +- .../mqe/rt}/AggregateLabelsOpTest.java | 8 +- .../library/mqe/rt}/AggregationOpTest.java | 8 +- .../library/mqe/rt}/BinaryOpTest.java | 8 +- .../library/mqe/rt}/FunctionOpTest.java | 8 +- .../skywalking/library/mqe/rt}/MockData.java | 12 +- oap-server/pom.xml | 2 + oap-server/server-query-plugin/pom.xml | 1 - .../query-graphql-plugin/pom.xml | 2 +- .../oap/query/graphql/mqe/rt/MQEVisitor.java | 189 +--------------- .../resolver/MetricsExpressionQuery.java | 6 +- 33 files changed, 346 insertions(+), 257 deletions(-) rename oap-server/{server-query-plugin => }/mqe-grammar/pom.xml (90%) rename oap-server/{server-query-plugin => }/mqe-grammar/src/main/antlr4/org/apache/skywalking/mqe/rt/grammar/MQELexer.g4 (100%) rename oap-server/{server-query-plugin => }/mqe-grammar/src/main/antlr4/org/apache/skywalking/mqe/rt/grammar/MQEParser.g4 (100%) create mode 100644 oap-server/mqe-rt/pom.xml create mode 100644 oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/MQEVisitorBase.java rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql => mqe-rt/src/main/java/org/apache/skywalking}/mqe/rt/exception/IllegalExpressionException.java (93%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql => mqe-rt/src/main/java/org/apache/skywalking}/mqe/rt/exception/ParseErrorListener.java (91%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql => mqe-rt/src/main/java/org/apache/skywalking}/mqe/rt/operation/AggregateLabelsOp.java (75%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql => mqe-rt/src/main/java/org/apache/skywalking}/mqe/rt/operation/AggregationOp.java (93%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql => mqe-rt/src/main/java/org/apache/skywalking}/mqe/rt/operation/BinaryOp.java (95%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql => mqe-rt/src/main/java/org/apache/skywalking}/mqe/rt/operation/FunctionOp.java (92%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql => mqe-rt/src/main/java/org/apache/skywalking}/mqe/rt/operation/aggregatelabels/AggregateLabelsFunc.java (91%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql => mqe-rt/src/main/java/org/apache/skywalking}/mqe/rt/operation/aggregatelabels/AggregateLabelsFuncFactory.java (91%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql => mqe-rt/src/main/java/org/apache/skywalking}/mqe/rt/operation/aggregatelabels/AvgAggregateLabelsFunc.java (94%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql => mqe-rt/src/main/java/org/apache/skywalking}/mqe/rt/operation/aggregatelabels/MaxAggregateLabelsFunc.java (93%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql => mqe-rt/src/main/java/org/apache/skywalking}/mqe/rt/operation/aggregatelabels/MinAggregateLabelsFunc.java (93%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql => mqe-rt/src/main/java/org/apache/skywalking}/mqe/rt/operation/aggregatelabels/SumAggregateLabelsFunc.java (93%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql => mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type}/ExpressionResult.java (95%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql => mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type}/ExpressionResultType.java (95%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql => mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type}/MQEValue.java (94%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql => mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type}/MQEValues.java (94%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql => mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type}/Metadata.java (94%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe => mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt}/AggregateLabelsOpTest.java (90%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe => mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt}/AggregationOpTest.java (95%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe => mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt}/BinaryOpTest.java (96%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe => mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt}/FunctionOpTest.java (95%) rename oap-server/{server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe => mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt}/MockData.java (92%) diff --git a/.gitignore b/.gitignore index 3bf5068856..3049d84a15 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,7 @@ OALLexer.tokens .externalToolBuilders oap-server/oal-grammar/**/gen/ MQELexer.tokens -oap-server/server-query-plugin/mqe-grammar/gen/ +oap-server/mqe-grammar/**/gen/ PromQLLexer.tokens oap-server/server-query-plugin/promql-plugin/gen/ LogQLLexer.tokens diff --git a/oap-server/server-query-plugin/mqe-grammar/pom.xml b/oap-server/mqe-grammar/pom.xml similarity index 90% rename from oap-server/server-query-plugin/mqe-grammar/pom.xml rename to oap-server/mqe-grammar/pom.xml index e6515a5693..39a00b4f8f 100644 --- a/oap-server/server-query-plugin/mqe-grammar/pom.xml +++ b/oap-server/mqe-grammar/pom.xml @@ -17,9 +17,10 @@ ~ --> - + - server-query-plugin + oap-server org.apache.skywalking 9.6.0-SNAPSHOT diff --git a/oap-server/server-query-plugin/mqe-grammar/src/main/antlr4/org/apache/skywalking/mqe/rt/grammar/MQELexer.g4 b/oap-server/mqe-grammar/src/main/antlr4/org/apache/skywalking/mqe/rt/grammar/MQELexer.g4 similarity index 100% rename from oap-server/server-query-plugin/mqe-grammar/src/main/antlr4/org/apache/skywalking/mqe/rt/grammar/MQELexer.g4 rename to oap-server/mqe-grammar/src/main/antlr4/org/apache/skywalking/mqe/rt/grammar/MQELexer.g4 diff --git a/oap-server/server-query-plugin/mqe-grammar/src/main/antlr4/org/apache/skywalking/mqe/rt/grammar/MQEParser.g4 b/oap-server/mqe-grammar/src/main/antlr4/org/apache/skywalking/mqe/rt/grammar/MQEParser.g4 similarity index 100% rename from oap-server/server-query-plugin/mqe-grammar/src/main/antlr4/org/apache/skywalking/mqe/rt/grammar/MQEParser.g4 rename to oap-server/mqe-grammar/src/main/antlr4/org/apache/skywalking/mqe/rt/grammar/MQEParser.g4 diff --git a/oap-server/mqe-rt/pom.xml b/oap-server/mqe-rt/pom.xml new file mode 100644 index 0000000000..204345ea97 --- /dev/null +++ b/oap-server/mqe-rt/pom.xml @@ -0,0 +1,49 @@ + + + + + + oap-server + org.apache.skywalking + 9.6.0-SNAPSHOT + + 4.0.0 + + mqe-rt + jar + + + + org.apache.skywalking + server-core + ${project.version} + + + org.apache.skywalking + library-util + ${project.version} + + + org.apache.skywalking + mqe-grammar + ${project.version} + + + diff --git a/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/MQEVisitorBase.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/MQEVisitorBase.java new file mode 100644 index 0000000000..229e849d92 --- /dev/null +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/MQEVisitorBase.java @@ -0,0 +1,209 @@ +/* + * 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.mqe.rt; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import lombok.extern.slf4j.Slf4j; +import org.apache.skywalking.mqe.rt.grammar.MQEParser; +import org.apache.skywalking.mqe.rt.grammar.MQEParserBaseVisitor; +import org.apache.skywalking.mqe.rt.operation.AggregateLabelsOp; +import org.apache.skywalking.mqe.rt.operation.AggregationOp; +import org.apache.skywalking.mqe.rt.operation.BinaryOp; +import org.apache.skywalking.mqe.rt.operation.FunctionOp; +import org.apache.skywalking.mqe.rt.type.ExpressionResult; +import org.apache.skywalking.mqe.rt.exception.IllegalExpressionException; +import org.apache.skywalking.mqe.rt.type.ExpressionResultType; +import org.apache.skywalking.mqe.rt.type.MQEValue; +import org.apache.skywalking.mqe.rt.type.MQEValues; +import org.apache.skywalking.oap.server.core.Const; +import org.apache.skywalking.oap.server.library.util.StringUtil; + +@Slf4j +public abstract class MQEVisitorBase extends MQEParserBaseVisitor { + + @Override + public ExpressionResult visitAddSubOp(MQEParser.AddSubOpContext ctx) { + ExpressionResult left = visit(ctx.expression(0)); + if (StringUtil.isNotBlank(left.getError())) { + return left; + } + ExpressionResult right = visit(ctx.expression(1)); + if (StringUtil.isNotBlank(right.getError())) { + return right; + } + int opType = ctx.addSub().getStart().getType(); + try { + return BinaryOp.doBinaryOp(left, right, opType); + } catch (IllegalExpressionException e) { + ExpressionResult result = new ExpressionResult(); + result.setType(ExpressionResultType.UNKNOWN); + result.setError(e.getMessage()); + return result; + } + } + + @Override + public ExpressionResult visitMulDivModOp(MQEParser.MulDivModOpContext ctx) { + ExpressionResult left = visit(ctx.expression(0)); + if (StringUtil.isNotBlank(left.getError())) { + return left; + } + ExpressionResult right = visit(ctx.expression(1)); + if (StringUtil.isNotBlank(right.getError())) { + return right; + } + int opType = ctx.mulDivMod().getStart().getType(); + try { + return BinaryOp.doBinaryOp(left, right, opType); + } catch (IllegalExpressionException e) { + ExpressionResult result = new ExpressionResult(); + result.setType(ExpressionResultType.UNKNOWN); + result.setError(e.getMessage()); + return result; + } + } + + @Override + public ExpressionResult visitScalar(MQEParser.ScalarContext ctx) { + ExpressionResult result = new ExpressionResult(); + double value = Double.parseDouble(ctx.getText()); + MQEValue mqeValue = new MQEValue(); + mqeValue.setDoubleValue(value); + mqeValue.setEmptyValue(false); + MQEValues mqeValues = new MQEValues(); + mqeValues.getValues().add(mqeValue); + result.getResults().add(mqeValues); + result.setType(ExpressionResultType.SINGLE_VALUE); + return result; + } + + @Override + public ExpressionResult visitAggregationOp(MQEParser.AggregationOpContext ctx) { + int opType = ctx.aggregation().getStart().getType(); + ExpressionResult expResult = visit(ctx.expression()); + if (StringUtil.isNotEmpty(expResult.getError())) { + return expResult; + } + try { + return AggregationOp.doAggregationOp(expResult, opType); + } catch (IllegalExpressionException e) { + ExpressionResult result = new ExpressionResult(); + result.setType(ExpressionResultType.UNKNOWN); + result.setError(e.getMessage()); + return result; + } + } + + @Override + public ExpressionResult visitAggregateLabelsOp(final MQEParser.AggregateLabelsOpContext ctx) { + int funcType = ctx.aggregateLabelsFunc().getStart().getType(); + ExpressionResult expResult = visit(ctx.expression()); + if (StringUtil.isNotEmpty(expResult.getError())) { + return expResult; + } + + if (!expResult.isLabeledResult()) { + expResult.setError("The result of expression [" + ctx.expression().getText() + "] is not a labeled result."); + return expResult; + } + + try { + return AggregateLabelsOp.doAggregateLabelsOp(expResult, funcType); + } catch (IllegalExpressionException e) { + ExpressionResult result = new ExpressionResult(); + result.setType(ExpressionResultType.UNKNOWN); + result.setError(e.getMessage()); + return result; + } + } + + @Override + public ExpressionResult visitFunction0OP(MQEParser.Function0OPContext ctx) { + int opType = ctx.function0().getStart().getType(); + ExpressionResult expResult = visit(ctx.expression()); + if (StringUtil.isNotEmpty(expResult.getError())) { + return expResult; + } + try { + return FunctionOp.doFunction0Op(expResult, opType); + } catch (IllegalExpressionException e) { + ExpressionResult result = new ExpressionResult(); + result.setType(ExpressionResultType.UNKNOWN); + result.setError(e.getMessage()); + return result; + } + } + + @Override + public ExpressionResult visitFunction1OP(MQEParser.Function1OPContext ctx) { + int opType = ctx.function1().getStart().getType(); + ExpressionResult expResult = visit(ctx.expression()); + if (StringUtil.isNotEmpty(expResult.getError())) { + return expResult; + } + try { + return FunctionOp.doFunction1Op(expResult, opType, Integer.parseInt(ctx.parameter().INTEGER().getText())); + } catch (IllegalExpressionException e) { + ExpressionResult result = new ExpressionResult(); + result.setType(ExpressionResultType.UNKNOWN); + result.setError(e.getMessage()); + return result; + } + } + + @Override + public ExpressionResult visitTopNOP(MQEParser.TopNOPContext ctx) { + return visit(ctx.metric()); + } + + @Override + public ExpressionResult visitRelablesOP(MQEParser.RelablesOPContext ctx) { + ExpressionResult result = visit(ctx.expression()); + if (!result.isLabeledResult()) { + // Reserve the original result type + result.setError("The result of expression [" + ctx.expression().getText() + "] is not a labeled result."); + return result; + } + + List relabelList = Collections.emptyList(); + String newLabelValue = ctx.label().labelValue().getText(); + String labelValueTrim = newLabelValue.substring(1, newLabelValue.length() - 1); + if (StringUtil.isNotBlank(labelValueTrim)) { + relabelList = Arrays.asList(labelValueTrim.split(Const.COMMA)); + } + List mqeValuesList = result.getResults(); + + if (mqeValuesList.size() != relabelList.size()) { + // Reserve the original result type + result.setError("The number of relabels is not equal to the number of labels."); + return result; + } + // For now, we only have a single label named `label` + for (int i = 0; i < mqeValuesList.size(); i++) { + mqeValuesList.get(i).getMetric().getLabels().get(0).setValue(relabelList.get(i)); + } + + return result; + } + + @Override + public abstract ExpressionResult visitMetric(MQEParser.MetricContext ctx); +} diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/exception/IllegalExpressionException.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/exception/IllegalExpressionException.java similarity index 93% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/exception/IllegalExpressionException.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/exception/IllegalExpressionException.java index ace094e759..69bf06c5a1 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/exception/IllegalExpressionException.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/exception/IllegalExpressionException.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe.rt.exception; +package org.apache.skywalking.mqe.rt.exception; public class IllegalExpressionException extends Exception { public IllegalExpressionException(String message) { diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/exception/ParseErrorListener.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/exception/ParseErrorListener.java similarity index 91% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/exception/ParseErrorListener.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/exception/ParseErrorListener.java index 1213458727..25105db327 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/exception/ParseErrorListener.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/exception/ParseErrorListener.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe.rt.exception; +package org.apache.skywalking.mqe.rt.exception; -import graphql.org.antlr.v4.runtime.misc.ParseCancellationException; +import org.antlr.v4.runtime.misc.ParseCancellationException; import org.antlr.v4.runtime.BaseErrorListener; import org.antlr.v4.runtime.RecognitionException; import org.antlr.v4.runtime.Recognizer; diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/AggregateLabelsOp.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/AggregateLabelsOp.java similarity index 75% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/AggregateLabelsOp.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/AggregateLabelsOp.java index 617894eb71..7ae816a84c 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/AggregateLabelsOp.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/AggregateLabelsOp.java @@ -16,22 +16,22 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe.rt.operation; +package org.apache.skywalking.mqe.rt.operation; import java.util.Collections; import java.util.List; +import org.apache.skywalking.mqe.rt.exception.IllegalExpressionException; import org.apache.skywalking.mqe.rt.grammar.MQEParser; -import org.apache.skywalking.oap.query.graphql.mqe.rt.exception.IllegalExpressionException; -import org.apache.skywalking.oap.query.graphql.mqe.rt.operation.aggregatelabels.AggregateLabelsFunc; -import org.apache.skywalking.oap.query.graphql.mqe.rt.operation.aggregatelabels.AggregateLabelsFuncFactory; -import org.apache.skywalking.oap.query.graphql.mqe.rt.operation.aggregatelabels.AvgAggregateLabelsFunc; -import org.apache.skywalking.oap.query.graphql.mqe.rt.operation.aggregatelabels.MaxAggregateLabelsFunc; -import org.apache.skywalking.oap.query.graphql.mqe.rt.operation.aggregatelabels.MinAggregateLabelsFunc; -import org.apache.skywalking.oap.query.graphql.mqe.rt.operation.aggregatelabels.SumAggregateLabelsFunc; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResult; -import org.apache.skywalking.oap.query.graphql.type.mql.MQEValue; -import org.apache.skywalking.oap.query.graphql.type.mql.MQEValues; -import org.apache.skywalking.oap.query.graphql.type.mql.Metadata; +import org.apache.skywalking.mqe.rt.type.ExpressionResult; +import org.apache.skywalking.mqe.rt.type.MQEValue; +import org.apache.skywalking.mqe.rt.type.MQEValues; +import org.apache.skywalking.mqe.rt.operation.aggregatelabels.AggregateLabelsFunc; +import org.apache.skywalking.mqe.rt.operation.aggregatelabels.AggregateLabelsFuncFactory; +import org.apache.skywalking.mqe.rt.operation.aggregatelabels.AvgAggregateLabelsFunc; +import org.apache.skywalking.mqe.rt.operation.aggregatelabels.MaxAggregateLabelsFunc; +import org.apache.skywalking.mqe.rt.operation.aggregatelabels.MinAggregateLabelsFunc; +import org.apache.skywalking.mqe.rt.operation.aggregatelabels.SumAggregateLabelsFunc; +import org.apache.skywalking.mqe.rt.type.Metadata; import org.apache.skywalking.oap.server.library.util.CollectionUtils; public class AggregateLabelsOp { diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/AggregationOp.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/AggregationOp.java similarity index 93% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/AggregationOp.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/AggregationOp.java index 45b440dd41..aa034c27bf 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/AggregationOp.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/AggregationOp.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe.rt.operation; +package org.apache.skywalking.mqe.rt.operation; import com.google.common.collect.Streams; import java.util.ArrayList; @@ -27,11 +27,11 @@ import java.util.OptionalDouble; import java.util.function.Function; import java.util.stream.DoubleStream; import org.apache.skywalking.mqe.rt.grammar.MQEParser; -import org.apache.skywalking.oap.query.graphql.mqe.rt.exception.IllegalExpressionException; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResult; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResultType; -import org.apache.skywalking.oap.query.graphql.type.mql.MQEValue; -import org.apache.skywalking.oap.query.graphql.type.mql.MQEValues; +import org.apache.skywalking.mqe.rt.type.ExpressionResult; +import org.apache.skywalking.mqe.rt.exception.IllegalExpressionException; +import org.apache.skywalking.mqe.rt.type.ExpressionResultType; +import org.apache.skywalking.mqe.rt.type.MQEValue; +import org.apache.skywalking.mqe.rt.type.MQEValues; public class AggregationOp { public static ExpressionResult doAggregationOp(ExpressionResult result, diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/BinaryOp.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/BinaryOp.java similarity index 95% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/BinaryOp.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/BinaryOp.java index ad6ce003e8..369c41c1e6 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/BinaryOp.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/BinaryOp.java @@ -16,17 +16,17 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe.rt.operation; +package org.apache.skywalking.mqe.rt.operation; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.skywalking.mqe.rt.exception.IllegalExpressionException; import org.apache.skywalking.mqe.rt.grammar.MQEParser; -import org.apache.skywalking.oap.query.graphql.mqe.rt.exception.IllegalExpressionException; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResult; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResultType; -import org.apache.skywalking.oap.query.graphql.type.mql.MQEValue; -import org.apache.skywalking.oap.query.graphql.type.mql.MQEValues; +import org.apache.skywalking.mqe.rt.type.ExpressionResult; +import org.apache.skywalking.mqe.rt.type.ExpressionResultType; +import org.apache.skywalking.mqe.rt.type.MQEValue; +import org.apache.skywalking.mqe.rt.type.MQEValues; import org.apache.skywalking.oap.server.core.query.type.KeyValue; public class BinaryOp { diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/FunctionOp.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/FunctionOp.java similarity index 92% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/FunctionOp.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/FunctionOp.java index da5f5953e6..8e033a27fd 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/FunctionOp.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/FunctionOp.java @@ -16,14 +16,14 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe.rt.operation; +package org.apache.skywalking.mqe.rt.operation; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.function.Function; +import org.apache.skywalking.mqe.rt.exception.IllegalExpressionException; import org.apache.skywalking.mqe.rt.grammar.MQEParser; -import org.apache.skywalking.oap.query.graphql.mqe.rt.exception.IllegalExpressionException; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResult; +import org.apache.skywalking.mqe.rt.type.ExpressionResult; public class FunctionOp { public static ExpressionResult doFunction0Op(ExpressionResult expResult, diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/AggregateLabelsFunc.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/AggregateLabelsFunc.java similarity index 91% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/AggregateLabelsFunc.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/AggregateLabelsFunc.java index a5be384cae..17ec1a9cf9 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/AggregateLabelsFunc.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/AggregateLabelsFunc.java @@ -16,10 +16,10 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe.rt.operation.aggregatelabels; +package org.apache.skywalking.mqe.rt.operation.aggregatelabels; public interface AggregateLabelsFunc { void combine(Double value); Double getResult(); -} \ No newline at end of file +} diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/AggregateLabelsFuncFactory.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/AggregateLabelsFuncFactory.java similarity index 91% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/AggregateLabelsFuncFactory.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/AggregateLabelsFuncFactory.java index 861be9067b..2dffbf687f 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/AggregateLabelsFuncFactory.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/AggregateLabelsFuncFactory.java @@ -16,8 +16,8 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe.rt.operation.aggregatelabels; +package org.apache.skywalking.mqe.rt.operation.aggregatelabels; public interface AggregateLabelsFuncFactory { AggregateLabelsFunc getAggregateLabelsFunc(); -} \ No newline at end of file +} diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/AvgAggregateLabelsFunc.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/AvgAggregateLabelsFunc.java similarity index 94% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/AvgAggregateLabelsFunc.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/AvgAggregateLabelsFunc.java index c9775d307f..b20973eefb 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/AvgAggregateLabelsFunc.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/AvgAggregateLabelsFunc.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe.rt.operation.aggregatelabels; +package org.apache.skywalking.mqe.rt.operation.aggregatelabels; public class AvgAggregateLabelsFunc implements AggregateLabelsFunc { @@ -46,4 +46,4 @@ public class AvgAggregateLabelsFunc implements AggregateLabelsFunc { return sum / count; } -} \ No newline at end of file +} diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/MaxAggregateLabelsFunc.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/MaxAggregateLabelsFunc.java similarity index 93% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/MaxAggregateLabelsFunc.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/MaxAggregateLabelsFunc.java index 7da0e2e39e..acce5d6ecb 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/MaxAggregateLabelsFunc.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/MaxAggregateLabelsFunc.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe.rt.operation.aggregatelabels; +package org.apache.skywalking.mqe.rt.operation.aggregatelabels; public class MaxAggregateLabelsFunc implements AggregateLabelsFunc { @@ -41,4 +41,4 @@ public class MaxAggregateLabelsFunc implements AggregateLabelsFunc { public Double getResult() { return max; } -} \ No newline at end of file +} diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/MinAggregateLabelsFunc.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/MinAggregateLabelsFunc.java similarity index 93% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/MinAggregateLabelsFunc.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/MinAggregateLabelsFunc.java index 9fce89148f..789b8d40e5 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/MinAggregateLabelsFunc.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/MinAggregateLabelsFunc.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe.rt.operation.aggregatelabels; +package org.apache.skywalking.mqe.rt.operation.aggregatelabels; public class MinAggregateLabelsFunc implements AggregateLabelsFunc { @@ -41,4 +41,4 @@ public class MinAggregateLabelsFunc implements AggregateLabelsFunc { public Double getResult() { return min; } -} \ No newline at end of file +} diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/SumAggregateLabelsFunc.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/SumAggregateLabelsFunc.java similarity index 93% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/SumAggregateLabelsFunc.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/SumAggregateLabelsFunc.java index 9951633b19..d2fa061d98 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/operation/aggregatelabels/SumAggregateLabelsFunc.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/aggregatelabels/SumAggregateLabelsFunc.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe.rt.operation.aggregatelabels; +package org.apache.skywalking.mqe.rt.operation.aggregatelabels; public class SumAggregateLabelsFunc implements AggregateLabelsFunc { @@ -39,4 +39,4 @@ public class SumAggregateLabelsFunc implements AggregateLabelsFunc { public Double getResult() { return sum; } -} \ No newline at end of file +} diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql/ExpressionResult.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type/ExpressionResult.java similarity index 95% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql/ExpressionResult.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type/ExpressionResult.java index 29348e7d6b..f5c6b94029 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql/ExpressionResult.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type/ExpressionResult.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.skywalking.oap.query.graphql.type.mql; +package org.apache.skywalking.mqe.rt.type; import java.util.ArrayList; import java.util.List; diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql/ExpressionResultType.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type/ExpressionResultType.java similarity index 95% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql/ExpressionResultType.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type/ExpressionResultType.java index 5820e04c62..cb72e903ca 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql/ExpressionResultType.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type/ExpressionResultType.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.skywalking.oap.query.graphql.type.mql; +package org.apache.skywalking.mqe.rt.type; public enum ExpressionResultType { diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql/MQEValue.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type/MQEValue.java similarity index 94% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql/MQEValue.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type/MQEValue.java index d6a7b548fd..f2ed601a49 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql/MQEValue.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type/MQEValue.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.skywalking.oap.query.graphql.type.mql; +package org.apache.skywalking.mqe.rt.type; import lombok.Data; diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql/MQEValues.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type/MQEValues.java similarity index 94% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql/MQEValues.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type/MQEValues.java index fcdcf234e6..64c8c6f1fe 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql/MQEValues.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type/MQEValues.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.skywalking.oap.query.graphql.type.mql; +package org.apache.skywalking.mqe.rt.type; import java.util.ArrayList; import java.util.List; diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql/Metadata.java b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type/Metadata.java similarity index 94% rename from oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql/Metadata.java rename to oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type/Metadata.java index 94dbe95cd8..b23150be91 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/mql/Metadata.java +++ b/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/type/Metadata.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.skywalking.oap.query.graphql.type.mql; +package org.apache.skywalking.mqe.rt.type; import java.util.ArrayList; import java.util.List; diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe/AggregateLabelsOpTest.java b/oap-server/mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt/AggregateLabelsOpTest.java similarity index 90% rename from oap-server/server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe/AggregateLabelsOpTest.java rename to oap-server/mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt/AggregateLabelsOpTest.java index c288328a1e..0255a7e290 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe/AggregateLabelsOpTest.java +++ b/oap-server/mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt/AggregateLabelsOpTest.java @@ -16,12 +16,12 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe; +package org.apache.skywalking.library.mqe.rt; import org.apache.skywalking.mqe.rt.grammar.MQEParser; -import org.apache.skywalking.oap.query.graphql.mqe.rt.operation.AggregateLabelsOp; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResult; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResultType; +import org.apache.skywalking.mqe.rt.operation.AggregateLabelsOp; +import org.apache.skywalking.mqe.rt.type.ExpressionResult; +import org.apache.skywalking.mqe.rt.type.ExpressionResultType; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe/AggregationOpTest.java b/oap-server/mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt/AggregationOpTest.java similarity index 95% rename from oap-server/server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe/AggregationOpTest.java rename to oap-server/mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt/AggregationOpTest.java index 1c271f5cc4..629f1adc36 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe/AggregationOpTest.java +++ b/oap-server/mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt/AggregationOpTest.java @@ -16,12 +16,12 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe; +package org.apache.skywalking.library.mqe.rt; import org.apache.skywalking.mqe.rt.grammar.MQEParser; -import org.apache.skywalking.oap.query.graphql.mqe.rt.operation.AggregationOp; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResult; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResultType; +import org.apache.skywalking.mqe.rt.operation.AggregationOp; +import org.apache.skywalking.mqe.rt.type.ExpressionResult; +import org.apache.skywalking.mqe.rt.type.ExpressionResultType; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe/BinaryOpTest.java b/oap-server/mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt/BinaryOpTest.java similarity index 96% rename from oap-server/server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe/BinaryOpTest.java rename to oap-server/mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt/BinaryOpTest.java index ab24aa1fc8..ba72c37c34 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe/BinaryOpTest.java +++ b/oap-server/mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt/BinaryOpTest.java @@ -16,12 +16,12 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe; +package org.apache.skywalking.library.mqe.rt; import org.apache.skywalking.mqe.rt.grammar.MQEParser; -import org.apache.skywalking.oap.query.graphql.mqe.rt.operation.BinaryOp; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResult; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResultType; +import org.apache.skywalking.mqe.rt.operation.BinaryOp; +import org.apache.skywalking.mqe.rt.type.ExpressionResult; +import org.apache.skywalking.mqe.rt.type.ExpressionResultType; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe/FunctionOpTest.java b/oap-server/mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt/FunctionOpTest.java similarity index 95% rename from oap-server/server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe/FunctionOpTest.java rename to oap-server/mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt/FunctionOpTest.java index 57ab3367e5..ebd0dae476 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe/FunctionOpTest.java +++ b/oap-server/mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt/FunctionOpTest.java @@ -16,12 +16,12 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe; +package org.apache.skywalking.library.mqe.rt; import org.apache.skywalking.mqe.rt.grammar.MQEParser; -import org.apache.skywalking.oap.query.graphql.mqe.rt.operation.FunctionOp; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResult; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResultType; +import org.apache.skywalking.mqe.rt.operation.FunctionOp; +import org.apache.skywalking.mqe.rt.type.ExpressionResult; +import org.apache.skywalking.mqe.rt.type.ExpressionResultType; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe/MockData.java b/oap-server/mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt/MockData.java similarity index 92% rename from oap-server/server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe/MockData.java rename to oap-server/mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt/MockData.java index 578b565430..a09e01c918 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/test/java/org/apache/skywalking/oap/query/graphql/mqe/MockData.java +++ b/oap-server/mqe-rt/src/test/java/org/apache/skywalking/library/mqe/rt/MockData.java @@ -16,13 +16,13 @@ * */ -package org.apache.skywalking.oap.query.graphql.mqe; +package org.apache.skywalking.library.mqe.rt; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResult; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResultType; -import org.apache.skywalking.oap.query.graphql.type.mql.MQEValue; -import org.apache.skywalking.oap.query.graphql.type.mql.MQEValues; -import org.apache.skywalking.oap.query.graphql.type.mql.Metadata; +import org.apache.skywalking.mqe.rt.type.ExpressionResult; +import org.apache.skywalking.mqe.rt.type.ExpressionResultType; +import org.apache.skywalking.mqe.rt.type.MQEValue; +import org.apache.skywalking.mqe.rt.type.MQEValues; +import org.apache.skywalking.mqe.rt.type.Metadata; import org.apache.skywalking.oap.server.core.query.type.KeyValue; public class MockData { diff --git a/oap-server/pom.xml b/oap-server/pom.xml index b8be0eabab..942a44816c 100755 --- a/oap-server/pom.xml +++ b/oap-server/pom.xml @@ -48,6 +48,8 @@ server-health-checker microbench ai-pipeline + mqe-grammar + mqe-rt diff --git a/oap-server/server-query-plugin/pom.xml b/oap-server/server-query-plugin/pom.xml index 1342740608..99a133db7f 100644 --- a/oap-server/server-query-plugin/pom.xml +++ b/oap-server/server-query-plugin/pom.xml @@ -30,7 +30,6 @@ query-graphql-plugin zipkin-query-plugin - mqe-grammar promql-plugin logql-plugin diff --git a/oap-server/server-query-plugin/query-graphql-plugin/pom.xml b/oap-server/server-query-plugin/query-graphql-plugin/pom.xml index 032ddacd83..e53da71906 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/pom.xml +++ b/oap-server/server-query-plugin/query-graphql-plugin/pom.xml @@ -45,7 +45,7 @@ org.apache.skywalking - mqe-grammar + mqe-rt ${project.version} diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/MQEVisitor.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/MQEVisitor.java index 9195da5ee4..0dd33bdc59 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/MQEVisitor.java +++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/mqe/rt/MQEVisitor.java @@ -25,16 +25,13 @@ import java.util.Collections; import java.util.List; import java.util.Optional; import lombok.extern.slf4j.Slf4j; -import org.apache.skywalking.oap.query.graphql.mqe.rt.exception.IllegalExpressionException; -import org.apache.skywalking.oap.query.graphql.mqe.rt.operation.AggregateLabelsOp; -import org.apache.skywalking.oap.query.graphql.mqe.rt.operation.AggregationOp; +import org.apache.skywalking.mqe.rt.exception.IllegalExpressionException; +import org.apache.skywalking.mqe.rt.grammar.MQEParser; +import org.apache.skywalking.mqe.rt.type.MQEValue; +import org.apache.skywalking.mqe.rt.type.MQEValues; +import org.apache.skywalking.mqe.rt.type.Metadata; import org.apache.skywalking.oap.query.graphql.resolver.MetricsQuery; import org.apache.skywalking.oap.query.graphql.resolver.RecordsQuery; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResult; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResultType; -import org.apache.skywalking.oap.query.graphql.type.mql.MQEValue; -import org.apache.skywalking.oap.query.graphql.type.mql.MQEValues; -import org.apache.skywalking.oap.query.graphql.type.mql.Metadata; import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.query.DurationUtils; import org.apache.skywalking.oap.server.core.query.PointOfTime; @@ -52,15 +49,12 @@ import org.apache.skywalking.oap.server.core.query.type.SelectedRecord; import org.apache.skywalking.oap.server.core.storage.annotation.Column; import org.apache.skywalking.oap.server.core.storage.annotation.ValueColumnMetadata; import org.apache.skywalking.oap.server.library.util.StringUtil; -import org.apache.skywalking.mqe.rt.grammar.MQEParser; -import org.apache.skywalking.mqe.rt.grammar.MQEParserBaseVisitor; - -import static org.apache.skywalking.oap.query.graphql.mqe.rt.operation.BinaryOp.doBinaryOp; -import static org.apache.skywalking.oap.query.graphql.mqe.rt.operation.FunctionOp.doFunction0Op; -import static org.apache.skywalking.oap.query.graphql.mqe.rt.operation.FunctionOp.doFunction1Op; +import org.apache.skywalking.mqe.rt.MQEVisitorBase; +import org.apache.skywalking.mqe.rt.type.ExpressionResult; +import org.apache.skywalking.mqe.rt.type.ExpressionResultType; @Slf4j -public class MQEVisitor extends MQEParserBaseVisitor { +public class MQEVisitor extends MQEVisitorBase { private final MetricsQuery metricsQuery; private final RecordsQuery recordsQuery; private final Entity entity; @@ -78,171 +72,6 @@ public class MQEVisitor extends MQEParserBaseVisitor { this.duration = duration; } - @Override - public ExpressionResult visitAddSubOp(MQEParser.AddSubOpContext ctx) { - ExpressionResult left = visit(ctx.expression(0)); - if (StringUtil.isNotBlank(left.getError())) { - return left; - } - ExpressionResult right = visit(ctx.expression(1)); - if (StringUtil.isNotBlank(right.getError())) { - return right; - } - int opType = ctx.addSub().getStart().getType(); - try { - return doBinaryOp(left, right, opType); - } catch (IllegalExpressionException e) { - ExpressionResult result = new ExpressionResult(); - result.setType(ExpressionResultType.UNKNOWN); - result.setError(e.getMessage()); - return result; - } - } - - @Override - public ExpressionResult visitMulDivModOp(MQEParser.MulDivModOpContext ctx) { - ExpressionResult left = visit(ctx.expression(0)); - if (StringUtil.isNotBlank(left.getError())) { - return left; - } - ExpressionResult right = visit(ctx.expression(1)); - if (StringUtil.isNotBlank(right.getError())) { - return right; - } - int opType = ctx.mulDivMod().getStart().getType(); - try { - return doBinaryOp(left, right, opType); - } catch (IllegalExpressionException e) { - ExpressionResult result = new ExpressionResult(); - result.setType(ExpressionResultType.UNKNOWN); - result.setError(e.getMessage()); - return result; - } - } - - @Override - public ExpressionResult visitScalar(MQEParser.ScalarContext ctx) { - ExpressionResult result = new ExpressionResult(); - double value = Double.parseDouble(ctx.getText()); - MQEValue mqeValue = new MQEValue(); - mqeValue.setDoubleValue(value); - mqeValue.setEmptyValue(false); - MQEValues mqeValues = new MQEValues(); - mqeValues.getValues().add(mqeValue); - result.getResults().add(mqeValues); - result.setType(ExpressionResultType.SINGLE_VALUE); - return result; - } - - @Override - public ExpressionResult visitAggregationOp(MQEParser.AggregationOpContext ctx) { - int opType = ctx.aggregation().getStart().getType(); - ExpressionResult expResult = visit(ctx.expression()); - if (StringUtil.isNotEmpty(expResult.getError())) { - return expResult; - } - try { - return AggregationOp.doAggregationOp(expResult, opType); - } catch (IllegalExpressionException e) { - ExpressionResult result = new ExpressionResult(); - result.setType(ExpressionResultType.UNKNOWN); - result.setError(e.getMessage()); - return result; - } - } - - @Override - public ExpressionResult visitAggregateLabelsOp(final MQEParser.AggregateLabelsOpContext ctx) { - int funcType = ctx.aggregateLabelsFunc().getStart().getType(); - ExpressionResult expResult = visit(ctx.expression()); - if (StringUtil.isNotEmpty(expResult.getError())) { - return expResult; - } - - if (!expResult.isLabeledResult()) { - expResult.setError("The result of expression [" + ctx.expression().getText() + "] is not a labeled result."); - return expResult; - } - - try { - return AggregateLabelsOp.doAggregateLabelsOp(expResult, funcType); - } catch (IllegalExpressionException e) { - ExpressionResult result = new ExpressionResult(); - result.setType(ExpressionResultType.UNKNOWN); - result.setError(e.getMessage()); - return result; - } - } - - @Override - public ExpressionResult visitFunction0OP(MQEParser.Function0OPContext ctx) { - int opType = ctx.function0().getStart().getType(); - ExpressionResult expResult = visit(ctx.expression()); - if (StringUtil.isNotEmpty(expResult.getError())) { - return expResult; - } - try { - return doFunction0Op(expResult, opType); - } catch (IllegalExpressionException e) { - ExpressionResult result = new ExpressionResult(); - result.setType(ExpressionResultType.UNKNOWN); - result.setError(e.getMessage()); - return result; - } - } - - @Override - public ExpressionResult visitFunction1OP(MQEParser.Function1OPContext ctx) { - int opType = ctx.function1().getStart().getType(); - ExpressionResult expResult = visit(ctx.expression()); - if (StringUtil.isNotEmpty(expResult.getError())) { - return expResult; - } - try { - return doFunction1Op(expResult, opType, Integer.parseInt(ctx.parameter().INTEGER().getText())); - } catch (IllegalExpressionException e) { - ExpressionResult result = new ExpressionResult(); - result.setType(ExpressionResultType.UNKNOWN); - result.setError(e.getMessage()); - return result; - } - } - - @Override - public ExpressionResult visitTopNOP(MQEParser.TopNOPContext ctx) { - return visit(ctx.metric()); - } - - @Override - public ExpressionResult visitRelablesOP(MQEParser.RelablesOPContext ctx) { - ExpressionResult result = visit(ctx.expression()); - if (!result.isLabeledResult()) { - // Reserve the original result type - result.setError("The result of expression [" + ctx.expression().getText() + "] is not a labeled result."); - return result; - } - - List relabelList = Collections.emptyList(); - String newLabelValue = ctx.label().labelValue().getText(); - String labelValueTrim = newLabelValue.substring(1, newLabelValue.length() - 1); - if (StringUtil.isNotBlank(labelValueTrim)) { - relabelList = Arrays.asList(labelValueTrim.split(Const.COMMA)); - } - List mqeValuesList = result.getResults(); - - if (mqeValuesList.size() != relabelList.size()) { - // Resever the original result type - result.setError("The number of relabels is not equal to the number of labels."); - return result; - } - // For now, we only have a single label named `label` - for (int i = 0; i < mqeValuesList.size(); i++) { - mqeValuesList.get(i).getMetric().getLabels().get(0).setValue(relabelList.get(i)); - } - - return result; - } - @Override public ExpressionResult visitMetric(MQEParser.MetricContext ctx) { ExpressionResult result = new ExpressionResult(); diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricsExpressionQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricsExpressionQuery.java index 2a485d3c81..e10c71465e 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricsExpressionQuery.java +++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricsExpressionQuery.java @@ -25,9 +25,9 @@ import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.tree.ParseTree; import org.apache.skywalking.oap.query.graphql.mqe.rt.MQEVisitor; -import org.apache.skywalking.oap.query.graphql.mqe.rt.exception.ParseErrorListener; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResult; -import org.apache.skywalking.oap.query.graphql.type.mql.ExpressionResultType; +import org.apache.skywalking.mqe.rt.exception.ParseErrorListener; +import org.apache.skywalking.mqe.rt.type.ExpressionResult; +import org.apache.skywalking.mqe.rt.type.ExpressionResultType; import org.apache.skywalking.oap.server.core.query.input.Entity; import org.apache.skywalking.oap.server.core.query.input.Duration; import org.apache.skywalking.oap.server.library.module.ModuleManager;