mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-16 17:34:52 -06:00
make api type more obvious
This commit is contained in:
parent
3d2061125d
commit
50f81078bd
@ -35,7 +35,7 @@ public class CqlD4CqlSimpleStmtMapper implements OpMapper<Cqld4CqlOp> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpDispenser<? extends Cqld4CqlOp> apply(ParsedOp cmd) {
|
||||
return new Cqld4SimpleCqlStmtDispenser(sessionFunc,targetFunction,cmd);
|
||||
public OpDispenser<? extends Cqld4CqlOp> apply(ParsedOp op) {
|
||||
return new Cqld4SimpleCqlStmtDispenser(sessionFunc,targetFunction, op);
|
||||
}
|
||||
}
|
||||
|
@ -46,10 +46,10 @@ public class CqlD4PreparedStmtMapper implements OpMapper<Cqld4CqlOp> {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public OpDispenser<Cqld4CqlOp> apply(ParsedOp cmd) {
|
||||
public OpDispenser<Cqld4CqlOp> apply(ParsedOp op) {
|
||||
|
||||
ParsedStringTemplate stmtTpl = cmd.getAsTemplate(target.field).orElseThrow(() -> new BasicError(
|
||||
"No statement was found in the op template:" + cmd
|
||||
ParsedStringTemplate stmtTpl = op.getAsTemplate(target.field).orElseThrow(() -> new BasicError(
|
||||
"No statement was found in the op template:" + op
|
||||
));
|
||||
|
||||
RSProcessors processors = new RSProcessors();
|
||||
@ -57,7 +57,7 @@ public class CqlD4PreparedStmtMapper implements OpMapper<Cqld4CqlOp> {
|
||||
processors.add(() -> new CqlFieldCaptureProcessor(stmtTpl.getCaptures()));
|
||||
}
|
||||
|
||||
Optional<List> processorList = cmd.getOptionalStaticConfig("processors", List.class);
|
||||
Optional<List> processorList = op.getOptionalStaticConfig("processors", List.class);
|
||||
|
||||
processorList.ifPresent(l -> {
|
||||
l.forEach(m -> {
|
||||
@ -67,7 +67,7 @@ public class CqlD4PreparedStmtMapper implements OpMapper<Cqld4CqlOp> {
|
||||
});
|
||||
});
|
||||
|
||||
return new Cqld4PreparedStmtDispenser(sessionFunc, cmd, stmtTpl, processors);
|
||||
return new Cqld4PreparedStmtDispenser(sessionFunc, op, stmtTpl, processors);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class CqlD4RawStmtMapper implements OpMapper<Cqld4CqlOp> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpDispenser<? extends Cqld4CqlOp> apply(ParsedOp cmd) {
|
||||
return new Cqld4RawStmtDispenser(sessionFunc, targetFunction, cmd);
|
||||
public OpDispenser<? extends Cqld4CqlOp> apply(ParsedOp op) {
|
||||
return new Cqld4RawStmtDispenser(sessionFunc, targetFunction, op);
|
||||
}
|
||||
}
|
||||
|
@ -44,28 +44,28 @@ public class Cqld4CoreOpMapper implements OpMapper<Op> {
|
||||
* for it. Since the operations under the CQL driver 4.* do not follow a common type structure, we use the
|
||||
* base types in the NoSQLBench APIs and treat them somewhat more generically than with other drivers.
|
||||
*
|
||||
* @param cmd The {@link ParsedOp} which is the parsed version of the user-provided op template.
|
||||
* @param op The {@link ParsedOp} which is the parsed version of the user-provided op template.
|
||||
* This contains all the fields provided by the user, as well as explicit knowledge of
|
||||
* which ones are static and dynamic.
|
||||
* @return An op dispenser for each provided op command
|
||||
*/
|
||||
public OpDispenser<? extends Op> apply(ParsedOp cmd) {
|
||||
public OpDispenser<? extends Op> apply(ParsedOp op) {
|
||||
|
||||
LongFunction<String> spaceName = cmd.getAsFunctionOr("space", "default");
|
||||
LongFunction<String> spaceName = op.getAsFunctionOr("space", "default");
|
||||
// Since the only needed thing in the Cqld4Space is the session, we can short-circuit
|
||||
// to it here instead of stepping down from the cycle to the space to the session
|
||||
LongFunction<CqlSession> sessionFunc = l -> cache.get(spaceName.apply(l)).getSession();
|
||||
|
||||
CqlD4OpType opType = CqlD4OpType.prepared;
|
||||
|
||||
TypeAndTarget<CqlD4OpType, String> target = cmd.getTypeAndTarget(CqlD4OpType.class, String.class, "type", "stmt");
|
||||
TypeAndTarget<CqlD4OpType, String> target = op.getTypeAndTarget(CqlD4OpType.class, String.class, "type", "stmt");
|
||||
|
||||
return switch (target.enumId) {
|
||||
case raw -> new CqlD4RawStmtMapper(sessionFunc, target.targetFunction).apply(cmd);
|
||||
case simple -> new CqlD4CqlSimpleStmtMapper(sessionFunc, target.targetFunction).apply(cmd);
|
||||
case prepared -> new CqlD4PreparedStmtMapper(sessionFunc, target).apply(cmd);
|
||||
case gremlin -> new Cqld4GremlinOpMapper(sessionFunc, target.targetFunction).apply(cmd);
|
||||
case fluent -> new Cqld4FluentGraphOpMapper(sessionFunc, target).apply(cmd);
|
||||
case raw -> new CqlD4RawStmtMapper(sessionFunc, target.targetFunction).apply(op);
|
||||
case simple -> new CqlD4CqlSimpleStmtMapper(sessionFunc, target.targetFunction).apply(op);
|
||||
case prepared -> new CqlD4PreparedStmtMapper(sessionFunc, target).apply(op);
|
||||
case gremlin -> new Cqld4GremlinOpMapper(sessionFunc, target.targetFunction).apply(op);
|
||||
case fluent -> new Cqld4FluentGraphOpMapper(sessionFunc, target).apply(op);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -54,19 +54,19 @@ public class Cqld4FluentGraphOpMapper implements OpMapper<Op> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpDispenser<? extends Op> apply(ParsedOp cmd) {
|
||||
public OpDispenser<? extends Op> apply(ParsedOp op) {
|
||||
GraphTraversalSource g = DseGraph.g;
|
||||
|
||||
ParsedStringTemplate fluent = cmd.getAsTemplate(target.field).orElseThrow();
|
||||
ParsedStringTemplate fluent = op.getAsTemplate(target.field).orElseThrow();
|
||||
String scriptBodyWithRawVarRefs = fluent.getPositionalStatement();
|
||||
|
||||
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
|
||||
|
||||
if (cmd.isDynamic("imports")) {
|
||||
if (op.isDynamic("imports")) {
|
||||
throw new OpConfigError("You may only define imports as a static list. Dynamic values are not allowed.");
|
||||
}
|
||||
|
||||
List imports = cmd.getOptionalStaticValue("imports", List.class)
|
||||
List imports = op.getOptionalStaticValue("imports", List.class)
|
||||
.orElse(List.of("org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__"));
|
||||
String[] verifiedClasses = expandClassNames(imports);
|
||||
ImportCustomizer importer = new ImportCustomizer();
|
||||
@ -79,10 +79,10 @@ public class Cqld4FluentGraphOpMapper implements OpMapper<Op> {
|
||||
return gshell.parse(scriptBodyWithRawVarRefs);
|
||||
};
|
||||
|
||||
LongFunction<? extends String> graphnameFunc = cmd.getAsRequiredFunction("graphname");
|
||||
LongFunction<? extends String> graphnameFunc = op.getAsRequiredFunction("graphname");
|
||||
Bindings virtdataBindings = new BindingsTemplate(fluent.getBindPoints()).resolveBindings();
|
||||
|
||||
return new Cqld4FluentGraphOpDispenser(cmd, graphnameFunc, sessionFunc, virtdataBindings, supplier);
|
||||
return new Cqld4FluentGraphOpDispenser(op, graphnameFunc, sessionFunc, virtdataBindings, supplier);
|
||||
}
|
||||
|
||||
private String[] expandClassNames(List l) {
|
||||
|
@ -34,7 +34,7 @@ public class Cqld4GremlinOpMapper implements OpMapper<Cqld4ScriptGraphOp> {
|
||||
this.targetFunction = targetFunction;
|
||||
}
|
||||
|
||||
public OpDispenser<Cqld4ScriptGraphOp> apply(ParsedOp cmd) {
|
||||
return new Cqld4GremlinOpDispenser(sessionFunc, targetFunction, cmd);
|
||||
public OpDispenser<Cqld4ScriptGraphOp> apply(ParsedOp op) {
|
||||
return new Cqld4GremlinOpDispenser(sessionFunc, targetFunction, op);
|
||||
}
|
||||
}
|
||||
|
@ -38,11 +38,11 @@ public class DiagOpMapper implements OpMapper<DiagOp>, NBReconfigurable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpDispenser<? extends DiagOp> apply(ParsedOp cmd) {
|
||||
DiagOpDispenser dispenser = new DiagOpDispenser(cmd);
|
||||
LongFunction<String> spaceName = cmd.getAsFunctionOr("space", "default");
|
||||
public OpDispenser<? extends DiagOp> apply(ParsedOp op) {
|
||||
DiagOpDispenser dispenser = new DiagOpDispenser(op);
|
||||
LongFunction<String> spaceName = op.getAsFunctionOr("space", "default");
|
||||
LongFunction<DiagSpace> spacef = l -> spaceCache.get(spaceName.apply(l));
|
||||
dispensers.put(cmd.getName(),dispenser);
|
||||
dispensers.put(op.getName(),dispenser);
|
||||
return dispenser;
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,8 @@ public class DynamoDBOpMapper implements OpMapper<DynamoDBOp> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpDispenser<DynamoDBOp> apply(ParsedOp cmd) {
|
||||
String space = cmd.getStaticConfigOr("space", "default");
|
||||
public OpDispenser<DynamoDBOp> apply(ParsedOp op) {
|
||||
String space = op.getStaticConfigOr("space", "default");
|
||||
DynamoDB ddb = cache.get(space).getDynamoDB();
|
||||
|
||||
/*
|
||||
@ -46,17 +46,17 @@ public class DynamoDBOpMapper implements OpMapper<DynamoDBOp> {
|
||||
* a data structure that can be converted into JSON, bypassing any further
|
||||
* specialized type-checking or op-type specific features
|
||||
*/
|
||||
if (cmd.isDefined("body")) {
|
||||
if (op.isDefined("body")) {
|
||||
throw new RuntimeException("This mode is reserved for later. Do not use the 'body' op field.");
|
||||
// return new RawDynamoDBOpDispenser(cmd);
|
||||
} else {
|
||||
TypeAndTarget<DynamoDBCmdType,String> cmdType = cmd.getTypeAndTarget(DynamoDBCmdType.class,String.class);
|
||||
TypeAndTarget<DynamoDBCmdType,String> cmdType = op.getTypeAndTarget(DynamoDBCmdType.class,String.class);
|
||||
return switch (cmdType.enumId) {
|
||||
case CreateTable -> new DDBCreateTableOpDispenser(ddb, cmd, cmdType.targetFunction);
|
||||
case DeleteTable -> new DDBDeleteTableOpDispenser(ddb, cmd, cmdType.targetFunction);
|
||||
case PutItem -> new DDBPutItemOpDispenser(ddb, cmd, cmdType.targetFunction);
|
||||
case GetItem -> new DDBGetItemOpDispenser(ddb, cmd, cmdType.targetFunction);
|
||||
case Query -> new DDBQueryOpDispenser(ddb, cmd, cmdType.targetFunction);
|
||||
case CreateTable -> new DDBCreateTableOpDispenser(ddb, op, cmdType.targetFunction);
|
||||
case DeleteTable -> new DDBDeleteTableOpDispenser(ddb, op, cmdType.targetFunction);
|
||||
case PutItem -> new DDBPutItemOpDispenser(ddb, op, cmdType.targetFunction);
|
||||
case GetItem -> new DDBGetItemOpDispenser(ddb, op, cmdType.targetFunction);
|
||||
case Query -> new DDBQueryOpDispenser(ddb, op, cmdType.targetFunction);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,9 @@ public class HttpOpMapper implements OpMapper<HttpOp> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpDispenser<? extends HttpOp> apply(ParsedOp cmd) {
|
||||
LongFunction<String> spaceNameF = cmd.getAsFunctionOr("space", "default");
|
||||
public OpDispenser<? extends HttpOp> apply(ParsedOp op) {
|
||||
LongFunction<String> spaceNameF = op.getAsFunctionOr("space", "default");
|
||||
LongFunction<HttpSpace> spaceFunc = l -> spaceCache.get(spaceNameF.apply(l));
|
||||
return new HttpOpDispenser(spaceFunc,cmd);
|
||||
return new HttpOpDispenser(spaceFunc, op);
|
||||
}
|
||||
}
|
||||
|
@ -32,10 +32,10 @@ public class StdoutOpMapper implements OpMapper<StdoutOp> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpDispenser<StdoutOp> apply(ParsedOp cmd) {
|
||||
LongFunction<String> spacefunc = cmd.getAsFunctionOr("space", "default");
|
||||
public OpDispenser<StdoutOp> apply(ParsedOp op) {
|
||||
LongFunction<String> spacefunc = op.getAsFunctionOr("space", "default");
|
||||
LongFunction<StdoutSpace> ctxfunc = (cycle) -> ctxcache.get(spacefunc.apply(cycle));
|
||||
return new StdoutOpDispenser(cmd,ctxfunc);
|
||||
return new StdoutOpDispenser(op,ctxfunc);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user