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