mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-01-11 00:12:04 -06:00
added saveglobalvars rowoperator in cql
This commit is contained in:
parent
67761f6018
commit
f9eb53d981
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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) {
|
@ -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;
|
||||
|
@ -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<>();
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user