use of io.nosqlbench.engine.api.templating.ParsedOp in project nosqlbench by nosqlbench.
the class DDBGetItemOpDispenser method resolveGetItemSpecFunction.
private LongFunction<GetItemSpec> resolveGetItemSpecFunction(ParsedOp cmd) {
PrimaryKey primaryKey = null;
LongFunction<PrimaryKey> pkfunc = null;
String projection = null;
LongFunction<String> projfunc = null;
LongFunction<? extends Map> keysmap_func = cmd.getAsRequiredFunction("key", Map.class);
LongFunction<PrimaryKey> pk_func = l -> {
PrimaryKey pk = new PrimaryKey();
keysmap_func.apply(l).forEach((k, v) -> {
pk.addComponent(k.toString(), v);
});
return pk;
};
LongFunction<GetItemSpec> gis = l -> new GetItemSpec().withPrimaryKey(pk_func.apply(l));
Optional<LongFunction<String>> projection_func = cmd.getAsOptionalFunction("projection", String.class);
if (projection_func.isPresent()) {
LongFunction<GetItemSpec> finalGis = gis;
gis = l -> {
LongFunction<String> pj = projection_func.get();
return finalGis.apply(l).withProjectionExpression(pj.apply(1));
};
}
Optional<LongFunction<Boolean>> consistentRead = cmd.getAsOptionalFunction("ConsistentRead", boolean.class);
if (consistentRead.isPresent()) {
LongFunction<GetItemSpec> finalGis = gis;
gis = l -> {
LongFunction<Boolean> consistentReadFunc = consistentRead.get();
return finalGis.apply(l).withConsistentRead(consistentReadFunc.apply(l));
};
}
return gis;
}
use of io.nosqlbench.engine.api.templating.ParsedOp in project nosqlbench by nosqlbench.
the class DDBQueryOpDispenser method resolveQuerySpecFunc.
private LongFunction<QuerySpec> resolveQuerySpecFunc(ParsedOp cmd) {
LongFunction<QuerySpec> func = l -> new QuerySpec();
Optional<LongFunction<String>> projFunc = cmd.getAsOptionalFunction("projection", String.class);
if (projFunc.isPresent()) {
LongFunction<QuerySpec> finalFunc = func;
LongFunction<String> af = projFunc.get();
func = l -> finalFunc.apply(l).withAttributesToGet(af.apply(l));
}
Optional<LongFunction<Boolean>> consistentRead = cmd.getAsOptionalFunction("ConsistentRead", boolean.class);
if (consistentRead.isPresent()) {
LongFunction<QuerySpec> finalFunc = func;
LongFunction<Boolean> consistentReadFunc = consistentRead.get();
func = l -> finalFunc.apply(l).withConsistentRead(consistentReadFunc.apply(l));
}
Optional<LongFunction<Map>> exclStrtKeyFunc = cmd.getAsOptionalFunction("ExclusiveStartKey", Map.class);
if (exclStrtKeyFunc.isPresent()) {
LongFunction<QuerySpec> finalFunc = func;
LongFunction<Map> skf = exclStrtKeyFunc.get();
LongFunction<PrimaryKey> pkf = l -> {
PrimaryKey pk = new PrimaryKey();
skf.apply(l).forEach((k, v) -> pk.addComponent(k.toString(), v.toString()));
return pk;
};
func = l -> finalFunc.apply(l).withExclusiveStartKey(pkf.apply(l));
}
Optional<LongFunction<Integer>> limitFunc = cmd.getAsOptionalFunction("Limit", Integer.class);
if (limitFunc.isPresent()) {
LongFunction<Integer> limitf = limitFunc.get();
LongFunction<QuerySpec> finalFunc = func;
func = l -> finalFunc.apply(l).withMaxResultSize(limitf.apply(l));
}
return func;
}
Aggregations