Search in sources :

Example 1 with BindPoint

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();
    }
}
Also used : OpTemplate(io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate) ParsedTemplate(io.nosqlbench.virtdata.core.templates.ParsedTemplate) BindPoint(io.nosqlbench.virtdata.core.templates.BindPoint) Bson(org.bson.conversions.Bson) Test(org.junit.jupiter.api.Test)

Example 2 with BindPoint

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();
    }
}
Also used : OpTemplate(io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate) ParsedTemplate(io.nosqlbench.virtdata.core.templates.ParsedTemplate) BindPoint(io.nosqlbench.virtdata.core.templates.BindPoint) Bson(org.bson.conversions.Bson) Test(org.junit.jupiter.api.Test)

Example 3 with BindPoint

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();
    }
}
Also used : OpTemplate(io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate) ParsedTemplate(io.nosqlbench.virtdata.core.templates.ParsedTemplate) BindPoint(io.nosqlbench.virtdata.core.templates.BindPoint) Bson(org.bson.conversions.Bson) Test(org.junit.jupiter.api.Test)

Example 4 with BindPoint

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);
}
Also used : VirtDataDSL(io.nosqlbench.virtdata.lang.parser.VirtDataDSL) BindPoint(io.nosqlbench.virtdata.core.templates.BindPoint)

Aggregations

BindPoint (io.nosqlbench.virtdata.core.templates.BindPoint)4 OpTemplate (io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate)3 ParsedTemplate (io.nosqlbench.virtdata.core.templates.ParsedTemplate)3 Bson (org.bson.conversions.Bson)3 Test (org.junit.jupiter.api.Test)3 VirtDataDSL (io.nosqlbench.virtdata.lang.parser.VirtDataDSL)1