Search in sources :

Example 1 with ValueValueType

use of com.alibaba.maxgraph.compiler.tree.value.ValueValueType in project GraphScope by alibaba.

the class SumTreeNode method buildLogicalQueryPlan.

@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
    TreeNodeLabelManager labelManager = contextManager.getTreeNodeLabelManager();
    VertexIdManager vertexIdManager = contextManager.getVertexIdManager();
    QueryFlowOuterClass.OperatorType operatorType = getUseKeyOperator(QueryFlowOuterClass.OperatorType.SUM);
    LogicalSubQueryPlan logicalSubQueryPlan = new LogicalSubQueryPlan(contextManager);
    LogicalVertex sourceVertex = getInputNode().getOutputVertex();
    logicalSubQueryPlan.addLogicalVertex(sourceVertex);
    ValueValueType valueValueType = ValueValueType.class.cast(getInputNode().getOutputValueType());
    ProcessorFunction combinerSumFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.COMBINER_SUM, Message.Value.newBuilder().setValueType(valueValueType.getDataType()));
    LogicalVertex combinerSumVertex = new LogicalUnaryVertex(vertexIdManager.getId(), combinerSumFunction, isPropLocalFlag(), sourceVertex);
    logicalSubQueryPlan.addLogicalVertex(combinerSumVertex);
    logicalSubQueryPlan.addLogicalEdge(sourceVertex, combinerSumVertex, LogicalEdge.forwardEdge());
    ProcessorFunction sumFunction = new ProcessorFunction(operatorType, Message.Value.newBuilder().setValueType(valueValueType.getDataType()));
    LogicalVertex sumVertex = new LogicalUnaryVertex(vertexIdManager.getId(), sumFunction, isPropLocalFlag(), combinerSumVertex);
    logicalSubQueryPlan.addLogicalVertex(sumVertex);
    logicalSubQueryPlan.addLogicalEdge(combinerSumVertex, sumVertex, new LogicalEdge());
    LogicalVertex outputVertex = processJoinZeroVertex(vertexIdManager, logicalSubQueryPlan, sumVertex, isJoinZeroFlag());
    setFinishVertex(outputVertex, labelManager);
    return logicalSubQueryPlan;
}
Also used : LogicalUnaryVertex(com.alibaba.maxgraph.compiler.logical.LogicalUnaryVertex) LogicalVertex(com.alibaba.maxgraph.compiler.logical.LogicalVertex) ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) LogicalEdge(com.alibaba.maxgraph.compiler.logical.LogicalEdge) QueryFlowOuterClass(com.alibaba.maxgraph.QueryFlowOuterClass) ValueValueType(com.alibaba.maxgraph.compiler.tree.value.ValueValueType) VertexIdManager(com.alibaba.maxgraph.compiler.logical.VertexIdManager) LogicalSubQueryPlan(com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)

Example 2 with ValueValueType

use of com.alibaba.maxgraph.compiler.tree.value.ValueValueType in project GraphScope by alibaba.

the class MaxTreeNode method buildLogicalQueryPlan.

@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
    LogicalSubQueryPlan logicalSubQueryPlan = new LogicalSubQueryPlan(contextManager);
    LogicalVertex sourceVertex = getInputNode().getOutputVertex();
    logicalSubQueryPlan.addLogicalVertex(sourceVertex);
    ValueValueType valueValueType = ValueValueType.class.cast(getInputNode().getOutputValueType());
    QueryFlowOuterClass.OperatorType operatorType = getUseKeyOperator(QueryFlowOuterClass.OperatorType.MAX);
    ProcessorFunction maxFunction = new ProcessorFunction(operatorType, Message.Value.newBuilder().setValueType(valueValueType.getDataType()));
    LogicalUnaryVertex maxVertex = new LogicalUnaryVertex(contextManager.getVertexIdManager().getId(), maxFunction, isPropLocalFlag(), sourceVertex);
    logicalSubQueryPlan.addLogicalVertex(maxVertex);
    logicalSubQueryPlan.addLogicalEdge(sourceVertex, maxVertex, new LogicalEdge());
    setFinishVertex(maxVertex, contextManager.getTreeNodeLabelManager());
    addUsedLabelAndRequirement(maxVertex, contextManager.getTreeNodeLabelManager());
    return logicalSubQueryPlan;
}
Also used : LogicalUnaryVertex(com.alibaba.maxgraph.compiler.logical.LogicalUnaryVertex) LogicalVertex(com.alibaba.maxgraph.compiler.logical.LogicalVertex) ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) LogicalEdge(com.alibaba.maxgraph.compiler.logical.LogicalEdge) ValueValueType(com.alibaba.maxgraph.compiler.tree.value.ValueValueType) QueryFlowOuterClass(com.alibaba.maxgraph.QueryFlowOuterClass) LogicalSubQueryPlan(com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)

