Search in sources :

Example 6 with ValueType

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

the class TreeBuilder method visitSelectStep.

private TreeNode visitSelectStep(SelectStep step, TreeNode prev) {
    List<String> selectKeyList = ReflectionUtils.getFieldValue(SelectStep.class, step, "selectKeys");
    Pop pop = step.getPop();
    List<Traversal.Admin<?, ?>> ringTraversalList = step.getLocalChildren();
    if (selectKeyList.size() < 2) {
        throw new IllegalArgumentException("select key size < 2 for select operator");
    }
    Map<String, List<TreeNode>> labelTreeNodeList = Maps.newHashMap();
    selectKeyList.forEach(v -> {
        if (treeNodeLabelManager.getLabelIndexList().containsKey(v)) {
            labelTreeNodeList.put(v, treeNodeLabelManager.getTreeNodeList(v));
        }
    });
    SelectTreeNode selectTreeNode = new SelectTreeNode(prev, selectKeyList, pop, labelTreeNodeList, schema);
    boolean saveFlag = rootPathFlag;
    rootPathFlag = false;
    if (!ringTraversalList.isEmpty()) {
        Set<ValueType> valueTypeList = selectKeyList.stream().map(v -> treeNodeLabelManager.getValueType(v, pop)).collect(Collectors.toSet());
        ValueType selectValueType = valueTypeList.size() > 1 ? new VarietyValueType(valueTypeList) : valueTypeList.iterator().next();
        ringTraversalList.forEach(v -> {
            SourceDelegateNode sourceDelegateNode = new SourceDelegateNode(selectTreeNode, schema);
            sourceDelegateNode.setDelegateOutputValueType(selectValueType);
            selectTreeNode.addTraversalTreeNode(travelTraversalAdmin(v, sourceDelegateNode));
        });
    }
    rootPathFlag = saveFlag;
    return selectTreeNode;
}
Also used : PageRankStep(com.alibaba.maxgraph.tinkerpop.steps.PageRankStep) WherePredicateStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.WherePredicateStep) SampleGlobalStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.SampleGlobalStep) DedupGlobalStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.DedupGlobalStep) Contains(org.apache.tinkerpop.gremlin.process.traversal.Contains) StringUtils(org.apache.commons.lang3.StringUtils) ShortestPathVertexProgramStep(org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ShortestPathVertexProgramStep) OrStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.OrStep) ShortestPathStep(com.alibaba.maxgraph.tinkerpop.steps.ShortestPathStep) ProfileStrategy(org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.ProfileStrategy) Pair(org.apache.commons.lang3.tuple.Pair) UnionStep(org.apache.tinkerpop.gremlin.process.traversal.step.branch.UnionStep) TraversalParent(org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent) OutputVineyardStep(com.alibaba.maxgraph.tinkerpop.steps.OutputVineyardStep) PeerPressureVertexProgramStep(org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.PeerPressureVertexProgramStep) LambdaFilterStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.LambdaFilterStep) org.apache.tinkerpop.gremlin.process.traversal.step.map(org.apache.tinkerpop.gremlin.process.traversal.step.map) TraversalHelper(org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper) VertexRatioProgram(com.alibaba.maxgraph.sdkcommon.compiler.custom.program.VertexRatioProgram) ReflectionUtils(com.alibaba.maxgraph.compiler.utils.ReflectionUtils) RegexPredicate(com.alibaba.maxgraph.sdkcommon.compiler.custom.RegexPredicate) Message(com.alibaba.maxgraph.Message) IsStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.IsStep) CountFlagNode(com.alibaba.maxgraph.compiler.tree.addition.CountFlagNode) ListKeyPredicate(com.alibaba.maxgraph.sdkcommon.compiler.custom.ListKeyPredicate) LabelPropagationStep(com.alibaba.maxgraph.tinkerpop.steps.LabelPropagationStep) SideEffectCapStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectCapStep) GraphSchema(com.alibaba.maxgraph.compiler.api.schema.GraphSchema) SourceTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode) EmptyStep(org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep) java.util(java.util) CustomVertexProgramStep(com.alibaba.maxgraph.tinkerpop.steps.CustomVertexProgramStep) MxGraphStepStrategy(com.alibaba.maxgraph.tinkerpop.strategies.MxGraphStepStrategy) SourceDelegateNode(com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode) AdjacentToIncidentStrategy(org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.AdjacentToIncidentStrategy) StringKeyPredicate(com.alibaba.maxgraph.sdkcommon.compiler.custom.StringKeyPredicate) AllPathStep(com.alibaba.maxgraph.tinkerpop.steps.AllPathStep) VertexValueType(com.alibaba.maxgraph.compiler.tree.value.VertexValueType) Supplier(java.util.function.Supplier) VertexProgram(org.apache.tinkerpop.gremlin.process.computer.VertexProgram) CustomPredicate(com.alibaba.maxgraph.sdkcommon.compiler.custom.CustomPredicate) Lists(com.google.common.collect.Lists) Order(org.apache.tinkerpop.gremlin.process.traversal.Order) ConnectedComponentVertexProgramStep(org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ConnectedComponentVertexProgramStep) EstimateCountTreeNode(com.alibaba.maxgraph.compiler.tree.source.EstimateCountTreeNode) TraversalRing(org.apache.tinkerpop.gremlin.process.traversal.util.TraversalRing) LpaVertexProgramStep(com.alibaba.maxgraph.tinkerpop.steps.LpaVertexProgramStep) ComputerAwareStep(org.apache.tinkerpop.gremlin.process.traversal.step.util.ComputerAwareStep) ListValueType(com.alibaba.maxgraph.compiler.tree.value.ListValueType) PropertyType(org.apache.tinkerpop.gremlin.structure.PropertyType) SourceEdgeTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceEdgeTreeNode) CustomCaseWhenFunction(com.alibaba.maxgraph.sdkcommon.compiler.custom.branch.CustomCaseWhenFunction) StandardVerificationStrategy(org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.StandardVerificationStrategy) CustomAggregationListTraversal(com.alibaba.maxgraph.sdkcommon.compiler.custom.aggregate.CustomAggregationListTraversal) T(org.apache.tinkerpop.gremlin.structure.T) OptimizeConfig(com.alibaba.maxgraph.compiler.optimizer.OptimizeConfig) Direction(org.apache.tinkerpop.gremlin.structure.Direction) IncidentToAdjacentStrategy(org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.IncidentToAdjacentStrategy) Traversal(org.apache.tinkerpop.gremlin.process.traversal.Traversal) SchemaUtils(com.alibaba.maxgraph.sdkcommon.util.SchemaUtils) RangeGlobalStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeGlobalStep) ListPredicate(com.alibaba.maxgraph.sdkcommon.compiler.custom.ListPredicate) HitsVertexProgramStep(com.alibaba.maxgraph.tinkerpop.steps.HitsVertexProgramStep) Pop(org.apache.tinkerpop.gremlin.process.traversal.Pop) LoggerFactory(org.slf4j.LoggerFactory) CreateGraphStep(com.alibaba.maxgraph.tinkerpop.steps.CreateGraphStep) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) RangeSumFunction(com.alibaba.maxgraph.sdkcommon.compiler.custom.map.RangeSumFunction) AggregateLocalStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.AggregateLocalStep) ConnectedComponentsStep(com.alibaba.maxgraph.tinkerpop.steps.ConnectedComponentsStep) org.apache.tinkerpop.gremlin.process.traversal.lambda(org.apache.tinkerpop.gremlin.process.traversal.lambda) RepeatUnrollStrategy(org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.RepeatUnrollStrategy) EstimateCountStep(com.alibaba.maxgraph.tinkerpop.steps.EstimateCountStep) P(org.apache.tinkerpop.gremlin.process.traversal.P) ValueValueType(com.alibaba.maxgraph.compiler.tree.value.ValueValueType) CompilerUtils(com.alibaba.maxgraph.compiler.utils.CompilerUtils) HasContainer(org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer) SourceVertexTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode) Predicate(java.util.function.Predicate) AndStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.AndStep) LazyBarrierStrategy(org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.LazyBarrierStrategy) MapPropFillFunction(com.alibaba.maxgraph.sdkcommon.compiler.custom.map.MapPropFillFunction) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Compare(org.apache.tinkerpop.gremlin.process.traversal.Compare) MaxGraphFilterRankingStrategy(com.alibaba.maxgraph.compiler.strategy.traversal.MaxGraphFilterRankingStrategy) HitsStep(com.alibaba.maxgraph.tinkerpop.steps.HitsStep) SourceCreateGraphTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceCreateGraphTreeNode) EdgeVertexWithByStep(com.alibaba.maxgraph.tinkerpop.steps.EdgeVertexWithByStep) ConnectiveP(org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP) CustomWhenThenFunction(com.alibaba.maxgraph.sdkcommon.compiler.custom.branch.CustomWhenThenFunction) NotImplementedException(org.apache.commons.lang3.NotImplementedException) VertexByModulatingStep(com.alibaba.maxgraph.tinkerpop.steps.VertexByModulatingStep) MaxGraphStep(com.alibaba.maxgraph.tinkerpop.steps.MaxGraphStep) HasStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasStep) PredicateType(com.alibaba.maxgraph.sdkcommon.compiler.custom.PredicateType) TreeNodeUtils(com.alibaba.maxgraph.compiler.utils.TreeNodeUtils) DataType(com.alibaba.maxgraph.compiler.api.schema.DataType) VertexWithByStep(com.alibaba.maxgraph.tinkerpop.steps.VertexWithByStep) PathFilterStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.PathFilterStep) Function(java.util.function.Function) FilterStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep) BiPredicate(java.util.function.BiPredicate) ChooseStep(org.apache.tinkerpop.gremlin.process.traversal.step.branch.ChooseStep) JoinZeroNode(com.alibaba.maxgraph.compiler.tree.addition.JoinZeroNode) MapConfiguration(org.apache.commons.configuration2.MapConfiguration) SampleNode(com.alibaba.maxgraph.compiler.tree.addition.SampleNode) PropertyNode(com.alibaba.maxgraph.compiler.tree.addition.PropertyNode) RegexKeyPredicate(com.alibaba.maxgraph.sdkcommon.compiler.custom.RegexKeyPredicate) Logger(org.slf4j.Logger) NotStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.NotStep) FilterRankingStrategy(org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.FilterRankingStrategy) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) RepeatStep(org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep) ConnectiveStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.ConnectiveStep) TraversalVertexProgramStep(org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.TraversalVertexProgramStep) Maps(com.google.common.collect.Maps) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) PageRankVertexProgramStep(org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.PageRankVertexProgramStep) Step(org.apache.tinkerpop.gremlin.process.traversal.Step) StringPredicate(com.alibaba.maxgraph.sdkcommon.compiler.custom.StringPredicate) IdentityStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IdentityStep) SubgraphStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SubgraphStep) OutputStep(com.alibaba.maxgraph.tinkerpop.steps.OutputStep) TraversalOptionParent(org.apache.tinkerpop.gremlin.process.traversal.step.TraversalOptionParent) TraversalFilterStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.TraversalFilterStep) ValueType(com.alibaba.maxgraph.compiler.tree.value.ValueType) VarietyValueType(com.alibaba.maxgraph.compiler.tree.value.VarietyValueType) BranchStep(org.apache.tinkerpop.gremlin.process.traversal.step.branch.BranchStep) VarietyValueType(com.alibaba.maxgraph.compiler.tree.value.VarietyValueType) VertexValueType(com.alibaba.maxgraph.compiler.tree.value.VertexValueType) ListValueType(com.alibaba.maxgraph.compiler.tree.value.ListValueType) ValueValueType(com.alibaba.maxgraph.compiler.tree.value.ValueValueType) ValueType(com.alibaba.maxgraph.compiler.tree.value.ValueType) VarietyValueType(com.alibaba.maxgraph.compiler.tree.value.VarietyValueType) SourceDelegateNode(com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode) Pop(org.apache.tinkerpop.gremlin.process.traversal.Pop)

