Search in sources :

Example 1 with MaxGraphTraversalSource

use of com.alibaba.maxgraph.tinkerpop.traversal.MaxGraphTraversalSource in project GraphScope by alibaba.

the class MaxTestGraph method traversal.

@Override
public GraphTraversalSource traversal() {
    MaxGraphTraversalSource source = AnonymousTraversalSource.traversal(MaxGraphTraversalSource.class).withRemote(remoteConnection);
    source.getStrategies().removeStrategies(ProfileStrategy.class, FilterRankingStrategy.class);
    return source;
}
Also used : MaxGraphTraversalSource(com.alibaba.maxgraph.tinkerpop.traversal.MaxGraphTraversalSource)

Example 2 with MaxGraphTraversalSource

use of com.alibaba.maxgraph.tinkerpop.traversal.MaxGraphTraversalSource in project GraphScope by alibaba.

the class RemoteTestGraph method traversal.

@Override
public GraphTraversalSource traversal() {
    MaxGraphTraversalSource source = AnonymousTraversalSource.traversal(MaxGraphTraversalSource.class).withRemote(remoteConnection);
    source.getStrategies().removeStrategies(ProfileStrategy.class, FilterRankingStrategy.class);
    return source;
}
Also used : MaxGraphTraversalSource(com.alibaba.maxgraph.tinkerpop.traversal.MaxGraphTraversalSource)

Example 3 with MaxGraphTraversalSource

use of com.alibaba.maxgraph.tinkerpop.traversal.MaxGraphTraversalSource in project GraphScope by alibaba.

the class MixedOpProcessor method processEstimateManager.

private Object processEstimateManager(EstimateRequest request, long timeout) throws RetryGremlinException {
    Stopwatch timer = Stopwatch.createStarted();
    CostDataStatistics statistics = CostDataStatistics.getInstance();
    TinkerMaxGraph emptyGraph = new TinkerMaxGraph(null, null, null);
    MaxGraphTraversalSource g = (MaxGraphTraversalSource) emptyGraph.traversal();
    GraphSchema graphSchema = schemaFetcher.getSchemaSnapshotPair().getLeft();
    Map<String, Double> vertexCountList = Maps.newHashMap();
    for (GraphElement vertex : graphSchema.getVertexList()) {
        String queryId = String.valueOf(ThreadLocalRandom.current().nextLong());
        GraphTraversal vertexQuery = g.estimateVCount(vertex.getLabel());
        RemoteRpcProcessor remoteRpcProcessor = new DefaultVertexRpcProcessor();
        MemoryResultProcessor resultProcessor = new MemoryResultProcessor(executeConfig.getBatchQuerySize(), resultIterationBatchSize, queryId);
        processQueryTraversal(vertexQuery.toString(), vertexQuery, timeout, queryId, timer, this.httpRpcConnector, remoteRpcProcessor, resultProcessor);
        double countValue = Double.parseDouble(resultProcessor.getResultList().get(0).toString());
        vertexCountList.put(vertex.getLabel(), countValue);
    }
    Map<String, Double> edgeCountList = Maps.newHashMap();
    for (GraphElement edge : graphSchema.getEdgeList()) {
        GraphTraversal edgeQuery = g.estimateECount(edge.getLabel());
        String queryId = String.valueOf(ThreadLocalRandom.current().nextLong());
        RemoteRpcProcessor remoteRpcProcessor = new DefaultVertexRpcProcessor();
        MemoryResultProcessor resultProcessor = new MemoryResultProcessor(executeConfig.getBatchQuerySize(), resultIterationBatchSize, queryId);
        processQueryTraversal(edgeQuery.toString(), edgeQuery, timeout, queryId, timer, this.httpRpcConnector, remoteRpcProcessor, resultProcessor);
        double countValue = Double.parseDouble(resultProcessor.getResultList().get(0).toString());
        edgeCountList.put(edge.getLabel(), countValue);
    }
    for (Map.Entry<String, Double> entry : vertexCountList.entrySet()) {
        statistics.addVertexCount(entry.getKey(), entry.getValue());
    }
    for (Map.Entry<String, Double> entry : edgeCountList.entrySet()) {
        statistics.addEdgeCount(entry.getKey(), entry.getValue());
    }
    return "Estimate vertex/edge count success";
}
Also used : Stopwatch(com.google.common.base.Stopwatch) MaxGraphTraversalSource(com.alibaba.maxgraph.tinkerpop.traversal.MaxGraphTraversalSource) GraphSchema(com.alibaba.maxgraph.compiler.api.schema.GraphSchema) TinkerMaxGraph(com.alibaba.maxgraph.structure.graph.TinkerMaxGraph) CostDataStatistics(com.alibaba.maxgraph.compiler.cost.statistics.CostDataStatistics) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) GraphElement(com.alibaba.maxgraph.compiler.api.schema.GraphElement) Map(java.util.Map)

Aggregations

MaxGraphTraversalSource (com.alibaba.maxgraph.tinkerpop.traversal.MaxGraphTraversalSource)3 GraphElement (com.alibaba.maxgraph.compiler.api.schema.GraphElement)1 GraphSchema (com.alibaba.maxgraph.compiler.api.schema.GraphSchema)1 CostDataStatistics (com.alibaba.maxgraph.compiler.cost.statistics.CostDataStatistics)1 TinkerMaxGraph (com.alibaba.maxgraph.structure.graph.TinkerMaxGraph)1 Stopwatch (com.google.common.base.Stopwatch)1 Map (java.util.Map)1 GraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal)1