mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2026-08-10 04:58:08 -05:00
remove unused classes
This commit is contained in:
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,7 +26,7 @@ import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlPreparedStatement;
|
||||
import io.nosqlbench.engine.api.activityimpl.uniform.DriverAdapter;
|
||||
import io.nosqlbench.engine.api.templating.ParsedOp;
|
||||
import io.nosqlbench.api.errors.OpConfigError;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedStringTemplate;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -37,13 +37,13 @@ public class Cqld4PreparedStmtDispenser extends Cqld4BaseOpDispenser {
|
||||
|
||||
private final RSProcessors processors;
|
||||
private final LongFunction<Statement> stmtFunc;
|
||||
private final ParsedStringTemplate stmtTpl;
|
||||
private final ParsedTemplateString stmtTpl;
|
||||
private final LongFunction<Object[]> fieldsF;
|
||||
private PreparedStatement preparedStmt;
|
||||
private CqlSession boundSession;
|
||||
|
||||
public Cqld4PreparedStmtDispenser(
|
||||
DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, ParsedOp op, ParsedStringTemplate stmtTpl, RSProcessors processors) {
|
||||
DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, 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 supported." +
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,7 +30,7 @@ import io.nosqlbench.engine.api.templating.ParsedOp;
|
||||
import io.nosqlbench.engine.api.templating.TypeAndTarget;
|
||||
import io.nosqlbench.api.config.params.ParamsParser;
|
||||
import io.nosqlbench.api.errors.BasicError;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedStringTemplate;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -51,7 +51,7 @@ public class CqlD4PreparedStmtMapper implements OpMapper<Cqld4CqlOp> {
|
||||
|
||||
public OpDispenser<Cqld4CqlOp> apply(ParsedOp op) {
|
||||
|
||||
ParsedStringTemplate stmtTpl = op.getAsTemplate(target.field).orElseThrow(() -> new BasicError(
|
||||
ParsedTemplateString stmtTpl = op.getAsTemplate(target.field).orElseThrow(() -> new BasicError(
|
||||
"No statement was found in the op template:" + op
|
||||
));
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,7 @@ import io.nosqlbench.engine.api.templating.TypeAndTarget;
|
||||
import io.nosqlbench.api.errors.OpConfigError;
|
||||
import io.nosqlbench.virtdata.core.bindings.Bindings;
|
||||
import io.nosqlbench.virtdata.core.bindings.BindingsTemplate;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedStringTemplate;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
|
||||
@@ -63,7 +63,7 @@ public class Cqld4FluentGraphOpMapper implements OpMapper<Op> {
|
||||
public OpDispenser<? extends Op> apply(ParsedOp op) {
|
||||
GraphTraversalSource g = DseGraph.g;
|
||||
|
||||
ParsedStringTemplate fluent = op.getAsTemplate(target.field).orElseThrow();
|
||||
ParsedTemplateString fluent = op.getAsTemplate(target.field).orElseThrow();
|
||||
String scriptBodyWithRawVarRefs = fluent.getPositionalStatement();
|
||||
|
||||
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
|
||||
|
||||
+6
-6
@@ -23,7 +23,7 @@ import io.nosqlbench.api.config.params.Element;
|
||||
import io.nosqlbench.api.config.params.NBParams;
|
||||
import io.nosqlbench.api.config.standard.NBTypeConverter;
|
||||
import io.nosqlbench.api.errors.OpConfigError;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedStringTemplate;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
@@ -170,9 +170,9 @@ public abstract class OpTemplate implements Tagged {
|
||||
* Parse the statement for anchors and return a richer view of the StmtDef which
|
||||
* is simpler to use for most statement configuration needs.
|
||||
*
|
||||
* @return an optional {@link ParsedStringTemplate}
|
||||
* @return an optional {@link ParsedTemplateString}
|
||||
*/
|
||||
public Optional<ParsedStringTemplate> getParsed(Function<String, String>... rewriters) {
|
||||
public Optional<ParsedTemplateString> getParsed(Function<String, String>... rewriters) {
|
||||
Optional<String> os = getStmt();
|
||||
return os.map(s -> {
|
||||
String result = s;
|
||||
@@ -180,11 +180,11 @@ public abstract class OpTemplate implements Tagged {
|
||||
result = rewriter.apply(result);
|
||||
}
|
||||
return result;
|
||||
}).map(s -> new ParsedStringTemplate(s, getBindings()));
|
||||
}).map(s -> new ParsedTemplateString(s, getBindings()));
|
||||
}
|
||||
|
||||
public Optional<ParsedStringTemplate> getParsed() {
|
||||
return getStmt().map(s -> new ParsedStringTemplate(s, getBindings()));
|
||||
public Optional<ParsedTemplateString> getParsed() {
|
||||
return getStmt().map(s -> new ParsedTemplateString(s, getBindings()));
|
||||
}
|
||||
|
||||
public abstract Optional<Map<String, Object>> getOp();
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform.flowtypes;
|
||||
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedStringTemplate;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.Map;
|
||||
* If an op implements VariableCapture, then it is known to be able to
|
||||
* extract variables from its result. Generally speaking, this should
|
||||
* be implemented within an Op according to the standard format
|
||||
* of {@link ParsedStringTemplate#getCaptures()}. Any op implementing
|
||||
* of {@link ParsedTemplateString#getCaptures()}. Any op implementing
|
||||
* this should use the interface below to support interop between adapters
|
||||
* and to allow for auto documentation tha the feature is supported for
|
||||
* a given adapter.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,7 @@ import io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.api.config.params.ParamsParser;
|
||||
import io.nosqlbench.api.errors.BasicError;
|
||||
import io.nosqlbench.virtdata.core.bindings.BindingsTemplate;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedStringTemplate;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
import io.nosqlbench.virtdata.core.templates.StringBindings;
|
||||
import io.nosqlbench.virtdata.core.templates.StringBindingsTemplate;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -160,7 +160,7 @@ public class CommandTemplate {
|
||||
cmd.putAll(params);
|
||||
|
||||
cmd.forEach((param, value) -> {
|
||||
ParsedStringTemplate paramTemplate = new ParsedStringTemplate(value, bindings);
|
||||
ParsedTemplateString paramTemplate = new ParsedTemplateString(value, bindings);
|
||||
if (paramTemplate.getBindPoints().size() > 0) {
|
||||
BindingsTemplate paramBindings = new BindingsTemplate(paramTemplate.getBindPoints());
|
||||
StringBindings paramStringBindings = new StringBindingsTemplate(value, paramBindings).resolve();
|
||||
|
||||
@@ -16,18 +16,18 @@
|
||||
|
||||
package io.nosqlbench.engine.api.templating;
|
||||
|
||||
import io.nosqlbench.api.config.fieldreaders.DynamicFieldReader;
|
||||
import io.nosqlbench.api.config.fieldreaders.StaticFieldReader;
|
||||
import io.nosqlbench.api.config.standard.NBConfigError;
|
||||
import io.nosqlbench.api.config.standard.NBConfiguration;
|
||||
import io.nosqlbench.api.errors.OpConfigError;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.engine.api.templating.binders.ArrayBinder;
|
||||
import io.nosqlbench.engine.api.templating.binders.ListBinder;
|
||||
import io.nosqlbench.engine.api.templating.binders.OrderedMapBinder;
|
||||
import io.nosqlbench.api.config.fieldreaders.DynamicFieldReader;
|
||||
import io.nosqlbench.api.config.fieldreaders.StaticFieldReader;
|
||||
import io.nosqlbench.api.config.standard.NBConfiguration;
|
||||
import io.nosqlbench.api.errors.OpConfigError;
|
||||
import io.nosqlbench.virtdata.core.templates.BindPoint;
|
||||
import io.nosqlbench.virtdata.core.templates.CapturePoint;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedStringTemplate;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -426,7 +426,7 @@ public class ParsedOp implements LongFunction<Map<String, ?>>, StaticFieldReader
|
||||
return tmap.getStaticValue(field);
|
||||
}
|
||||
|
||||
public Optional<ParsedStringTemplate> getAsTemplate(String fieldname) {
|
||||
public Optional<ParsedTemplateString> getAsTemplate(String fieldname) {
|
||||
return this.tmap.getAsStringTemplate(fieldname);
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -17,7 +17,7 @@
|
||||
package io.nosqlbench.engine.api.activityconfig.yaml;
|
||||
|
||||
import io.nosqlbench.engine.api.activityconfig.OpsLoader;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedStringTemplate;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@@ -27,8 +27,8 @@ import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ParsedOpTemplateTest {
|
||||
private static final Logger logger = LogManager.getLogger(ParsedOpTemplateTest.class);
|
||||
public class ParsedWorkloadTemplateTest {
|
||||
private static final Logger logger = LogManager.getLogger(ParsedWorkloadTemplateTest.class);
|
||||
private static OpsDocList doclist;
|
||||
|
||||
@BeforeAll
|
||||
@@ -40,13 +40,13 @@ public class ParsedOpTemplateTest {
|
||||
public void testBasicParser() {
|
||||
OpsBlock block0 = doclist.getStmtDocs().get(0).getBlocks().get(0);
|
||||
OpTemplate stmtDef0 = block0.getOps().get(0);
|
||||
ParsedStringTemplate parsed0 = stmtDef0.getParsed().orElseThrow();
|
||||
ParsedTemplateString parsed0 = stmtDef0.getParsed().orElseThrow();
|
||||
assertThat(parsed0.getMissing()).containsExactly("delta");
|
||||
assertThat(parsed0.hasError()).isTrue();
|
||||
|
||||
OpsBlock block1 = doclist.getStmtDocs().get(0).getBlocks().get(1);
|
||||
OpTemplate stmtDef1 = block1.getOps().get(0);
|
||||
ParsedStringTemplate parsed1 = stmtDef1.getParsed().orElseThrow();
|
||||
ParsedTemplateString parsed1 = stmtDef1.getParsed().orElseThrow();
|
||||
assertThat(parsed1.getMissing()).containsExactly();
|
||||
assertThat(parsed1.hasError()).isFalse();
|
||||
}
|
||||
@@ -56,12 +56,12 @@ public class ParsedOpTemplateTest {
|
||||
OpsBlock block2 = doclist.getStmtDocs().get(0).getBlocks().get(2);
|
||||
|
||||
OpTemplate stmtDef0 = block2.getOps().get(0);
|
||||
ParsedStringTemplate parsed0 = stmtDef0.getParsed().orElseThrow();
|
||||
ParsedTemplateString parsed0 = stmtDef0.getParsed().orElseThrow();
|
||||
assertThat(parsed0.getMissing()).isEmpty();
|
||||
assertThat(parsed0.hasError()).isFalse();
|
||||
|
||||
OpTemplate stmtDef1 = block2.getOps().get(1);
|
||||
ParsedStringTemplate parsed1 = stmtDef1.getParsed().orElseThrow();
|
||||
ParsedTemplateString parsed1 = stmtDef1.getParsed().orElseThrow();
|
||||
assertThat(parsed1.getMissing()).isEmpty();
|
||||
assertThat(parsed1.hasError()).isFalse();
|
||||
}
|
||||
+4
-3
@@ -30,7 +30,7 @@ import io.nosqlbench.virtdata.core.bindings.DataMapper;
|
||||
import io.nosqlbench.virtdata.core.bindings.VirtData;
|
||||
import io.nosqlbench.virtdata.core.templates.BindPoint;
|
||||
import io.nosqlbench.virtdata.core.templates.CapturePoint;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedStringTemplate;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
import io.nosqlbench.virtdata.core.templates.StringBindings;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -701,11 +701,11 @@ public class ParsedTemplateMap implements LongFunction<Map<String, ?>>, StaticFi
|
||||
return false;
|
||||
}
|
||||
|
||||
public Optional<ParsedStringTemplate> getAsStringTemplate(String fieldname) {
|
||||
public Optional<ParsedTemplateString> getAsStringTemplate(String fieldname) {
|
||||
if (specmap.containsKey(fieldname)) {
|
||||
Object fval = specmap.get(fieldname);
|
||||
if (fval instanceof CharSequence) {
|
||||
return Optional.of(new ParsedStringTemplate(fval.toString(), this.bindings));
|
||||
return Optional.of(new ParsedTemplateString(fval.toString(), this.bindings));
|
||||
} else {
|
||||
throw new RuntimeException("Can not make a parsed text template from op template field '" + fieldname + "' of type '" + fval.getClass().getSimpleName() + "'");
|
||||
}
|
||||
@@ -988,4 +988,5 @@ public class ParsedTemplateMap implements LongFunction<Map<String, ?>>, StaticFi
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import io.nosqlbench.api.errors.OpConfigError;
|
||||
import io.nosqlbench.virtdata.core.bindings.DataMapper;
|
||||
import io.nosqlbench.virtdata.core.bindings.VirtData;
|
||||
import io.nosqlbench.virtdata.core.templates.CapturePoint;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedStringTemplate;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplateString;
|
||||
import io.nosqlbench.virtdata.core.templates.StringBindings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -36,7 +36,7 @@ public class Templatizer {
|
||||
result.setName(name);
|
||||
|
||||
if (v instanceof CharSequence) {
|
||||
ParsedStringTemplate pt = ParsedStringTemplate.of(((CharSequence) v).toString(), bindings);
|
||||
ParsedTemplateString pt = ParsedTemplateString.of(((CharSequence) v).toString(), bindings);
|
||||
result.addCaptures(pt.getCaptures());
|
||||
result.setType(pt.getType());
|
||||
switch (pt.getType()) {
|
||||
|
||||
@@ -92,7 +92,7 @@ public class BindPoint {
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the anchor for a binding as it appears in a user-specified template, parsed by {@link ParsedStringTemplate}.
|
||||
* The name of the anchor for a binding as it appears in a user-specified template, parsed by {@link ParsedTemplateString}.
|
||||
* @return A string name for the bind point anchor, or null for {@link BindPoint.Type#definition} types.
|
||||
*/
|
||||
public String getAnchor() {
|
||||
|
||||
+7
-7
@@ -74,7 +74,7 @@ import java.util.stream.StreamSupport;
|
||||
* <LI>provide a text template for re-assembly with injected data</LI>
|
||||
* </UL>
|
||||
*
|
||||
* Once the parsed template is constructed, the method {@link ParsedStringTemplate#orError()}
|
||||
* Once the parsed template is constructed, the method {@link ParsedTemplateString#orError()}
|
||||
* should <em>always</em> called before it is used.
|
||||
*
|
||||
* <H2>Validity Checks</H2>
|
||||
@@ -106,16 +106,16 @@ import java.util.stream.StreamSupport;
|
||||
* This is a list of binding names which were provided by the user, but which were not used in the raw template by name.
|
||||
* </p>
|
||||
*/
|
||||
public class ParsedStringTemplate {
|
||||
public class ParsedTemplateString {
|
||||
|
||||
private final static Logger logger = LogManager.getLogger(ParsedStringTemplate.class);
|
||||
private final static Logger logger = LogManager.getLogger(ParsedTemplateString.class);
|
||||
|
||||
private final String rawtemplate;
|
||||
private final List<CapturePoint> captures = new ArrayList<>();
|
||||
private final List<BindPoint> bindpoints;
|
||||
|
||||
public static ParsedStringTemplate of(String rawtemplate, Map<String, String> bindings) {
|
||||
return new ParsedStringTemplate(rawtemplate, bindings);
|
||||
public static ParsedTemplateString of(String rawtemplate, Map<String, String> bindings) {
|
||||
return new ParsedTemplateString(rawtemplate, bindings);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,7 +136,7 @@ public class ParsedStringTemplate {
|
||||
* @param rawtemplate A string template which contains optionally embedded named anchors
|
||||
* @param availableBindings The bindings which are provided by the user to fulfill the named anchors in this raw template
|
||||
*/
|
||||
public ParsedStringTemplate(String rawtemplate, Map<String, String> availableBindings) {
|
||||
public ParsedTemplateString(String rawtemplate, Map<String, String> availableBindings) {
|
||||
this.bindings.putAll(availableBindings);
|
||||
this.rawtemplate = rawtemplate;
|
||||
|
||||
@@ -160,7 +160,7 @@ public class ParsedStringTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
public ParsedStringTemplate orError() {
|
||||
public ParsedTemplateString orError() {
|
||||
if (hasError()) {
|
||||
throw new RuntimeException("Unable to parse statement: " + this);
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,15 +37,15 @@ public class StringBindings implements Binder<String> {
|
||||
}
|
||||
|
||||
public StringBindings(String template, Map<String,String> bindings, Map<String,Object> fconfig) {
|
||||
ParsedStringTemplate parsed = new ParsedStringTemplate(template,bindings);
|
||||
ParsedTemplateString parsed = new ParsedTemplateString(template,bindings);
|
||||
this.compositor = new StringCompositor(parsed, fconfig);
|
||||
}
|
||||
|
||||
public StringBindings(ParsedStringTemplate parsedStringTemplate) {
|
||||
public StringBindings(ParsedTemplateString parsedStringTemplate) {
|
||||
this(parsedStringTemplate, Map.of());
|
||||
}
|
||||
|
||||
public StringBindings(ParsedStringTemplate pt, Map<String,Object> fconfig) {
|
||||
public StringBindings(ParsedTemplateString pt, Map<String,Object> fconfig) {
|
||||
this.compositor = new StringCompositor(pt,fconfig);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,7 +40,7 @@ public class StringCompositor implements LongFunction<String> {
|
||||
|
||||
private final Function<Object, String> stringfunc;
|
||||
|
||||
public StringCompositor(ParsedStringTemplate template, Map<String,Object> fconfig, Function<Object,String> stringfunc) {
|
||||
public StringCompositor(ParsedTemplateString template, Map<String,Object> fconfig, Function<Object,String> stringfunc) {
|
||||
Map<String,Integer> specs = new HashMap<>();
|
||||
List<BindPoint> bindpoints = template.getBindPoints();
|
||||
for (BindPoint bindPoint : bindpoints) {
|
||||
@@ -69,7 +69,7 @@ public class StringCompositor implements LongFunction<String> {
|
||||
bufsize = minsize*2;
|
||||
}
|
||||
|
||||
public StringCompositor(ParsedStringTemplate template, Map<String,Object> fconfig) {
|
||||
public StringCompositor(ParsedTemplateString template, Map<String,Object> fconfig) {
|
||||
this(template,fconfig,Object::toString);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,7 +28,7 @@ public class FastStringCompositorTest {
|
||||
public void testFastStringCompositor() {
|
||||
String rawTpl = "template {b1}, {{TestValue(5)}}";
|
||||
Map<String, String> bindings = Map.of("b1", "TestIdentity()");
|
||||
ParsedStringTemplate ptpl = new ParsedStringTemplate(rawTpl, bindings);
|
||||
ParsedTemplateString ptpl = new ParsedTemplateString(rawTpl, bindings);
|
||||
StringCompositor fsc = new StringCompositor(ptpl,Map.of());
|
||||
System.out.println(fsc);
|
||||
}
|
||||
|
||||
+11
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
package io.nosqlbench.virtdata.core.templates;
|
||||
|
||||
import io.nosqlbench.engine.api.templating.BindType;
|
||||
import io.nosqlbench.engine.api.templating.ParsedSpanType;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ParsedStringTemplateTest {
|
||||
public class ParsedTemplateStringTest {
|
||||
|
||||
private final Map<String, String> bindings = Map.of(
|
||||
"bindname1", "bindspec1",
|
||||
@@ -32,7 +32,7 @@ public class ParsedStringTemplateTest {
|
||||
@Test
|
||||
public void testShouldMatchRawLiteral() {
|
||||
String rawNothing = "This has no anchors";
|
||||
ParsedStringTemplate pt = new ParsedStringTemplate(rawNothing, bindings);
|
||||
ParsedTemplateString pt = new ParsedTemplateString(rawNothing, bindings);
|
||||
assertThat(pt.getSpans()).containsExactly("This has no anchors");
|
||||
assertThat(pt.getBindPoints()).isEmpty();
|
||||
assertThat(pt.getMissing()).isEmpty();
|
||||
@@ -41,7 +41,7 @@ public class ParsedStringTemplateTest {
|
||||
@Test
|
||||
public void testShouldIgnoreExtraneousAnchors() {
|
||||
String oneExtraneous = "An {this is an extraneous form} invalid anchor.";
|
||||
ParsedStringTemplate pt = new ParsedStringTemplate(oneExtraneous, bindings);
|
||||
ParsedTemplateString pt = new ParsedTemplateString(oneExtraneous, bindings);
|
||||
assertThat(pt.getSpans()).containsExactly("An {this is an extraneous form} invalid anchor.");
|
||||
assertThat(pt.getBindPoints()).isEmpty();
|
||||
assertThat(pt.getMissing()).isEmpty();
|
||||
@@ -50,7 +50,7 @@ public class ParsedStringTemplateTest {
|
||||
@Test
|
||||
public void testShouldAllowArbitraryNonGreedyInExtendedBindPoint() {
|
||||
String oneExtendedBindPoint = "An {{this is an extended form}} {{and another}} invalid anchor.";
|
||||
ParsedStringTemplate pt = new ParsedStringTemplate(oneExtendedBindPoint, bindings);
|
||||
ParsedTemplateString pt = new ParsedTemplateString(oneExtendedBindPoint, bindings);
|
||||
assertThat(pt.getSpans()).containsExactly("An ","this is an extended form"," ","and another"," invalid anchor.");
|
||||
assertThat(pt.getAnchors()).containsExactly("this is an extended form","and another");
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class ParsedStringTemplateTest {
|
||||
@Test
|
||||
public void testShouldMatchLiteralVariableOnly() {
|
||||
String literalVariableOnly = "literal {bindname1}";
|
||||
ParsedStringTemplate pt = new ParsedStringTemplate(literalVariableOnly, bindings);
|
||||
ParsedTemplateString pt = new ParsedTemplateString(literalVariableOnly, bindings);
|
||||
assertThat(pt.getSpans()).containsExactly("literal ", "bindname1", "");
|
||||
assertThat(pt.getAnchors()).containsOnly("bindname1");
|
||||
assertThat(pt.getMissing()).isEmpty();
|
||||
@@ -67,7 +67,7 @@ public class ParsedStringTemplateTest {
|
||||
@Test
|
||||
public void testShouldMatchVariableLiteralOnly() {
|
||||
String variableLiteralOnly = "{bindname2} literal";
|
||||
ParsedStringTemplate pt = new ParsedStringTemplate(variableLiteralOnly, bindings);
|
||||
ParsedTemplateString pt = new ParsedTemplateString(variableLiteralOnly, bindings);
|
||||
assertThat(pt.getSpans()).containsExactly("", "bindname2", " literal");
|
||||
assertThat(pt.getAnchors()).containsOnly("bindname2");
|
||||
assertThat(pt.getMissing()).isEmpty();
|
||||
@@ -76,7 +76,7 @@ public class ParsedStringTemplateTest {
|
||||
@Test
|
||||
public void testPositionalExpansionShouldBeValid() {
|
||||
String multi = "A {bindname1} of {bindname2} sort.";
|
||||
ParsedStringTemplate pt = new ParsedStringTemplate(multi, bindings);
|
||||
ParsedTemplateString pt = new ParsedTemplateString(multi, bindings);
|
||||
assertThat(pt.getSpans()).containsExactly("A ", "bindname1", " of ", "bindname2", " sort.");
|
||||
assertThat(pt.getAnchors()).containsOnly("bindname1", "bindname2");
|
||||
assertThat(pt.getMissing()).isEmpty();
|
||||
@@ -91,11 +91,11 @@ public class ParsedStringTemplateTest {
|
||||
|
||||
@Test
|
||||
public void shouldMatchBasicCapturePoint() {
|
||||
ParsedStringTemplate pt = new ParsedStringTemplate(
|
||||
ParsedTemplateString pt = new ParsedTemplateString(
|
||||
"select [u],[v as v1] from users where userid={userid}", Map.of("userid", "NumberNameToString()")
|
||||
);
|
||||
assertThat(pt.getAnchors()).containsExactly("userid");
|
||||
assertThat(pt.getType()).isEqualTo(BindType.concat);
|
||||
assertThat(pt.getType()).isEqualTo(ParsedSpanType.concat);
|
||||
assertThat(pt.getCaptures()).containsExactly(CapturePoint.of("u"),CapturePoint.of("v","v1"));
|
||||
|
||||
}
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,13 +26,13 @@ public class StringCompositorTest {
|
||||
|
||||
@Test
|
||||
public void testShouldMatchSpanOnly() {
|
||||
ParsedStringTemplate pt = new ParsedStringTemplate("A\\{ {one}two", Map.of());
|
||||
ParsedTemplateString pt = new ParsedTemplateString("A\\{ {one}two", Map.of());
|
||||
assertThat(pt.getSpans()).containsExactly("A\\{ ", "one", "two");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldNotMatchEscaped() {
|
||||
ParsedStringTemplate pt = new ParsedStringTemplate("A\\{{B}C",Map.of());
|
||||
ParsedTemplateString pt = new ParsedTemplateString("A\\{{B}C",Map.of());
|
||||
assertThat(pt.getSpans()).containsExactly("A\\{","B","C");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user