mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-12-22 15:13:41 -06:00
derive session from space directly
This commit is contained in:
parent
919a741fa8
commit
a13b433b23
@ -40,13 +40,12 @@ public class CqlD4BatchStmtDispenser extends Cqld4CqlBaseOpDispenser<Cqld4CqlBat
|
||||
|
||||
public CqlD4BatchStmtDispenser(
|
||||
Cqld4DriverAdapter adapter,
|
||||
LongFunction<CqlSession> sessionFunc,
|
||||
ParsedOp op,
|
||||
int repeat,
|
||||
ParsedOp subop,
|
||||
OpDispenser<? extends Cqld4CqlOp> subopDispenser
|
||||
) {
|
||||
super(adapter, sessionFunc, op);
|
||||
super(adapter, op);
|
||||
this.repeat = repeat;
|
||||
this.subop = subop;
|
||||
this.opfunc = createStmtFunc(op, subopDispenser);
|
||||
@ -90,7 +89,7 @@ public class CqlD4BatchStmtDispenser extends Cqld4CqlBaseOpDispenser<Cqld4CqlBat
|
||||
public Cqld4CqlBatchStatement getOp(long value) {
|
||||
Statement bstmt = opfunc.apply(value);
|
||||
return new Cqld4CqlBatchStatement(
|
||||
getSessionFunc().apply(value),
|
||||
sessionF.apply(value),
|
||||
(BatchStatement) bstmt,
|
||||
getMaxPages(),
|
||||
getMaxLwtRetries(),
|
||||
|
@ -55,7 +55,6 @@ public abstract class Cqld4BaseOpDispenser<T extends Cqld4BaseOp> extends BaseOp
|
||||
protected final LongFunction<CqlSession> sessionF;
|
||||
|
||||
public Cqld4BaseOpDispenser(Cqld4DriverAdapter adapter,
|
||||
LongFunction<CqlSession> sessionFunc,
|
||||
ParsedOp op) {
|
||||
super((DriverAdapter<? extends T, ? extends Cqld4Space>) adapter, op);
|
||||
this.sessionF = l -> adapter.getSpaceCache().get(l).getSession();
|
||||
@ -94,11 +93,6 @@ public abstract class Cqld4BaseOpDispenser<T extends Cqld4BaseOp> extends BaseOp
|
||||
return maxLwtRetries;
|
||||
}
|
||||
|
||||
|
||||
public LongFunction<CqlSession> getSessionFunc() {
|
||||
return sessionFunc;
|
||||
}
|
||||
|
||||
/**
|
||||
* All implementations of a CQL Statement Dispenser should be using the method
|
||||
* provided by this function. This ensures that {@link Statement}-level attributes
|
||||
|
@ -38,22 +38,18 @@ import java.util.function.Supplier;
|
||||
public class Cqld4FluentGraphOpDispenser extends Cqld4BaseOpDispenser<Cqld4BaseOp> {
|
||||
|
||||
private final LongFunction<? extends String> graphnameFunc;
|
||||
private final LongFunction<CqlSession> sessionFunc;
|
||||
private final Bindings virtdataBindings;
|
||||
private final ThreadLocal<Script> tlScript;
|
||||
|
||||
public Cqld4FluentGraphOpDispenser(
|
||||
Cqld4DriverAdapter adapter,
|
||||
LongFunction<CqlSession> sessionFunc,
|
||||
ParsedOp op,
|
||||
LongFunction<? extends String> graphnameFunc,
|
||||
LongFunction<CqlSession> sessionFunc1,
|
||||
Bindings virtdataBindings,
|
||||
Supplier<Script> scriptSupplier
|
||||
) {
|
||||
super(adapter, op);
|
||||
this.graphnameFunc = graphnameFunc;
|
||||
this.sessionFunc = sessionFunc1;
|
||||
this.virtdataBindings = virtdataBindings;
|
||||
this.tlScript = ThreadLocal.withInitial(scriptSupplier);
|
||||
}
|
||||
@ -66,7 +62,7 @@ public class Cqld4FluentGraphOpDispenser extends Cqld4BaseOpDispenser<Cqld4BaseO
|
||||
allMap.forEach((k,v) -> script.getBinding().setVariable(k,v));
|
||||
GraphTraversal<Vertex,Vertex> v = (GraphTraversal<Vertex, Vertex>) script.run();
|
||||
FluentGraphStatement fgs = new FluentGraphStatementBuilder(v).setGraphName(graphname).build();
|
||||
return new Cqld4FluentGraphOp(sessionFunc.apply(value),fgs);
|
||||
return new Cqld4FluentGraphOp(sessionF.apply(value),fgs);
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,16 +48,11 @@ public class Cqld4PreparedStmtDispenser extends Cqld4BaseOpDispenser {
|
||||
|
||||
public Cqld4PreparedStmtDispenser(
|
||||
Cqld4DriverAdapter adapter,
|
||||
LongFunction<CqlSession> sessionFunc,
|
||||
ParsedOp op,
|
||||
ParsedTemplateString stmtTpl,
|
||||
RSProcessors processors
|
||||
ParsedOp op,
|
||||
ParsedTemplateString stmtTpl,
|
||||
RSProcessors processors
|
||||
) {
|
||||
super(adapter, sessionFunc, op);
|
||||
if (op.isDynamic("space")) {
|
||||
throw new RuntimeException("Prepared statements and dynamic space values are not yet supported" +
|
||||
" but are being implemented");
|
||||
}
|
||||
super(adapter, op);
|
||||
this.processors = processors;
|
||||
this.stmtTpl = stmtTpl;
|
||||
this.fieldsF = getFieldsFunction(op);
|
||||
@ -71,10 +66,6 @@ public class Cqld4PreparedStmtDispenser extends Cqld4BaseOpDispenser {
|
||||
return varbinder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LongFunction<CqlSession> getSessionFunc() {
|
||||
return super.getSessionFunc();
|
||||
}
|
||||
|
||||
protected LongFunction<Statement> createStmtFunc(LongFunction<Object[]> fieldsF, ParsedOp op) {
|
||||
|
||||
|
@ -35,7 +35,6 @@ public class Cqld4RawStmtDispenser extends Cqld4BaseOpDispenser<Cqld4CqlOp> {
|
||||
private final LongFunction<String> targetFunction;
|
||||
|
||||
public Cqld4RawStmtDispenser(Cqld4DriverAdapter adapter,
|
||||
LongFunction<CqlSession> sessionFunc,
|
||||
LongFunction<String> targetFunction, ParsedOp cmd) {
|
||||
super(adapter, cmd);
|
||||
this.targetFunction=targetFunction;
|
||||
@ -50,7 +49,7 @@ public class Cqld4RawStmtDispenser extends Cqld4BaseOpDispenser<Cqld4CqlOp> {
|
||||
@Override
|
||||
public Cqld4CqlSimpleStatement getOp(long value) {
|
||||
return new Cqld4CqlSimpleStatement(
|
||||
getSessionFunc().apply(value),
|
||||
sessionF.apply(value),
|
||||
(SimpleStatement) stmtFunc.apply(value),
|
||||
getMaxPages(),
|
||||
isRetryReplace(),
|
||||
|
@ -33,8 +33,8 @@ public class Cqld4SimpleCqlStmtDispenser<T extends Cqld4CqlOp> extends Cqld4Base
|
||||
private final LongFunction<Statement> stmtFunc;
|
||||
private final LongFunction<String> targetFunction;
|
||||
|
||||
public Cqld4SimpleCqlStmtDispenser(Cqld4DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, LongFunction<String> targetFunction, ParsedOp cmd) {
|
||||
super(adapter, sessionFunc,cmd);
|
||||
public Cqld4SimpleCqlStmtDispenser(Cqld4DriverAdapter adapter, LongFunction<String> targetFunction, ParsedOp cmd) {
|
||||
super(adapter, cmd);
|
||||
this.targetFunction=targetFunction;
|
||||
this.stmtFunc =createStmtFunc(cmd);
|
||||
}
|
||||
@ -46,7 +46,7 @@ public class Cqld4SimpleCqlStmtDispenser<T extends Cqld4CqlOp> extends Cqld4Base
|
||||
@Override
|
||||
public Cqld4CqlSimpleStatement getOp(long value) {
|
||||
return new Cqld4CqlSimpleStatement(
|
||||
sessionFunc.apply(value),
|
||||
this.sessionF.apply(value),
|
||||
(SimpleStatement) stmtFunc.apply(value),
|
||||
getMaxPages(),
|
||||
isRetryReplace(),
|
||||
|
@ -29,8 +29,8 @@ public class Cqld4SsTableDispenser extends Cqld4BaseOpDispenser {
|
||||
// private final LongFunction<Statement> stmtFunc;
|
||||
// private final LongFunction<String> targetFunction;
|
||||
|
||||
public Cqld4SsTableDispenser(Cqld4DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, LongFunction<String> targetFunction, ParsedOp cmd) {
|
||||
super(adapter,sessionFunc,cmd);
|
||||
public Cqld4SsTableDispenser(Cqld4DriverAdapter adapter, LongFunction<String> targetFunction, ParsedOp cmd) {
|
||||
super(adapter,cmd);
|
||||
// this.targetFunction=targetFunction;
|
||||
// this.tableFunc =createTableFunc(cmd);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class CqlD4BatchStmtMapper extends Cqld4BaseOpMapper<Cqld4BaseOp> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpDispenser<Cqld4BaseOp> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF) {
|
||||
public OpDispenser<Cqld4CqlBatchStatement> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF) {
|
||||
ParsedOp subop = op.getAsSubOp("op_template", ParsedOp.SubOpNaming.ParentAndSubKey);
|
||||
int repeat = op.getStaticValue("repeat");
|
||||
OpDispenser<? extends Cqld4BaseOp> od = new Cqld4CqlOpMapper(adapter).apply(op, spaceInitF);
|
||||
|
@ -69,7 +69,7 @@ public class CqlD4PreparedStmtMapper extends Cqld4BaseOpMapper<Cqld4BaseOp> {
|
||||
});
|
||||
});
|
||||
|
||||
return new Cqld4PreparedStmtDispenser(adapter, sessionFunc, op, stmtTpl, processors);
|
||||
return new Cqld4PreparedStmtDispenser(adapter, op, stmtTpl, processors);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -95,10 +95,8 @@ public class Cqld4FluentGraphOpMapper<CO extends Cqld4FluentGraphOp> extends Cql
|
||||
|
||||
return new Cqld4FluentGraphOpDispenser(
|
||||
adapter,
|
||||
sessionFunc,
|
||||
op,
|
||||
graphnameFunc,
|
||||
sessionFunc,
|
||||
virtdataBindings,
|
||||
supplier
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user