Example 3 with ValueValueType

use of com.alibaba.maxgraph.compiler.tree.value.ValueValueType in project GraphScope by alibaba.

the class MinTreeNode method buildLogicalQueryPlan.

@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
    LogicalSubQueryPlan logicalSubQueryPlan = new LogicalSubQueryPlan(contextManager);
    LogicalVertex sourceVertex = getInputNode().getOutputVertex();
    logicalSubQueryPlan.addLogicalVertex(sourceVertex);
    ValueValueType valueValueType = ValueValueType.class.cast(getInputNode().getOutputValueType());
    QueryFlowOuterClass.OperatorType operatorType = getUseKeyOperator(QueryFlowOuterClass.OperatorType.MIN);
    ProcessorFunction minFunction = new ProcessorFunction(operatorType, Message.Value.newBuilder().setValueType(valueValueType.getDataType()));
    LogicalUnaryVertex minVertex = new LogicalUnaryVertex(contextManager.getVertexIdManager().getId(), minFunction, isPropLocalFlag(), sourceVertex);
    logicalSubQueryPlan.addLogicalVertex(minVertex);
    logicalSubQueryPlan.addLogicalEdge(sourceVertex, minVertex, new LogicalEdge());
    setFinishVertex(minVertex, contextManager.getTreeNodeLabelManager());
    addUsedLabelAndRequirement(minVertex, contextManager.getTreeNodeLabelManager());
    return logicalSubQueryPlan;
}
Also used : LogicalUnaryVertex(com.alibaba.maxgraph.compiler.logical.LogicalUnaryVertex) LogicalVertex(com.alibaba.maxgraph.compiler.logical.LogicalVertex) ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) LogicalEdge(com.alibaba.maxgraph.compiler.logical.LogicalEdge) ValueValueType(com.alibaba.maxgraph.compiler.tree.value.ValueValueType) QueryFlowOuterClass(com.alibaba.maxgraph.QueryFlowOuterClass) LogicalSubQueryPlan(com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)

Example 4 with ValueValueType

use of com.alibaba.maxgraph.compiler.tree.value.ValueValueType in project GraphScope by alibaba.

the class TreeBuilder method convertHasContainer.

private HasContainer convertHasContainer(String key, Predicate<?> predicate, ValueType inputValueType) {
    if (null == predicate) {
        return new HasContainer(key, null);
    }
    if (predicate instanceof CustomPredicate) {
        if (StringUtils.isEmpty(key)) {
            checkArgument(inputValueType instanceof ListValueType || inputValueType instanceof ValueValueType, "Output value for predicate must be value while current type=>" + inputValueType);
            PredicateType predicateType = ((CustomPredicate) predicate).getPredicateType();
            Message.VariantType variantType = inputValueType instanceof ListValueType ? Message.VariantType.valueOf(ValueValueType.class.cast(((ListValueType) inputValueType).getListValue()).getDataType().name() + "_LIST") : ValueValueType.class.cast(inputValueType).getDataType();
            validPredicateVariantType(variantType, predicateType);
            return new HasContainer(key, CustomPredicate.class.cast(predicate));
        } else {
            Set<DataType> dataTypeSet = SchemaUtils.getPropDataTypeList(key, schema);
            if (dataTypeSet.isEmpty()) {
                return new HasContainer(key, CustomPredicate.class.cast(predicate));
            } else {
                if (dataTypeSet.size() > 1) {
                    logger.warn("There's multiple type=>" + dataTypeSet + " for property=>" + key);
                    return new HasContainer(key, CustomPredicate.class.cast(predicate));
                } else {
                    Message.VariantType variantType = CompilerUtils.parseVariantFromDataType(dataTypeSet.iterator().next());
                    PredicateType predicateType = ((CustomPredicate) predicate).getPredicateType();
                    validPredicateVariantType(variantType, predicateType);
                    return new HasContainer(key, CustomPredicate.class.cast(predicate));
                }
            }
        }
    } else {
        if (StringUtils.isEmpty(key)) {
            Message.VariantType variantType = ValueValueType.class.cast(inputValueType).getDataType();
            return createContainerFromVariantyType(key, P.class.cast(predicate), variantType);
        } else {
            Set<DataType> dataTypeSet = SchemaUtils.getPropDataTypeList(key, schema);
            if (dataTypeSet.isEmpty()) {
                return new HasContainer(key, P.class.cast(predicate));
            } else {
                if (dataTypeSet.size() > 1) {
                    logger.warn("There's multiple type=>" + dataTypeSet + " for property=>" + key);
                    return new HasContainer(key, P.class.cast(predicate));
                } else {
                    Message.VariantType variantType = CompilerUtils.parseVariantFromDataType(dataTypeSet.iterator().next());
                    return createContainerFromVariantyType(key, P.class.cast(predicate), variantType);
                }
            }
        }
    }
}
Also used : P(org.apache.tinkerpop.gremlin.process.traversal.P) ConnectiveP(org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP) Message(com.alibaba.maxgraph.Message) PredicateType(com.alibaba.maxgraph.sdkcommon.compiler.custom.PredicateType) HasContainer(org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer) ListValueType(com.alibaba.maxgraph.compiler.tree.value.ListValueType) DataType(com.alibaba.maxgraph.compiler.api.schema.DataType) CustomPredicate(com.alibaba.maxgraph.sdkcommon.compiler.custom.CustomPredicate) ValueValueType(com.alibaba.maxgraph.compiler.tree.value.ValueValueType)

