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;
}
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;
}
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;
}
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);
}
}
}
}
}
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;
}
Aggregations