mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2026-08-13 06:24:57 -05:00
merged my-NB5-I446 with main
This commit is contained in:
+17
-14
@@ -20,6 +20,8 @@ import io.nosqlbench.api.config.standard.*;
|
||||
import io.nosqlbench.engine.api.activityimpl.uniform.fieldmappers.FieldDestructuringMapper;
|
||||
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.engine.api.templating.ParsedOp;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -29,7 +31,8 @@ import java.util.function.Function;
|
||||
import java.util.function.LongFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class BaseDriverAdapter<R extends Op,S> implements DriverAdapter<R,S>, NBConfigurable, NBReconfigurable {
|
||||
public abstract class BaseDriverAdapter<R extends Op, S> implements DriverAdapter<R, S>, NBConfigurable, NBReconfigurable {
|
||||
private final static Logger logger = LogManager.getLogger("ADAPTER");
|
||||
|
||||
private DriverSpaceCache<? extends S> spaceCache;
|
||||
private NBConfiguration cfg;
|
||||
@@ -43,22 +46,22 @@ public abstract class BaseDriverAdapter<R extends Op,S> implements DriverAdapter
|
||||
*/
|
||||
@Override
|
||||
public final Function<Map<String, Object>, Map<String, Object>> getPreprocessor() {
|
||||
List<Function<Map<String,Object>,Map<String,Object>>> mappers = new ArrayList<>();
|
||||
List<Function<Map<String,Object>,Map<String,Object>>> stmtRemappers =
|
||||
List<Function<Map<String, Object>, Map<String, Object>>> mappers = new ArrayList<>();
|
||||
List<Function<Map<String, Object>, Map<String, Object>>> stmtRemappers =
|
||||
getOpStmtRemappers().stream()
|
||||
.map(m -> new FieldDestructuringMapper("stmt",m))
|
||||
.map(m -> new FieldDestructuringMapper("stmt", m))
|
||||
.collect(Collectors.toList());
|
||||
mappers.addAll(stmtRemappers);
|
||||
mappers.addAll(getOpFieldRemappers());
|
||||
|
||||
if (mappers.size()==0) {
|
||||
if (mappers.size() == 0) {
|
||||
return (i) -> i;
|
||||
}
|
||||
|
||||
Function<Map<String,Object>,Map<String,Object>> remapper = null;
|
||||
Function<Map<String, Object>, Map<String, Object>> remapper = null;
|
||||
for (int i = 0; i < mappers.size(); i++) {
|
||||
if (i==0) {
|
||||
remapper=mappers.get(i);
|
||||
if (i == 0) {
|
||||
remapper = mappers.get(i);
|
||||
} else {
|
||||
remapper = remapper.andThen(mappers.get(i));
|
||||
}
|
||||
@@ -102,7 +105,7 @@ public abstract class BaseDriverAdapter<R extends Op,S> implements DriverAdapter
|
||||
*
|
||||
* @return A list of optionally applied remapping functions.
|
||||
*/
|
||||
public List<Function<String, Optional<Map<String,Object>>>> getOpStmtRemappers() {
|
||||
public List<Function<String, Optional<Map<String, Object>>>> getOpStmtRemappers() {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@@ -112,14 +115,14 @@ public abstract class BaseDriverAdapter<R extends Op,S> implements DriverAdapter
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Function<Map<String,Object>,Map<String,Object>>> getOpFieldRemappers() {
|
||||
public List<Function<Map<String, Object>, Map<String, Object>>> getOpFieldRemappers() {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized final DriverSpaceCache<? extends S> getSpaceCache() {
|
||||
if (spaceCache==null) {
|
||||
spaceCache=new DriverSpaceCache<>(getSpaceInitializer(getConfiguration()));
|
||||
if (spaceCache == null) {
|
||||
spaceCache = new DriverSpaceCache<>(getSpaceInitializer(getConfiguration()));
|
||||
}
|
||||
return spaceCache;
|
||||
}
|
||||
@@ -149,7 +152,7 @@ public abstract class BaseDriverAdapter<R extends Op,S> implements DriverAdapter
|
||||
public NBConfigModel getConfigModel() {
|
||||
return ConfigModel.of(BaseDriverAdapter.class)
|
||||
.add(Param.optional("alias"))
|
||||
.add(Param.defaultTo("strict",true,"strict op field mode, which requires that provided op fields are recognized and used"))
|
||||
.add(Param.defaultTo("strict", true, "strict op field mode, which requires that provided op fields are recognized and used"))
|
||||
.add(Param.optional(List.of("op", "stmt", "statement"), String.class, "op template in statement form"))
|
||||
.add(Param.optional("tags", String.class, "tags to be used to filter operations"))
|
||||
.add(Param.defaultTo("errors", "stop", "error handler configuration"))
|
||||
@@ -162,7 +165,7 @@ public abstract class BaseDriverAdapter<R extends Op,S> implements DriverAdapter
|
||||
.add(Param.optional("seq", String.class, "sequencing algorithm"))
|
||||
.add(Param.optional("instrument", Boolean.class))
|
||||
.add(Param.optional(List.of("workload", "yaml"), String.class, "location of workload yaml file"))
|
||||
.add(Param.optional("driver",String.class))
|
||||
.add(Param.optional("driver", String.class))
|
||||
.asReadOnly();
|
||||
}
|
||||
|
||||
|
||||
+9
-1
@@ -152,7 +152,15 @@ public interface DriverAdapter<OPTYPE extends Op, SPACETYPE> {
|
||||
DriverSpaceCache<? extends SPACETYPE> getSpaceCache();
|
||||
|
||||
/**
|
||||
* @return A function which can initialize a new S
|
||||
* This method allows each driver adapter to create named state which is automatically
|
||||
* cached and re-used by name. For each (driver,space) combination in an activity,
|
||||
* a distinct space instance will be created. In general, adapter developers will
|
||||
* use the space type associated with an adapter to wrap native driver instances
|
||||
* one-to-one. As such, if the space implementation is a {@link AutoCloseable},
|
||||
* it will be explicitly shutdown as part of the activity shutdown.
|
||||
*
|
||||
* @return A function which can initialize a new Space, which is a place to hold
|
||||
* object state related to retained objects for the lifetime of a native driver.
|
||||
*/
|
||||
default Function<String, ? extends SPACETYPE> getSpaceInitializer(NBConfiguration cfg) {
|
||||
return n -> null;
|
||||
|
||||
+6
@@ -16,6 +16,8 @@
|
||||
|
||||
package io.nosqlbench.engine.api.activityimpl.uniform;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -64,4 +66,8 @@ public class DriverSpaceCache<S> {
|
||||
return cache.computeIfAbsent(name, newSpaceFunction);
|
||||
}
|
||||
|
||||
public Map<String,S> getElements() {
|
||||
return Collections.unmodifiableMap(cache);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user