Search in sources :

Example 6 with TinkerMaxGraph

use of com.alibaba.maxgraph.structure.graph.TinkerMaxGraph in project GraphScope by alibaba.

the class MaxGraphServiceProducer method makeGraphService.

@Override
public AbstractService makeGraphService(SchemaFetcher schemaFetcher, ChannelManager channelManager, NodeDiscovery discovery, GraphWriter graphWriter, WriteSessionGenerator writeSessionGenerator, MetaService metaService) {
    MaxGraphImpl maxGraphImpl = new MaxGraphImpl(discovery, schemaFetcher, graphWriter, writeSessionGenerator, metaService);
    TinkerMaxGraph graph = new TinkerMaxGraph(new InstanceConfig(configs.getInnerProperties()), maxGraphImpl, new DefaultGraphDfs());
    return new ReadOnlyGraphServer(configs, graph, schemaFetcher, new DiscoveryAddressFetcher(discovery));
}
Also used : InstanceConfig(com.alibaba.maxgraph.common.cluster.InstanceConfig) TinkerMaxGraph(com.alibaba.maxgraph.structure.graph.TinkerMaxGraph) DefaultGraphDfs(com.alibaba.maxgraph.compiler.dfs.DefaultGraphDfs)

Example 7 with TinkerMaxGraph

use of com.alibaba.maxgraph.structure.graph.TinkerMaxGraph 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

TinkerMaxGraph (com.alibaba.maxgraph.structure.graph.TinkerMaxGraph)7 DefaultGraphDfs (com.alibaba.maxgraph.compiler.dfs.DefaultGraphDfs)4 SchemaFetcher (com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher)3 JsonFileSchemaFetcher (com.alibaba.maxgraph.compiler.schema.JsonFileSchemaFetcher)3 ExecutorAddressFetcher (com.alibaba.maxgraph.frontendservice.server.ExecutorAddressFetcher)3 RemoteGraph (com.alibaba.maxgraph.frontendservice.RemoteGraph)2 RpcChannelFetcher (com.alibaba.graphscope.common.client.RpcChannelFetcher)1 Configs (com.alibaba.graphscope.common.config.Configs)1 IrMetaQueryCallback (com.alibaba.graphscope.common.manager.IrMetaQueryCallback)1 IrMetaFetcher (com.alibaba.graphscope.common.store.IrMetaFetcher)1 AbstractBroadcastProcessor (com.alibaba.graphscope.gaia.broadcast.AbstractBroadcastProcessor)1 AsyncRpcBroadcastProcessor (com.alibaba.graphscope.gaia.broadcast.AsyncRpcBroadcastProcessor)1 AsyncRpcChannelFetcher (com.alibaba.graphscope.gaia.broadcast.channel.AsyncRpcChannelFetcher)1 GraphStoreService (com.alibaba.graphscope.gaia.store.GraphStoreService)1 IrGremlinServer (com.alibaba.graphscope.gremlin.service.IrGremlinServer)1 InstanceConfig (com.alibaba.maxgraph.common.cluster.InstanceConfig)1 RpcAddressFetcher (com.alibaba.maxgraph.common.rpc.RpcAddressFetcher)1 GraphElement (com.alibaba.maxgraph.compiler.api.schema.GraphElement)1 GraphSchema (com.alibaba.maxgraph.compiler.api.schema.GraphSchema)1 GraphVertex (com.alibaba.maxgraph.compiler.api.schema.GraphVertex)1