mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
align subtype structure in cql op mapping
generic parameter fixes
This commit is contained in:
parent
f47498a185
commit
6ba4ff16fe
@ -49,7 +49,7 @@ import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Cqld4Space extends BaseSpace {
|
||||
public class Cqld4Space extends BaseSpace<Cqld4Space> {
|
||||
private final static Logger logger = LogManager.getLogger(Cqld4Space.class);
|
||||
|
||||
CqlSession session;
|
||||
|
@ -30,6 +30,7 @@ import com.datastax.oss.driver.api.core.type.VectorType;
|
||||
import com.datastax.oss.driver.api.core.type.codec.ExtraTypeCodecs;
|
||||
import com.datastax.oss.driver.api.core.type.codec.TypeCodec;
|
||||
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
|
||||
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlPreparedStatement;
|
||||
import io.nosqlbench.nb.api.errors.OpConfigError;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@ -130,7 +131,7 @@ public class CQLD4PreparedStmtDiagnostics {
|
||||
};
|
||||
}
|
||||
|
||||
public static Cqld4CqlOp rebindWithDiagnostics(
|
||||
public static Cqld4CqlPreparedStatement rebindWithDiagnostics(
|
||||
PreparedStatement preparedStmt,
|
||||
LongFunction<Object[]> fieldsF,
|
||||
long cycle,
|
||||
|
@ -36,14 +36,14 @@ public class CqlD4BatchStmtDispenser extends Cqld4CqlBaseOpDispenser<Cqld4CqlBat
|
||||
private final int repeat;
|
||||
private final ParsedOp subop;
|
||||
private final OpMapper submapper;
|
||||
private LongFunction<Statement> opfunc;
|
||||
private LongFunction<BatchStatement> opfunc;
|
||||
|
||||
public CqlD4BatchStmtDispenser(
|
||||
Cqld4DriverAdapter adapter,
|
||||
ParsedOp op,
|
||||
int repeat,
|
||||
ParsedOp subop,
|
||||
OpDispenser<? extends Cqld4CqlOp> subopDispenser
|
||||
OpDispenser<Cqld4CqlOp> subopDispenser
|
||||
) {
|
||||
super(adapter, op);
|
||||
this.repeat = repeat;
|
||||
@ -54,7 +54,7 @@ public class CqlD4BatchStmtDispenser extends Cqld4CqlBaseOpDispenser<Cqld4CqlBat
|
||||
|
||||
}
|
||||
|
||||
private LongFunction<Statement> createStmtFunc(ParsedOp topOp, OpDispenser<? extends Cqld4CqlOp> subopDispenser) {
|
||||
private LongFunction<BatchStatement> createStmtFunc(ParsedOp topOp, OpDispenser<? extends Cqld4CqlOp> subopDispenser) {
|
||||
Cqld4CqlOp exampleOp = subopDispenser.apply(0L);
|
||||
Statement<?> example = exampleOp.getStmt();
|
||||
if (!(example instanceof BatchableStatement<?> b)) {
|
||||
@ -63,13 +63,14 @@ public class CqlD4BatchStmtDispenser extends Cqld4CqlBaseOpDispenser<Cqld4CqlBat
|
||||
}
|
||||
BatchTypeEnum bte = topOp.getEnumFromFieldOr(BatchTypeEnum.class, BatchTypeEnum.unlogged, "batchtype");
|
||||
LongFunction<BatchStatementBuilder> bsbf = l -> new BatchStatementBuilder(bte.batchtype);
|
||||
LongFunction<Statement> bsf = getBatchAccumulator(bsbf, subopDispenser);
|
||||
LongFunction<BatchStatement> bsf = getBatchAccumulator(bsbf, subopDispenser);
|
||||
bsf = getEnhancedStmtFunc(bsf, topOp);
|
||||
return bsf;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private LongFunction<Statement> getBatchAccumulator(LongFunction<BatchStatementBuilder> bsb, OpDispenser<? extends Cqld4CqlOp> subopDispenser) {
|
||||
private LongFunction<BatchStatement> getBatchAccumulator(LongFunction<BatchStatementBuilder> bsb, OpDispenser<?
|
||||
extends Cqld4CqlOp> subopDispenser) {
|
||||
LongFunction<BatchStatementBuilder> f = l -> {
|
||||
long base = l * repeat;
|
||||
BatchStatementBuilder bsa = bsb.apply(l);
|
||||
@ -81,7 +82,7 @@ public class CqlD4BatchStmtDispenser extends Cqld4CqlBaseOpDispenser<Cqld4CqlBat
|
||||
return bsa;
|
||||
};
|
||||
|
||||
LongFunction<Statement> bsf = (long l) -> f.apply(l).build();
|
||||
LongFunction<BatchStatement> bsf = (long l) -> f.apply(l).build();
|
||||
return bsf;
|
||||
}
|
||||
|
||||
|
@ -31,15 +31,14 @@ public class CqlD4RainbowTableDispenser extends Cqld4BaseOpDispenser<Cqld4Rainbo
|
||||
// private final LongFunction<Statement> stmtFunc;
|
||||
private final LongFunction<String> targetFunction;
|
||||
|
||||
public CqlD4RainbowTableDispenser(Cqld4DriverAdapter adapter, LongFunction<CqlSession> sessionFunc,
|
||||
LongFunction<String> targetFunction, ParsedOp cmd) {
|
||||
super(adapter, sessionFunc,cmd);
|
||||
public CqlD4RainbowTableDispenser(Cqld4DriverAdapter adapter, LongFunction<String> targetFunction, ParsedOp cmd) {
|
||||
super(adapter, cmd);
|
||||
this.targetFunction=targetFunction;
|
||||
// this.tableFunc =createTableFunc(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cqld4CqlOp getOp(long cycle) {
|
||||
public Cqld4RainbowTableOp getOp(long cycle) {
|
||||
throw new RuntimeException("implement me");
|
||||
// return new Cqld4RainbowTableOp(
|
||||
// getSessionFunc().apply(value),
|
||||
|
@ -42,7 +42,7 @@ import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public abstract class Cqld4BaseOpDispenser<T extends Cqld4BaseOp> extends BaseOpDispenser<Cqld4BaseOp, Cqld4Space> implements CqlOpMetrics {
|
||||
public abstract class Cqld4BaseOpDispenser<T extends Cqld4BaseOp> extends BaseOpDispenser<T, Cqld4Space> implements CqlOpMetrics {
|
||||
|
||||
private final static Logger logger = LogManager.getLogger("CQLD4");
|
||||
|
||||
@ -104,27 +104,50 @@ public abstract class Cqld4BaseOpDispenser<T extends Cqld4BaseOp> extends BaseOp
|
||||
* overhead for implicit attributes. This should be called when the stmt function is
|
||||
* initialized within each dispenser, not for each time dispensing occurs.
|
||||
*/
|
||||
protected LongFunction<Statement> getEnhancedStmtFunc(LongFunction<Statement> basefunc, ParsedOp op) {
|
||||
protected <S extends Statement> LongFunction<S> getEnhancedStmtFunc(
|
||||
LongFunction<S> basefunc,
|
||||
ParsedOp op
|
||||
) {
|
||||
LongFunction<S> partial = basefunc;
|
||||
|
||||
LongFunction<Statement> partial = basefunc;
|
||||
partial = op.enhanceEnumOptionally(partial, "cl", DefaultConsistencyLevel.class, Statement::setConsistencyLevel);
|
||||
partial = op.enhanceEnumOptionally(partial, "consistency_level", DefaultConsistencyLevel.class, Statement::setConsistencyLevel);
|
||||
partial = op.enhanceEnumOptionally(partial, "scl", DefaultConsistencyLevel.class, Statement::setSerialConsistencyLevel);
|
||||
partial = op.enhanceEnumOptionally(partial, "serial_consistency_level", DefaultConsistencyLevel.class, Statement::setSerialConsistencyLevel);
|
||||
partial = op.enhanceFuncOptionally(partial, "idempotent", Boolean.class, Statement::setIdempotent);
|
||||
partial = op.enhanceFuncOptionally(partial, "timeout", double.class, (statement, l) -> statement.setTimeout(Duration.ofMillis((long) (l * 1000L))));
|
||||
partial = op.enhanceFuncOptionally(partial, "custom_payload", Map.class, Statement::setCustomPayload);
|
||||
partial = op.enhanceFuncOptionally(partial, "execution_profile", DriverExecutionProfile.class, Statement::setExecutionProfile);
|
||||
partial = op.enhanceFuncOptionally(partial, "execution_profile_name", String.class, Statement::setExecutionProfileName);
|
||||
partial = op.enhanceFuncOptionally(partial, "node", Node.class, Statement::setNode);
|
||||
partial = op.enhanceFuncOptionally(partial, "now_in_seconds", int.class, Statement::setNowInSeconds);
|
||||
partial = op.enhanceFuncOptionally(partial, "page_size", int.class, Statement::setPageSize);
|
||||
partial = op.enhanceFuncOptionally(partial, "query_timestamp", long.class, Statement::setQueryTimestamp);
|
||||
partial = op.enhanceFuncOptionally(partial, "routing_key", ByteBuffer.class, Statement::setRoutingKey);
|
||||
partial = op.enhanceFuncOptionally(partial, "routing_keys", ByteBuffer[].class, Statement::setRoutingKey);
|
||||
partial = op.enhanceFuncOptionally(partial, "routing_token", Token.class, Statement::setRoutingToken);
|
||||
partial = op.enhanceFuncOptionally(partial, "tracing", boolean.class, Statement::setTracing);
|
||||
partial = op.enhanceFuncOptionally(partial, "showstmt", boolean.class, this::showstmt);
|
||||
// This form is need to overcome limitations in covariant type-checking with method references
|
||||
|
||||
partial = op.enhanceEnumOptionally(partial, "cl", DefaultConsistencyLevel.class,
|
||||
(s, cl) -> (S) s.setConsistencyLevel(cl));
|
||||
partial = op.enhanceEnumOptionally(partial, "consistency_level", DefaultConsistencyLevel.class,
|
||||
(s,v) -> (S) s.setConsistencyLevel(v));
|
||||
partial = op.enhanceEnumOptionally(partial, "scl", DefaultConsistencyLevel.class,
|
||||
(s,v) -> (S) s.setSerialConsistencyLevel(v));
|
||||
partial = op.enhanceEnumOptionally(partial, "serial_consistency_level", DefaultConsistencyLevel.class,
|
||||
(s,v) -> (S) s.setSerialConsistencyLevel(v));
|
||||
|
||||
partial = op.enhanceFuncOptionally(partial, "idempotent", Boolean.class,
|
||||
(s,v) -> (S) s.setIdempotent(v));
|
||||
partial = op.enhanceFuncOptionally(partial, "custom_payload", Map.class,
|
||||
(s,v) -> (S) s.setCustomPayload(v));
|
||||
partial = op.enhanceFuncOptionally(partial, "execution_profile", DriverExecutionProfile.class,
|
||||
(s,v) -> (S) s.setExecutionProfile(v));
|
||||
partial = op.enhanceFuncOptionally(partial, "execution_profile_name", String.class,
|
||||
(s,v) -> (S) s.setExecutionProfileName(v));
|
||||
partial = op.enhanceFuncOptionally(partial, "node", Node.class,
|
||||
(s,v) -> (S) s.setNode(v));
|
||||
partial = op.enhanceFuncOptionally(partial, "now_in_seconds", int.class,
|
||||
(s,v) -> (S) s.setNowInSeconds(v));
|
||||
partial = op.enhanceFuncOptionally(partial, "page_size", int.class,
|
||||
(s,v) -> (S) s.setPageSize(v));
|
||||
partial = op.enhanceFuncOptionally(partial, "query_timestamp", long.class,
|
||||
(s,v) -> (S) s.setQueryTimestamp(v));
|
||||
partial = op.enhanceFuncOptionally(partial, "routing_key", ByteBuffer.class,
|
||||
(s,v) -> (S) s.setRoutingKey(v));
|
||||
partial = op.enhanceFuncOptionally(partial, "routing_keys", ByteBuffer[].class,
|
||||
(s,v) -> (S) s.setRoutingKey(v));
|
||||
partial = op.enhanceFuncOptionally(partial, "routing_token", Token.class,
|
||||
(s,v) -> (S) s.setRoutingToken(v));
|
||||
partial = op.enhanceFuncOptionally(partial, "tracing", boolean.class,
|
||||
(s,v) -> (S) s.setTracing(v));
|
||||
partial = op.enhanceFuncOptionally(partial, "timeout", double.class,
|
||||
(statement, l) -> (S) statement.setTimeout(Duration.ofMillis((long) ((l * 1000L)))));
|
||||
partial = op.enhanceFuncOptionally(partial, "showstmt", boolean.class, (s,v) -> (S) this.showstmt(s,v));
|
||||
|
||||
return partial;
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
package io.nosqlbench.adapter.cqld4.opdispensers;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
|
||||
import io.nosqlbench.adapter.cqld4.optypes.Cqld4BaseOp;
|
||||
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
|
||||
public abstract class Cqld4CqlBaseOpDispenser<T extends Cqld4CqlOp> extends Cqld4BaseOpDispenser<T> {
|
||||
|
||||
public Cqld4CqlBaseOpDispenser(Cqld4DriverAdapter adapter, ParsedOp op) {
|
||||
super(adapter, op);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract T getOp(long value);
|
||||
}
|
@ -35,7 +35,7 @@ import java.util.Map;
|
||||
import java.util.function.LongFunction;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class Cqld4FluentGraphOpDispenser extends Cqld4BaseOpDispenser<Cqld4BaseOp> {
|
||||
public class Cqld4FluentGraphOpDispenser extends Cqld4BaseOpDispenser<Cqld4FluentGraphOp> {
|
||||
|
||||
private final LongFunction<? extends String> graphnameFunc;
|
||||
private final Bindings virtdataBindings;
|
||||
@ -55,7 +55,7 @@ public class Cqld4FluentGraphOpDispenser extends Cqld4BaseOpDispenser<Cqld4BaseO
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cqld4BaseOp getOp(long value) {
|
||||
public Cqld4FluentGraphOp getOp(long value) {
|
||||
String graphname = graphnameFunc.apply(value);
|
||||
Script script = tlScript.get();
|
||||
Map<String, Object> allMap = virtdataBindings.getAllMap(value);
|
||||
|
@ -35,7 +35,7 @@ import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class Cqld4PreparedStmtDispenser extends Cqld4BaseOpDispenser {
|
||||
public class Cqld4PreparedStmtDispenser extends Cqld4BaseOpDispenser<Cqld4CqlPreparedStatement> {
|
||||
private final static Logger logger = LogManager.getLogger(Cqld4PreparedStmtDispenser.class);
|
||||
|
||||
private final RSProcessors processors;
|
||||
|
@ -29,7 +29,7 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class Cqld4RawStmtDispenser extends Cqld4BaseOpDispenser<Cqld4CqlOp> {
|
||||
public class Cqld4RawStmtDispenser extends Cqld4CqlBaseOpDispenser<Cqld4CqlSimpleStatement> {
|
||||
|
||||
private final LongFunction<Statement> stmtFunc;
|
||||
private final LongFunction<String> targetFunction;
|
||||
|
@ -28,7 +28,7 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class Cqld4SimpleCqlStmtDispenser<T extends Cqld4CqlOp> extends Cqld4BaseOpDispenser<T> {
|
||||
public class Cqld4SimpleCqlStmtDispenser extends Cqld4CqlBaseOpDispenser<Cqld4CqlSimpleStatement> {
|
||||
|
||||
private final LongFunction<Statement> stmtFunc;
|
||||
private final LongFunction<String> targetFunction;
|
||||
|
@ -24,7 +24,7 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class Cqld4SsTableDispenser extends Cqld4BaseOpDispenser {
|
||||
public class Cqld4SsTableDispenser extends Cqld4BaseOpDispenser<Cqld4CqlOp> {
|
||||
|
||||
// private final LongFunction<Statement> stmtFunc;
|
||||
// private final LongFunction<String> targetFunction;
|
||||
|
@ -27,7 +27,7 @@ import io.nosqlbench.engine.api.templating.TypeAndTarget;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class CqlD4BatchStmtMapper extends Cqld4BaseOpMapper<Cqld4BaseOp> {
|
||||
public class CqlD4BatchStmtMapper extends Cqld4CqlBaseOpMapper<Cqld4CqlBatchStatement> {
|
||||
|
||||
private final TypeAndTarget<CqlD4OpType, String> target;
|
||||
|
||||
@ -41,8 +41,8 @@ public class CqlD4BatchStmtMapper extends Cqld4BaseOpMapper<Cqld4BaseOp> {
|
||||
public OpDispenser<Cqld4CqlBatchStatement> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF) {
|
||||
ParsedOp subop = op.getAsSubOp("op_template", ParsedOp.SubOpNaming.ParentAndSubKey);
|
||||
int repeat = op.getStaticValue("repeat");
|
||||
OpDispenser<? extends Cqld4BaseOp> od = new Cqld4CqlOpMapper(adapter).apply(op, spaceInitF);
|
||||
return new CqlD4BatchStmtDispenser(adapter, sessionFunc, op, repeat, subop, od);
|
||||
OpDispenser<Cqld4CqlOp> od = new Cqld4CqlOpMapper(adapter).apply(op, spaceInitF);
|
||||
return new CqlD4BatchStmtDispenser(adapter, op, repeat, subop, od);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class CqlD4CqlSimpleStmtMapper extends Cqld4BaseOpMapper<Cqld4BaseOp> {
|
||||
public class CqlD4CqlSimpleStmtMapper extends Cqld4CqlBaseOpMapper<Cqld4CqlSimpleStatement> {
|
||||
private final LongFunction<String> targetFunction;
|
||||
|
||||
public CqlD4CqlSimpleStmtMapper(Cqld4DriverAdapter adapter,
|
||||
@ -36,8 +36,8 @@ public class CqlD4CqlSimpleStmtMapper extends Cqld4BaseOpMapper<Cqld4BaseOp> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpDispenser<Cqld4BaseOp> apply(ParsedOp op, LongFunction spaceInitF) {
|
||||
return new Cqld4SimpleCqlStmtDispenser(adapter, sessionFunc,targetFunction, op);
|
||||
public OpDispenser<Cqld4CqlSimpleStatement> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF) {
|
||||
return new Cqld4SimpleCqlStmtDispenser(adapter, targetFunction, op);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class CqlD4PreparedStmtMapper extends Cqld4BaseOpMapper<Cqld4BaseOp> {
|
||||
public class CqlD4PreparedStmtMapper extends Cqld4CqlBaseOpMapper<Cqld4CqlPreparedStatement> {
|
||||
|
||||
private final TypeAndTarget<CqlD4OpType, String> target;
|
||||
|
||||
@ -49,7 +49,7 @@ public class CqlD4PreparedStmtMapper extends Cqld4BaseOpMapper<Cqld4BaseOp> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpDispenser<Cqld4BaseOp> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF) {
|
||||
public OpDispenser<Cqld4CqlPreparedStatement> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF) {
|
||||
ParsedTemplateString stmtTpl = op.getAsTemplate(target.field).orElseThrow(() -> new BasicError(
|
||||
"No statement was found in the op template:" + op
|
||||
));
|
||||
|
@ -26,19 +26,17 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class CqlD4RawStmtMapper extends Cqld4BaseOpMapper<Cqld4BaseOp> {
|
||||
public class CqlD4RawStmtMapper extends Cqld4CqlBaseOpMapper<Cqld4CqlSimpleStatement> {
|
||||
|
||||
private final LongFunction<String> targetFunction;
|
||||
|
||||
public CqlD4RawStmtMapper(Cqld4DriverAdapter adapter,
|
||||
LongFunction<String> targetFunction) {
|
||||
public CqlD4RawStmtMapper(Cqld4DriverAdapter adapter,LongFunction<String> targetFunction) {
|
||||
super(adapter);
|
||||
this.targetFunction = targetFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpDispenser<Cqld4BaseOp> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF) {
|
||||
return new Cqld4RawStmtDispenser(adapter, sessionFunc, targetFunction, op);
|
||||
public OpDispenser<Cqld4CqlSimpleStatement> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF) {
|
||||
return new Cqld4RawStmtDispenser(adapter, targetFunction,op);
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
@ -58,7 +58,7 @@ public class Cqld4CoreOpMapper extends Cqld4BaseOpMapper<Cqld4BaseOp> {
|
||||
TypeAndTarget<CqlD4OpType, String> target = op.getTypeAndTarget(CqlD4OpType.class, String.class, "type", "stmt");
|
||||
logger.info(() -> "Using " + target.enumId + " statement form for '" + op.getName()+"'");
|
||||
|
||||
return switch (target.enumId) {
|
||||
return (OpDispenser<Cqld4BaseOp>) switch (target.enumId) {
|
||||
case raw, simple, prepared, batch -> new Cqld4CqlOpMapper(adapter).apply(op, spaceFunc);
|
||||
case gremlin -> new Cqld4GremlinOpMapper(adapter, target.targetFunction).apply(op, spaceFunc);
|
||||
case fluent -> new Cqld4FluentGraphOpMapper(adapter, target).apply(op, spaceFunc);
|
||||
|
@ -0,0 +1,37 @@
|
||||
package io.nosqlbench.adapter.cqld4.opmappers;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
|
||||
import io.nosqlbench.adapter.cqld4.Cqld4Space;
|
||||
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public abstract class Cqld4CqlBaseOpMapper<T extends Cqld4CqlOp> extends Cqld4BaseOpMapper<T> {
|
||||
|
||||
public Cqld4CqlBaseOpMapper(Cqld4DriverAdapter adapter) {
|
||||
super(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract OpDispenser<T> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF);
|
||||
}
|
@ -29,7 +29,7 @@ import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class Cqld4CqlOpMapper extends Cqld4BaseOpMapper<Cqld4BaseOp> {
|
||||
public class Cqld4CqlOpMapper extends Cqld4CqlBaseOpMapper<Cqld4CqlOp> {
|
||||
|
||||
protected final static Logger logger = LogManager.getLogger(Cqld4CqlOpMapper.class);
|
||||
|
||||
@ -38,22 +38,23 @@ public class Cqld4CqlOpMapper extends Cqld4BaseOpMapper<Cqld4BaseOp> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpDispenser<Cqld4BaseOp> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF) {
|
||||
public OpDispenser<Cqld4CqlOp> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF) {
|
||||
CqlD4OpType opType = CqlD4OpType.prepared;
|
||||
TypeAndTarget<CqlD4OpType, String> target = op.getTypeAndTarget(CqlD4OpType.class, String.class, "type", "stmt");
|
||||
logger.info(() -> "Using " + target.enumId + " statement form for '" + op.getName() + "'");
|
||||
|
||||
return switch (target.enumId) {
|
||||
return (OpDispenser<Cqld4CqlOp>) switch (target.enumId) {
|
||||
case raw -> {
|
||||
CqlD4RawStmtMapper cqlD4RawStmtMapper = new CqlD4RawStmtMapper(adapter, target.targetFunction);
|
||||
OpDispenser<Cqld4BaseOp> apply = cqlD4RawStmtMapper.apply(op, spaceFunc);
|
||||
OpDispenser<Cqld4CqlSimpleStatement> apply = cqlD4RawStmtMapper.apply(op, spaceFunc);
|
||||
yield apply;
|
||||
}
|
||||
case simple -> new CqlD4CqlSimpleStmtMapper(adapter, target.targetFunction).apply(op, spaceFunc);
|
||||
case prepared -> new CqlD4PreparedStmtMapper(adapter, target).apply(op, spaceFunc);
|
||||
|
||||
case batch -> new CqlD4BatchStmtMapper(adapter, target).apply(op, spaceFunc);
|
||||
default -> throw new OpConfigError("Unsupported op type for CQL category of statement forms:" + target.enumId);
|
||||
default ->
|
||||
throw new OpConfigError("Unsupported op type for CQL category of statement forms:" + target.enumId);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ import java.util.Map;
|
||||
import java.util.function.LongFunction;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class Cqld4FluentGraphOpMapper<CO extends Cqld4FluentGraphOp> extends Cqld4BaseOpMapper<Cqld4BaseOp> {
|
||||
public class Cqld4FluentGraphOpMapper extends Cqld4BaseOpMapper<Cqld4FluentGraphOp> {
|
||||
private final static Logger logger = LogManager.getLogger(Cqld4FluentGraphOpMapper.class);
|
||||
|
||||
private final TypeAndTarget<CqlD4OpType, String> target;
|
||||
@ -65,7 +65,7 @@ public class Cqld4FluentGraphOpMapper<CO extends Cqld4FluentGraphOp> extends Cql
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpDispenser<Cqld4BaseOp> apply(ParsedOp op, LongFunction<Cqld4Space> cqld4SpaceLongFunction) {
|
||||
public OpDispenser<Cqld4FluentGraphOp> apply(ParsedOp op, LongFunction<Cqld4Space> cqld4SpaceLongFunction) {
|
||||
GraphTraversalSource g = DseGraph.g;
|
||||
|
||||
ParsedTemplateString fluent = op.getAsTemplate(target.field).orElseThrow();
|
||||
|
@ -25,8 +25,15 @@ public class Cqld4CqlPreparedStatement extends Cqld4CqlOp {
|
||||
|
||||
private final BoundStatement stmt;
|
||||
|
||||
public Cqld4CqlPreparedStatement(CqlSession session, BoundStatement stmt, int maxPages,
|
||||
boolean retryReplace, int maxLwtRetries, RSProcessors processors, CqlOpMetrics metrics) {
|
||||
public Cqld4CqlPreparedStatement(
|
||||
CqlSession session,
|
||||
BoundStatement stmt,
|
||||
int maxPages,
|
||||
boolean retryReplace,
|
||||
int maxLwtRetries,
|
||||
RSProcessors processors,
|
||||
CqlOpMetrics metrics
|
||||
) {
|
||||
super(session, maxPages, retryReplace, maxLwtRetries, processors, metrics);
|
||||
this.stmt = stmt;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user