mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
allow op type specialization/covariance
This commit is contained in:
@@ -13,7 +13,7 @@ import java.util.function.LongFunction;
|
||||
*/
|
||||
public interface OpSource<T> extends LongFunction<T> {
|
||||
|
||||
static <O extends Op> OpSource<O> of(OpSequence<OpDispenser<O>> seq) {
|
||||
static <O extends Op> OpSource<O> of(OpSequence<OpDispenser<? extends O>> seq) {
|
||||
return (long l) -> seq.apply(l).apply(l);
|
||||
}
|
||||
|
||||
|
||||
@@ -419,20 +419,20 @@ public class SimpleActivity implements Activity, ProgressCapable {
|
||||
* @param <O>
|
||||
* @return
|
||||
*/
|
||||
protected <O extends Op> OpSequence<OpDispenser<O>> createOpSequenceFromCommands(Function<CommandTemplate, OpDispenser<O>> opinit) {
|
||||
protected <O extends Op> OpSequence<OpDispenser<? extends O>> createOpSequenceFromCommands(Function<CommandTemplate, OpDispenser<O>> opinit) {
|
||||
Function<OpTemplate, CommandTemplate> f = CommandTemplate::new;
|
||||
Function<OpTemplate, OpDispenser<O>> opTemplateOFunction = f.andThen(opinit);
|
||||
Function<OpTemplate, OpDispenser<? extends O>> opTemplateOFunction = f.andThen(opinit);
|
||||
|
||||
return createOpSequence(opTemplateOFunction);
|
||||
}
|
||||
|
||||
protected <O extends Op> OpSequence<OpDispenser<O>> createOpSourceFromCommands(
|
||||
Function<ParsedOp, OpDispenser<O>> opinit,
|
||||
protected <O extends Op> OpSequence<OpDispenser<? extends O>> createOpSourceFromCommands(
|
||||
Function<ParsedOp, OpDispenser<? extends O>> opinit,
|
||||
NBConfiguration cfg,
|
||||
List<Function<Map<String, Object>, Map<String, Object>>> parsers
|
||||
) {
|
||||
Function<OpTemplate, ParsedOp> f = t -> new ParsedOp(t, cfg, parsers);
|
||||
Function<OpTemplate, OpDispenser<O>> opTemplateOFunction = f.andThen(opinit);
|
||||
Function<OpTemplate, OpDispenser<? extends O>> opTemplateOFunction = f.andThen(opinit);
|
||||
return createOpSequence(opTemplateOFunction);
|
||||
}
|
||||
|
||||
@@ -459,14 +459,14 @@ public class SimpleActivity implements Activity, ProgressCapable {
|
||||
* @return The sequence of operations as determined by filtering and ratios
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
protected <O> OpSequence<OpDispenser<O>> createOpSequence(Function<OpTemplate, OpDispenser<O>> opinit) {
|
||||
protected <O> OpSequence<OpDispenser<? extends O>> createOpSequence(Function<OpTemplate, OpDispenser<? extends O>> opinit) {
|
||||
String tagfilter = activityDef.getParams().getOptionalString("tags").orElse("");
|
||||
StrInterpolator interp = new StrInterpolator(activityDef);
|
||||
// StrInterpolator interp = new StrInterpolator(activityDef);
|
||||
SequencerType sequencerType = getParams()
|
||||
.getOptionalString("seq")
|
||||
.map(SequencerType::valueOf)
|
||||
.orElse(SequencerType.bucket);
|
||||
SequencePlanner<OpDispenser<O>> planner = new SequencePlanner<>(sequencerType);
|
||||
SequencePlanner<OpDispenser<? extends O>> planner = new SequencePlanner<>(sequencerType);
|
||||
|
||||
StmtsDocList stmtsDocList = null;
|
||||
|
||||
@@ -475,10 +475,10 @@ public class SimpleActivity implements Activity, ProgressCapable {
|
||||
Optional<String> stmt = activityDef.getParams().getOptionalString("op", "stmt", "statement");
|
||||
Optional<String> op_yaml_loc = activityDef.getParams().getOptionalString("yaml", "workload");
|
||||
if (stmt.isPresent()) {
|
||||
stmtsDocList = StatementsLoader.loadStmt(logger, stmt.get(), interp);
|
||||
stmtsDocList = StatementsLoader.loadStmt(logger, stmt.get(), activityDef.getParams());
|
||||
workloadSource = "commandline:" + stmt.get();
|
||||
} else if (op_yaml_loc.isPresent()) {
|
||||
stmtsDocList = StatementsLoader.loadPath(logger, op_yaml_loc.get(), interp, "activities");
|
||||
stmtsDocList = StatementsLoader.loadPath(logger, op_yaml_loc.get(), activityDef.getParams(), "activities");
|
||||
workloadSource = "yaml:" + op_yaml_loc.get();
|
||||
}
|
||||
|
||||
@@ -500,7 +500,7 @@ public class SimpleActivity implements Activity, ProgressCapable {
|
||||
for (int i = 0; i < stmts.size(); i++) {
|
||||
long ratio = ratios.get(i);
|
||||
OpTemplate optemplate = stmts.get(i);
|
||||
OpDispenser<O> driverSpecificReadyOp = opinit.apply(optemplate);
|
||||
OpDispenser<? extends O> driverSpecificReadyOp = opinit.apply(optemplate);
|
||||
planner.addOp(driverSpecificReadyOp, ratio);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -5,9 +5,9 @@ import io.nosqlbench.engine.api.activityapi.planning.OpSequence;
|
||||
import io.nosqlbench.engine.api.activityapi.planning.OpSource;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.engine.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.engine.api.activityimpl.OpMapper;
|
||||
import io.nosqlbench.engine.api.activityimpl.SimpleActivity;
|
||||
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.engine.api.templating.ParsedOp;
|
||||
import io.nosqlbench.nb.api.errors.OpConfigError;
|
||||
|
||||
import java.util.List;
|
||||
@@ -27,14 +27,15 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity {
|
||||
private final DriverAdapter<R, S> adapter;
|
||||
private final OpSource<R> opsource;
|
||||
private NBErrorHandler errorHandler;
|
||||
private final OpSequence<OpDispenser<R>> sequence;
|
||||
private final OpSequence<OpDispenser<? extends R>> sequence;
|
||||
|
||||
public StandardActivity(DriverAdapter<R, S> adapter, ActivityDef activityDef) {
|
||||
super(activityDef);
|
||||
this.adapter = adapter;
|
||||
|
||||
try {
|
||||
Function<ParsedOp, OpDispenser<R>> opmapper = adapter.getOpMapper();
|
||||
// Function<ParsedOp, OpDispenser<R>> opmapper;
|
||||
OpMapper<R> opmapper = adapter.getOpMapper();
|
||||
Function<Map<String, Object>, Map<String, Object>> preprocessor = adapter.getPreprocessor();
|
||||
sequence = createOpSourceFromCommands(opmapper, adapter.getConfiguration(), List.of(preprocessor));
|
||||
opsource = OpSource.of(sequence);
|
||||
@@ -53,7 +54,7 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity {
|
||||
setDefaultsFromOpSequence(sequence);
|
||||
}
|
||||
|
||||
public OpSequence<OpDispenser<R>> getOpSequence() {
|
||||
public OpSequence<OpDispenser<? extends R>> getOpSequence() {
|
||||
return sequence;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user