use of com.alibaba.pegasus.builder.AbstractBuilder in project GraphScope by alibaba.
the class QueryTest method test_CR_8.
public static void test_CR_8(GaiaConfig config, GraphStoreService storeService, IdMaker queryIdMaker) {
Traversal testTraversal = CR_8();
GaiaGraphOpProcessor.applyStrategy(testTraversal, config, storeService);
long queryId = (long) queryIdMaker.getId(testTraversal.asAdmin());
AbstractBuilder job = new TraversalTranslator((new TraversalBuilder(testTraversal.asAdmin())).addConfig(PlanConfig.QUERY_ID, queryId).addConfig(PlanConfig.TAG_ID_MAKER, new TagIdMaker(testTraversal.asAdmin())).addConfig(PlanConfig.QUERY_CONFIG, PlanUtils.getDefaultConfig(queryId, config))).translate();
PlanUtils.print(job);
}
use of com.alibaba.pegasus.builder.AbstractBuilder in project GraphScope by alibaba.
the class GremlinStepResource method attachResource.
@Override
public void attachResource(StepBuilder stepBuilder) {
Step step = stepBuilder.getStep();
AbstractBuilder target = stepBuilder.getJobBuilder();
if (ShuffleStrategy.needShuffle(step)) {
((JobBuilder) target).exchange(ByteString.EMPTY);
}
addGremlinStep(stepBuilder);
}
use of com.alibaba.pegasus.builder.AbstractBuilder in project GraphScope by alibaba.
the class GaiaGraphOpProcessor method createLifeCycle.
@Override
protected GremlinExecutor.LifeCycle createLifeCycle(Context ctx, Supplier<GremlinExecutor> gremlinExecutorSupplier, BindingSupplier bindingsSupplier) {
final RequestMessage msg = ctx.getRequestMessage();
final Settings settings = ctx.getSettings();
final Map<String, Object> args = msg.getArgs();
final long seto = args.containsKey(Tokens.ARGS_SCRIPT_EVAL_TIMEOUT) ? ((Number) args.get(Tokens.ARGS_SCRIPT_EVAL_TIMEOUT)).longValue() : settings.scriptEvaluationTimeout;
if (config.getGraphType() == GraphType.MAXGRAPH) {
graphStore.updateSnapShotId();
}
return GremlinExecutor.LifeCycle.build().scriptEvaluationTimeoutOverride(seto).beforeEval(b -> {
try {
b.putAll(bindingsSupplier.get());
} catch (OpProcessorException ope) {
throw new RuntimeException(ope);
}
}).transformResult(o -> {
if (o != null && o instanceof Traversal) {
applyStrategy((Traversal) o, config, graphStore);
}
return o;
}).withResult(o -> {
if (o != null && o instanceof Traversal) {
long queryId = (long) queryIdMaker.getId(o);
TraversalBuilder traversalBuilder = new TraversalBuilder((Traversal.Admin) o).addConfig(PlanConfig.QUERY_ID, queryId).addConfig(PlanConfig.TAG_ID_MAKER, new TagIdMaker((Traversal.Admin) o)).addConfig(PlanConfig.QUERY_CONFIG, PlanUtils.getDefaultConfig(queryId, config));
if (config.getGraphType() == GraphType.MAXGRAPH) {
traversalBuilder.addConfig(PlanConfig.SNAPSHOT_ID, Long.valueOf(graphStore.getSnapShotId()));
}
AbstractBuilder jobReqBuilder = new TraversalTranslator(traversalBuilder).translate();
PlanUtils.print(jobReqBuilder);
broadcastProcessor.broadcast(jobReqBuilder.build(), new GremlinResultProcessor(ctx, new DefaultResultParser(traversalBuilder, graphStore, config)));
} else {
List<Object> results = new ArrayList<>();
if (o != null) {
results.add(o);
}
writeResultList(ctx, results, ResponseStatusCode.SUCCESS);
}
}).create();
}
use of com.alibaba.pegasus.builder.AbstractBuilder in project GraphScope by alibaba.
the class QueryTest method test_CR_9.
public static void test_CR_9(GaiaConfig config, GraphStoreService storeService, IdMaker queryIdMaker) {
Traversal testTraversal = CR_9();
GaiaGraphOpProcessor.applyStrategy(testTraversal, config, storeService);
long queryId = (long) queryIdMaker.getId(testTraversal.asAdmin());
AbstractBuilder job = new TraversalTranslator((new TraversalBuilder(testTraversal.asAdmin())).addConfig(PlanConfig.QUERY_ID, queryId).addConfig(PlanConfig.TAG_ID_MAKER, new TagIdMaker(testTraversal.asAdmin())).addConfig(PlanConfig.QUERY_CONFIG, PlanUtils.getDefaultConfig(queryId, config))).translate();
PlanUtils.print(job);
}
use of com.alibaba.pegasus.builder.AbstractBuilder in project GraphScope by alibaba.
the class LogicPlanProcessor method createLifeCycle.
@Override
protected GremlinExecutor.LifeCycle createLifeCycle(Context ctx, Supplier<GremlinExecutor> gremlinExecutorSupplier, BindingSupplier bindingsSupplier) {
final RequestMessage msg = ctx.getRequestMessage();
final Settings settings = ctx.getSettings();
final Map<String, Object> args = msg.getArgs();
final long seto = args.containsKey(Tokens.ARGS_SCRIPT_EVAL_TIMEOUT) ? ((Number) args.get(Tokens.ARGS_SCRIPT_EVAL_TIMEOUT)).longValue() : settings.scriptEvaluationTimeout;
if (config.getGraphType() == GraphType.MAXGRAPH) {
graphStore.updateSnapShotId();
}
return GremlinExecutor.LifeCycle.build().scriptEvaluationTimeoutOverride(seto).beforeEval(b -> {
try {
b.putAll(bindingsSupplier.get());
} catch (OpProcessorException ope) {
throw new RuntimeException(ope);
}
}).transformResult(o -> {
if (o != null && o instanceof Traversal) {
applyStrategy((Traversal) o, config, graphStore);
}
return o;
}).withResult(o -> {
if (o != null && o instanceof Traversal) {
long queryId = (long) queryIdMaker.getId(o);
TraversalBuilder traversalBuilder = new TraversalBuilder((Traversal.Admin) o).addConfig(PlanConfig.QUERY_ID, queryId).addConfig(PlanConfig.TAG_ID_MAKER, new TagIdMaker((Traversal.Admin) o)).addConfig(PlanConfig.QUERY_CONFIG, PlanUtils.getDefaultConfig(queryId, config));
if (config.getGraphType() == GraphType.MAXGRAPH) {
traversalBuilder.addConfig(PlanConfig.SNAPSHOT_ID, Long.valueOf(graphStore.getSnapShotId()));
}
AbstractBuilder jobReqBuilder = new TraversalTranslator(traversalBuilder).translate();
String content = new String(jobReqBuilder.build().toByteArray(), StandardCharsets.ISO_8859_1);
AbstractGraphOpProcessor.writeResultList(ctx, Arrays.asList(content), ResponseStatusCode.SUCCESS);
}
}).create();
}
Aggregations