mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-12-25 08:11:06 -06:00
improve graph op mappers and pre-processors
This commit is contained in:
parent
ec5128396f
commit
8fd8a6cb98
@ -59,6 +59,26 @@ public class Cqld4DriverAdapter extends BaseDriverAdapter<Op, Cqld4Space> {
|
|||||||
map.remove("type");
|
map.remove("type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (map.containsKey("type")) {
|
||||||
|
String type = map.get("type").toString();
|
||||||
|
if (type.equals("gremlin")&&map.containsKey("script")) {
|
||||||
|
map.put("gremlin",map.get("script").toString());
|
||||||
|
map.remove("script");
|
||||||
|
map.remove("type");
|
||||||
|
}
|
||||||
|
if (type.equals("gremlin")&&map.containsKey("stmt")) {
|
||||||
|
map.put("gremlin",map.get("stmt"));
|
||||||
|
map.remove("type");
|
||||||
|
map.remove("stmt");
|
||||||
|
}
|
||||||
|
if (type.equals("fluent")&&map.containsKey("fluent")) {
|
||||||
|
map.remove("type");
|
||||||
|
}
|
||||||
|
if (type.equals("fluent")&&map.containsKey("stmt")) {
|
||||||
|
map.put("fluent",map.get("stmt"));
|
||||||
|
map.remove("stmt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
});
|
});
|
||||||
|
@ -16,7 +16,7 @@ public class Cqld4GremlinOpDispenser extends BaseOpDispenser<Cqld4ScriptGraphOp>
|
|||||||
private final LongFunction<CqlSession> sessionFunc;
|
private final LongFunction<CqlSession> sessionFunc;
|
||||||
private final LongFunction<Long> diagFunc;
|
private final LongFunction<Long> diagFunc;
|
||||||
|
|
||||||
public Cqld4GremlinOpDispenser(LongFunction<CqlSession> sessionFunc, ParsedOp cmd) {
|
public Cqld4GremlinOpDispenser(LongFunction<CqlSession> sessionFunc, LongFunction<String> targetFunction, ParsedOp cmd) {
|
||||||
super(cmd);
|
super(cmd);
|
||||||
this.sessionFunc = sessionFunc;
|
this.sessionFunc = sessionFunc;
|
||||||
this.diagFunc = cmd.getAsFunctionOr("diag", 0L);
|
this.diagFunc = cmd.getAsFunctionOr("diag", 0L);
|
||||||
@ -31,15 +31,8 @@ public class Cqld4GremlinOpDispenser extends BaseOpDispenser<Cqld4ScriptGraphOp>
|
|||||||
func = l -> finalFunc.apply(l).setGraphName(stringLongFunction.apply(l));
|
func = l -> finalFunc.apply(l).setGraphName(stringLongFunction.apply(l));
|
||||||
}
|
}
|
||||||
|
|
||||||
// script
|
|
||||||
Optional<LongFunction<String>> scriptFunc = cmd.getAsOptionalFunction("script");
|
|
||||||
if (scriptFunc.isPresent()) {
|
|
||||||
LongFunction<ScriptGraphStatementBuilder> finalFunc = func;
|
|
||||||
func = l -> finalFunc.apply(l).setScript(scriptFunc.get().apply(l));
|
|
||||||
}
|
|
||||||
|
|
||||||
LongFunction<ScriptGraphStatementBuilder> finalFunc = func;
|
LongFunction<ScriptGraphStatementBuilder> finalFunc = func;
|
||||||
this.stmtFunc = l -> finalFunc.apply(l).build();
|
this.stmtFunc = l -> finalFunc.apply(l).setScript(targetFunction.apply(l)).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ public class Cqld4CoreOpMapper implements OpMapper<Op> {
|
|||||||
case raw -> new CqlD4RawStmtMapper(sessionFunc, target.targetFunction).apply(cmd);
|
case raw -> new CqlD4RawStmtMapper(sessionFunc, target.targetFunction).apply(cmd);
|
||||||
case simple -> new CqlD4CqlSimpleStmtMapper(sessionFunc, target.targetFunction).apply(cmd);
|
case simple -> new CqlD4CqlSimpleStmtMapper(sessionFunc, target.targetFunction).apply(cmd);
|
||||||
case prepared -> new CqlD4PreparedStmtMapper(sessionFunc, target).apply(cmd);
|
case prepared -> new CqlD4PreparedStmtMapper(sessionFunc, target).apply(cmd);
|
||||||
case gremlin -> new Cqld4GremlinOpMapper(sessionFunc).apply(cmd);
|
case gremlin -> new Cqld4GremlinOpMapper(sessionFunc, target.targetFunction).apply(cmd);
|
||||||
case fluent -> new Cqld4FluentGraphOpMapper(sessionFunc).apply(cmd);
|
case fluent -> new Cqld4FluentGraphOpMapper(sessionFunc, target).apply(cmd);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import io.nosqlbench.engine.api.activityimpl.OpDispenser;
|
|||||||
import io.nosqlbench.engine.api.activityimpl.OpMapper;
|
import io.nosqlbench.engine.api.activityimpl.OpMapper;
|
||||||
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op;
|
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op;
|
||||||
import io.nosqlbench.engine.api.templating.ParsedOp;
|
import io.nosqlbench.engine.api.templating.ParsedOp;
|
||||||
|
import io.nosqlbench.engine.api.templating.TypeAndTarget;
|
||||||
import io.nosqlbench.virtdata.core.bindings.Bindings;
|
import io.nosqlbench.virtdata.core.bindings.Bindings;
|
||||||
import io.nosqlbench.virtdata.core.bindings.BindingsTemplate;
|
import io.nosqlbench.virtdata.core.bindings.BindingsTemplate;
|
||||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplate;
|
import io.nosqlbench.virtdata.core.templates.ParsedTemplate;
|
||||||
@ -30,17 +31,19 @@ public class Cqld4FluentGraphOpMapper implements OpMapper<Op> {
|
|||||||
private final static Logger logger = LogManager.getLogger(Cqld4FluentGraphOpMapper.class);
|
private final static Logger logger = LogManager.getLogger(Cqld4FluentGraphOpMapper.class);
|
||||||
|
|
||||||
private final LongFunction<CqlSession> sessionFunc;
|
private final LongFunction<CqlSession> sessionFunc;
|
||||||
|
private final TypeAndTarget<CqlD4OpType, String> target;
|
||||||
private GraphTraversalSource gtsPlaceHolder;
|
private GraphTraversalSource gtsPlaceHolder;
|
||||||
|
|
||||||
public Cqld4FluentGraphOpMapper(LongFunction<CqlSession> sessionFunc) {
|
public Cqld4FluentGraphOpMapper(LongFunction<CqlSession> sessionFunc, TypeAndTarget<CqlD4OpType, String> target) {
|
||||||
this.sessionFunc = sessionFunc;
|
this.sessionFunc = sessionFunc;
|
||||||
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OpDispenser<? extends Op> apply(ParsedOp cmd) {
|
public OpDispenser<? extends Op> apply(ParsedOp cmd) {
|
||||||
GraphTraversalSource g = DseGraph.g;
|
GraphTraversalSource g = DseGraph.g;
|
||||||
|
|
||||||
ParsedTemplate fluent = cmd.getAsTemplate("fluent").orElseThrow();
|
ParsedTemplate fluent = cmd.getAsTemplate(target.field).orElseThrow();
|
||||||
String scriptBodyWithRawVarRefs = fluent.getPositionalStatement();
|
String scriptBodyWithRawVarRefs = fluent.getPositionalStatement();
|
||||||
|
|
||||||
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
|
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
|
||||||
|
@ -11,12 +11,14 @@ import java.util.function.LongFunction;
|
|||||||
|
|
||||||
public class Cqld4GremlinOpMapper implements OpMapper<Cqld4ScriptGraphOp> {
|
public class Cqld4GremlinOpMapper implements OpMapper<Cqld4ScriptGraphOp> {
|
||||||
private final LongFunction<CqlSession> sessionFunc;
|
private final LongFunction<CqlSession> sessionFunc;
|
||||||
|
private final LongFunction<String> targetFunction;
|
||||||
|
|
||||||
public Cqld4GremlinOpMapper(LongFunction<CqlSession> session) {
|
public Cqld4GremlinOpMapper(LongFunction<CqlSession> session, LongFunction<String> targetFunction) {
|
||||||
this.sessionFunc = session;
|
this.sessionFunc = session;
|
||||||
|
this.targetFunction = targetFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OpDispenser<Cqld4ScriptGraphOp> apply(ParsedOp cmd) {
|
public OpDispenser<Cqld4ScriptGraphOp> apply(ParsedOp cmd) {
|
||||||
return new Cqld4GremlinOpDispenser(sessionFunc, cmd);
|
return new Cqld4GremlinOpDispenser(sessionFunc, targetFunction, cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user