Example 5 with ValueValueType

use of com.alibaba.maxgraph.compiler.tree.value.ValueValueType in project GraphScope by alibaba.

the class MixedOpProcessor method newNettyResultProcessor.

private NettyResultProcessor newNettyResultProcessor(String queryId, String script, Context context, Graph graph, GraphSchema schema) {
    NettyVertexRpcProcessor nettyVertexRpcProcessor = new NettyVertexRpcProcessor(context, resultIterationBatchSize, false);
    GremlinResultTransform gremlinResultTransform = new GremlinResultTransform(remoteRpcConnector, nettyVertexRpcProcessor, this.graph, new ListValueType(new ValueValueType(Message.VariantType.VT_STRING)), vertexCacheFlag);
    NettyResultProcessor nettyResultProcessor = new NettyResultProcessor(queryId, script, context, executeConfig.getBatchQuerySize(), resultIterationBatchSize, false);
    nettyResultProcessor.setSchema(schema);
    nettyResultProcessor.setResultTransform(gremlinResultTransform);
    return nettyResultProcessor;
}
Also used : ListValueType(com.alibaba.maxgraph.compiler.tree.value.ListValueType) ValueValueType(com.alibaba.maxgraph.compiler.tree.value.ValueValueType)

Aggregations

ValueValueType (com.alibaba.maxgraph.compiler.tree.value.ValueValueType)7 QueryFlowOuterClass (com.alibaba.maxgraph.QueryFlowOuterClass)3 LogicalEdge (com.alibaba.maxgraph.compiler.logical.LogicalEdge)3 LogicalSubQueryPlan (com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)3 LogicalUnaryVertex (com.alibaba.maxgraph.compiler.logical.LogicalUnaryVertex)3 LogicalVertex (com.alibaba.maxgraph.compiler.logical.LogicalVertex)3 ProcessorFunction (com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction)3 ListValueType (com.alibaba.maxgraph.compiler.tree.value.ListValueType)2 Message (com.alibaba.maxgraph.Message)1 DataType (com.alibaba.maxgraph.compiler.api.schema.DataType)1 VertexIdManager (com.alibaba.maxgraph.compiler.logical.VertexIdManager)1 PropertyNode (com.alibaba.maxgraph.compiler.tree.addition.PropertyNode)1 SourceDelegateNode (com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode)1 SourceTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode)1 SourceVertexTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode)1 EdgeValueType (com.alibaba.maxgraph.compiler.tree.value.EdgeValueType)1 MapValueType (com.alibaba.maxgraph.compiler.tree.value.MapValueType)1 ValueType (com.alibaba.maxgraph.compiler.tree.value.ValueType)1 VarietyValueType (com.alibaba.maxgraph.compiler.tree.value.VarietyValueType)1 CustomPredicate (com.alibaba.maxgraph.sdkcommon.compiler.custom.CustomPredicate)1