use of io.nosqlbench.virtdata.core.templates.BindPoint in project nosqlbench by nosqlbench.
the class ReadyMongoStatementTest method testResolvePhaseMainWrite.
@Test
public void testResolvePhaseMainWrite() {
String tagfilter = activityDef.getParams().getOptionalString("tags").orElse("phase:main,name:.*main-insert");
List<OpTemplate> stmts = stmtsDocList.getStmts(tagfilter);
assertThat(stmts).hasSize(1);
for (OpTemplate stmt : stmts) {
ParsedTemplate parsed = stmt.getParsed().orElseThrow();
assertThat(parsed.getBindPoints()).hasSize(2);
BindPoint rwKey = new BindPoint("rw_key", "Uniform(0,1000000)->long; ToInt()");
BindPoint rwValue = new BindPoint("rw_value", "Uniform(0,1000000000)->int; Hash(); ToString() -> String");
assertThat(parsed.getBindPoints()).containsExactly(rwKey, rwValue);
String statement = parsed.getPositionalStatement(Function.identity());
Objects.requireNonNull(statement);
ReadyMongoStatement readyMongoStatement = new ReadyMongoStatement(stmt);
Bson bsonDoc = readyMongoStatement.bind(1L);
assertThat(bsonDoc).isNotNull();
}
}
use of io.nosqlbench.virtdata.core.templates.BindPoint in project nosqlbench by nosqlbench.
the class ReadyMongoStatementTest method testResolvePhaseMainRead.
@Test
public void testResolvePhaseMainRead() {
String tagfilter = activityDef.getParams().getOptionalString("tags").orElse("phase:main,name:.*main-find");
List<OpTemplate> stmts = stmtsDocList.getStmts(tagfilter);
assertThat(stmts).hasSize(1);
for (OpTemplate stmt : stmts) {
ParsedTemplate parsed = stmt.getParsed().orElseThrow();
assertThat(parsed.getBindPoints()).hasSize(1);
BindPoint rwKey = new BindPoint("rw_key", "Uniform(0,1000000)->long; ToInt()");
assertThat(parsed.getBindPoints()).containsExactly(rwKey);
String statement = parsed.getPositionalStatement(Function.identity());
Objects.requireNonNull(statement);
ReadyMongoStatement readyMongoStatement = new ReadyMongoStatement(stmt);
Bson bsonDoc = readyMongoStatement.bind(1L);
assertThat(bsonDoc).isNotNull();
}
}
use of io.nosqlbench.virtdata.core.templates.BindPoint in project nosqlbench by nosqlbench.
the class ReadyMongoStatementTest method testResolvePhaseRampup.
@Test
public void testResolvePhaseRampup() {
String tagfilter = activityDef.getParams().getOptionalString("tags").orElse("phase:rampup");
List<OpTemplate> stmts = stmtsDocList.getStmts(tagfilter);
assertThat(stmts).hasSize(1);
for (OpTemplate stmt : stmts) {
ParsedTemplate parsed = stmt.getParsed().orElseThrow();
assertThat(parsed.getBindPoints()).hasSize(2);
BindPoint seqKey = new BindPoint("seq_key", "Mod(1000000L); ToInt()");
BindPoint seqValue = new BindPoint("seq_value", "Mod(1000000000L); Hash(); ToString() -> String");
assertThat(parsed.getBindPoints()).containsExactly(seqKey, seqValue);
String statement = parsed.getPositionalStatement(Function.identity());
Objects.requireNonNull(statement);
ReadyMongoStatement readyMongoStatement = new ReadyMongoStatement(stmt);
Bson bsonDoc = readyMongoStatement.bind(1L);
assertThat(bsonDoc).isNotNull();
}
}
use of io.nosqlbench.virtdata.core.templates.BindPoint in project nosqlbench by nosqlbench.
the class VirtData method getTemplate.
// /**
// * Create a bindings template from the provided map, ensuring that
// * the syntax of the bindings specs is parsable first.
// *
// * @param namedBindings The named bindings map
// * @return a bindings template
// */
// public static BindingsTemplate getTemplate(Map<String, String> namedBindings) {
//
// for (String bindingSpec : namedBindings.values()) {
// VirtDataDSL.ParseResult parseResult = VirtDataDSL.parse(bindingSpec);
// if (parseResult.throwable != null) {
// throw new RuntimeException(parseResult.throwable);
// }
// }
// return new BindingsTemplate(namedBindings);
// }
/**
* Create a bindings template from a provided list of {@link BindPoint}s,
* ensuring that the syntax of the bindings specs is parsable first.
*
* @param bindPoints A list of {@link BindPoint}s
* @return A BindingsTemplate
*/
public static BindingsTemplate getTemplate(Map<String, Object> config, List<BindPoint> bindPoints) {
for (BindPoint bindPoint : bindPoints) {
String bindspec = bindPoint.getBindspec();
VirtDataDSL.ParseResult parseResult = VirtDataDSL.parse(bindspec);
if (parseResult.throwable != null) {
throw new RuntimeException(parseResult.throwable);
}
}
return new BindingsTemplate(config, bindPoints);
}
Aggregations