Aggregations

ValueType (com.alibaba.maxgraph.compiler.tree.value.ValueType)6 VarietyValueType (com.alibaba.maxgraph.compiler.tree.value.VarietyValueType)5 ListValueType (com.alibaba.maxgraph.compiler.tree.value.ListValueType)4 ValueValueType (com.alibaba.maxgraph.compiler.tree.value.ValueValueType)4 VertexValueType (com.alibaba.maxgraph.compiler.tree.value.VertexValueType)4 EstimateCountTreeNode (com.alibaba.maxgraph.compiler.tree.source.EstimateCountTreeNode)3 SourceCreateGraphTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceCreateGraphTreeNode)3 SourceDelegateNode (com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode)3 SourceEdgeTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceEdgeTreeNode)3 SourceTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode)3 SourceVertexTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode)3 Message (com.alibaba.maxgraph.Message)2 DataType (com.alibaba.maxgraph.compiler.api.schema.DataType)2 GraphSchema (com.alibaba.maxgraph.compiler.api.schema.GraphSchema)2 MapValueType (com.alibaba.maxgraph.compiler.tree.value.MapValueType)2 CustomAggregationListTraversal (com.alibaba.maxgraph.sdkcommon.compiler.custom.aggregate.CustomAggregationListTraversal)2 SchemaUtils (com.alibaba.maxgraph.sdkcommon.util.SchemaUtils)2 QueryFlowOuterClass (com.alibaba.maxgraph.QueryFlowOuterClass)1 GraphEdge (com.alibaba.maxgraph.compiler.api.schema.GraphEdge)1 GraphElement (com.alibaba.maxgraph.compiler.api.schema.GraphElement)1