added saveglobalvars rowoperator in cql

This commit is contained in:
Jonathan Shook 2020-03-03 13:28:01 -06:00
parent 67761f6018
commit f9eb53d981
5 changed files with 34 additions and 5 deletions

View File

@ -4,8 +4,9 @@ import io.nosqlbench.activitytype.cql.ebdrivers.cql.api.RowCycleOperator;
public enum RowCycleOperators {
saverows(SaveRows.class),
savevars(SaveVars.class),
saverows(SaveThreadRows.class),
savevars(SaveThreadVars.class),
saveglobalvars(SaveGlobalVars.class),
print(Print.class);
private final Class<? extends RowCycleOperator> implClass;

View File

@ -0,0 +1,26 @@
package io.nosqlbench.activitytype.cql.ebdrivers.cql.statements.rowoperators;
import com.datastax.driver.core.ColumnDefinitions;
import com.datastax.driver.core.Row;
import io.nosqlbench.activitytype.cql.ebdrivers.cql.api.RowCycleOperator;
import io.nosqlbench.virtdata.library.basics.core.threadstate.SharedState;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
public class SaveGlobalVars implements RowCycleOperator {
ConcurrentHashMap<String, Object> gl_vars = SharedState.gl_ObjectMap;
@Override
public int apply(Row row, long cycle) {
List<ColumnDefinitions.Definition> cdlist = row.getColumnDefinitions().asList();
for (ColumnDefinitions.Definition definition : cdlist) {
String name = definition.getName();
Object object = row.getObject(name);
gl_vars.put(name,object);
}
return 0;
}
}

View File

@ -6,7 +6,7 @@ import io.nosqlbench.activitytype.cql.ebdrivers.cql.statements.rsoperators.PerTh
import java.util.LinkedList;
public class SaveRows implements RowCycleOperator {
public class SaveThreadRows implements RowCycleOperator {
@Override
public int apply(Row row, long cycle) {

View File

@ -8,7 +8,7 @@ import io.nosqlbench.virtdata.library.basics.core.threadstate.SharedState;
import java.util.HashMap;
import java.util.List;
public class SaveVars implements RowCycleOperator {
public class SaveThreadVars implements RowCycleOperator {
ThreadLocal<HashMap<String, Object>> tl_objectMap = SharedState.tl_ObjectMap;

View File

@ -1,6 +1,7 @@
package io.nosqlbench.virtdata.library.basics.core.threadstate;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
* This provides common thread local instancing for sharing a thread local map across classes.
@ -14,6 +15,7 @@ public class SharedState {
public static ThreadLocal<Deque<Object>> tl_ObjectStack = ThreadLocal.withInitial(ArrayDeque::new);
// A global map of objects for constant pool, etc.
public static Map<String,Object> gl_ObjectMap = new HashMap<>();
public static ConcurrentHashMap<String,Object> gl_ObjectMap =
new ConcurrentHashMap<>();
}