Search in sources :

Example 1 with ShortestPathVertexProgramStep

use of org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ShortestPathVertexProgramStep in project GraphScope by alibaba.

the class TreeBuilder method visitShortestPathStep.

private TreeNode visitShortestPathStep(ShortestPathVertexProgramStep step, TreeNode prev) {
    Traversal.Admin<?, ?> targetVertexFilter = step.getLocalChildren().get(0);
    Step targetStep = targetVertexFilter.getSteps().get(0);
    if (targetStep instanceof HasStep) {
        List<HasContainer> targetHasContainerList = ((HasStep) targetStep).getHasContainers();
        List<HasContainer> convertContainerList = targetHasContainerList.stream().map(v -> convertHasContainer(v.getKey(), v.getPredicate(), prev.getOutputValueType())).collect(Collectors.toList());
        HasContainer targetHascontainer = convertContainerList.get(0);
        if (prev instanceof SourceTreeNode) {
            List<HasContainer> sourceHasContainerList = ((SourceTreeNode) prev).hasContainerList;
            int idx = sourceHasContainerList.size() - 1;
            if (idx >= 0) {
                HasContainer sourceHasContainer = sourceHasContainerList.get(idx);
                if (targetHascontainer.getKey().equals(sourceHasContainer.getKey())) {
                    HasContainer targetContainer = new HasContainer(targetHascontainer.getKey(), P.within(Lists.newArrayList(sourceHasContainer.getPredicate().getValue(), targetHascontainer.getPredicate().getValue())));
                    ((SourceTreeNode) prev).hasContainerList.set(idx, targetContainer);
                } else {
                    throw new UnsupportedOperationException(targetStep.toString());
                }
            } else {
                // do not support target vertex exists without source vertex
                throw new UnsupportedOperationException(targetStep.toString());
            }
        }
    } else if (targetStep instanceof IdentityStep) {
    } else {
        throw new UnsupportedOperationException(targetStep.toString());
    }
    return new ShortestPathVertexProgramTreeNode(prev, schema, step);
}
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) IdentityStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IdentityStep) HasStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasStep) SourceTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode) HasContainer(org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer) CustomAggregationListTraversal(com.alibaba.maxgraph.sdkcommon.compiler.custom.aggregate.CustomAggregationListTraversal) Traversal(org.apache.tinkerpop.gremlin.process.traversal.Traversal) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) 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) 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) UnionStep(org.apache.tinkerpop.gremlin.process.traversal.step.branch.UnionStep) 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) IsStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.IsStep) LabelPropagationStep(com.alibaba.maxgraph.tinkerpop.steps.LabelPropagationStep) SideEffectCapStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectCapStep) EmptyStep(org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep) CustomVertexProgramStep(com.alibaba.maxgraph.tinkerpop.steps.CustomVertexProgramStep) AllPathStep(com.alibaba.maxgraph.tinkerpop.steps.AllPathStep) ConnectedComponentVertexProgramStep(org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ConnectedComponentVertexProgramStep) LpaVertexProgramStep(com.alibaba.maxgraph.tinkerpop.steps.LpaVertexProgramStep) ComputerAwareStep(org.apache.tinkerpop.gremlin.process.traversal.step.util.ComputerAwareStep) RangeGlobalStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeGlobalStep) HitsVertexProgramStep(com.alibaba.maxgraph.tinkerpop.steps.HitsVertexProgramStep) CreateGraphStep(com.alibaba.maxgraph.tinkerpop.steps.CreateGraphStep) AggregateLocalStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.AggregateLocalStep) ConnectedComponentsStep(com.alibaba.maxgraph.tinkerpop.steps.ConnectedComponentsStep) EstimateCountStep(com.alibaba.maxgraph.tinkerpop.steps.EstimateCountStep) AndStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.AndStep) HitsStep(com.alibaba.maxgraph.tinkerpop.steps.HitsStep) EdgeVertexWithByStep(com.alibaba.maxgraph.tinkerpop.steps.EdgeVertexWithByStep) VertexByModulatingStep(com.alibaba.maxgraph.tinkerpop.steps.VertexByModulatingStep) MaxGraphStep(com.alibaba.maxgraph.tinkerpop.steps.MaxGraphStep) HasStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasStep) VertexWithByStep(com.alibaba.maxgraph.tinkerpop.steps.VertexWithByStep) PathFilterStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.PathFilterStep) FilterStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep) ChooseStep(org.apache.tinkerpop.gremlin.process.traversal.step.branch.ChooseStep) NotStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.NotStep) 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) PageRankVertexProgramStep(org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.PageRankVertexProgramStep) Step(org.apache.tinkerpop.gremlin.process.traversal.Step) 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) TraversalFilterStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.TraversalFilterStep) BranchStep(org.apache.tinkerpop.gremlin.process.traversal.step.branch.BranchStep)

Aggregations

Message (com.alibaba.maxgraph.Message)1 DataType (com.alibaba.maxgraph.compiler.api.schema.DataType)1 GraphSchema (com.alibaba.maxgraph.compiler.api.schema.GraphSchema)1 OptimizeConfig (com.alibaba.maxgraph.compiler.optimizer.OptimizeConfig)1 MaxGraphFilterRankingStrategy (com.alibaba.maxgraph.compiler.strategy.traversal.MaxGraphFilterRankingStrategy)1 CountFlagNode (com.alibaba.maxgraph.compiler.tree.addition.CountFlagNode)1 JoinZeroNode (com.alibaba.maxgraph.compiler.tree.addition.JoinZeroNode)1 PropertyNode (com.alibaba.maxgraph.compiler.tree.addition.PropertyNode)1 SampleNode (com.alibaba.maxgraph.compiler.tree.addition.SampleNode)1 EstimateCountTreeNode (com.alibaba.maxgraph.compiler.tree.source.EstimateCountTreeNode)1 SourceCreateGraphTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceCreateGraphTreeNode)1 SourceDelegateNode (com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode)1 SourceEdgeTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceEdgeTreeNode)1 SourceTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode)1 SourceVertexTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode)1 ListValueType (com.alibaba.maxgraph.compiler.tree.value.ListValueType)1 ValueType (com.alibaba.maxgraph.compiler.tree.value.ValueType)1 ValueValueType (com.alibaba.maxgraph.compiler.tree.value.ValueValueType)1 VarietyValueType (com.alibaba.maxgraph.compiler.tree.value.VarietyValueType)1 VertexValueType (com.alibaba.maxgraph.compiler.tree.value.VertexValueType)1