jshook/nosqlbench-2057-flattenop (#2067)

* remove ChainingOp

* typos and other minor fixes

* remove Op, ChainingOp, flatten to CycleOp, derive RunnableOp

* refactor qdrant for aligned op types

* refactor mongodb for aligned op types

* refactor cqld4 for aligned op types

* minor API alignment

refactor gcpspanner for aligned op types

* minor API alignment

refactor gcpspanner for aligned op types

add license

* fix cqld4 batch statement mapper

* fix cql base op mapper

* remove var inference

* remove emitter for runnable op
This commit is contained in:
Jonathan Shook 2024-11-04 16:42:05 -06:00 committed by GitHub
parent 62ad93cb59
commit ea7fceae49
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
87 changed files with 331 additions and 539 deletions

View File

@ -32,14 +32,14 @@ import io.nosqlbench.nb.api.labels.NBLabels;
import static io.nosqlbench.adapter.azureaisearch.AzureAISearchAdapterUtils.AZURE_AI_SEARCH;
@Service(value = DriverAdapter.class, selector = AZURE_AI_SEARCH)
public class AzureAISearchDriverAdapter extends BaseDriverAdapter<AzureAISearchBaseOp, AzureAISearchSpace> {
public class AzureAISearchDriverAdapter extends BaseDriverAdapter<AzureAISearchBaseOp<?,?>, AzureAISearchSpace> {
public AzureAISearchDriverAdapter(NBComponent parentComponent, NBLabels labels) {
super(parentComponent, labels);
}
@Override
public OpMapper<AzureAISearchBaseOp,AzureAISearchSpace> getOpMapper() {
public OpMapper<AzureAISearchBaseOp<?,?>,AzureAISearchSpace> getOpMapper() {
return new AzureAISearchOpMapper(this);
}

View File

@ -16,6 +16,7 @@
package io.nosqlbench.adapter.azureaisearch;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -34,7 +35,7 @@ import io.nosqlbench.engine.api.templating.TypeAndTarget;
import java.util.function.LongFunction;
public class AzureAISearchOpMapper implements OpMapper<AzureAISearchBaseOp, AzureAISearchSpace> {
public class AzureAISearchOpMapper implements OpMapper<AzureAISearchBaseOp<?,?>, AzureAISearchSpace> {
private static final Logger logger = LogManager.getLogger(AzureAISearchOpMapper.class);
private final AzureAISearchDriverAdapter adapter;
@ -60,7 +61,7 @@ public class AzureAISearchOpMapper implements OpMapper<AzureAISearchBaseOp, Azur
* the op type
*/
@Override
public OpDispenser<AzureAISearchBaseOp> apply(ParsedOp op, LongFunction<AzureAISearchSpace> spaceInitF) {
public OpDispenser<AzureAISearchBaseOp<?,?>> apply(ParsedOp op, LongFunction<AzureAISearchSpace> spaceInitF) {
TypeAndTarget<AzureAISearchOpType, String> typeAndTarget = op.getTypeAndTarget(AzureAISearchOpType.class,
String.class, "type", "target");

View File

@ -29,7 +29,7 @@ import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.templating.ParsedOp;
public abstract class AzureAISearchBaseOpDispenser<REQUEST,RESULT>
extends BaseOpDispenser<AzureAISearchBaseOp, AzureAISearchSpace> {
extends BaseOpDispenser<AzureAISearchBaseOp<?,?>, AzureAISearchSpace> {
protected final LongFunction<AzureAISearchSpace> azureAISearchSpaceFunction;
protected final LongFunction<SearchIndexClient> clientFunction;

View File

@ -18,13 +18,11 @@ package io.nosqlbench.adapter.cqld4;
import io.nosqlbench.adapter.cqld4.opmappers.Cqld4CoreOpMapper;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4BaseOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.nb.api.config.standard.NBConfigModel;
import io.nosqlbench.nb.api.config.standard.NBConfiguration;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.BaseDriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.nb.api.labels.NBLabels;
import io.nosqlbench.nb.api.components.core.NBComponent;
import io.nosqlbench.nb.annotations.Service;
@ -39,7 +37,7 @@ import java.util.function.Function;
import java.util.function.LongFunction;
@Service(value = DriverAdapter.class, selector = "cqld4")
public class Cqld4DriverAdapter extends BaseDriverAdapter<Cqld4BaseOp, Cqld4Space> {
public class Cqld4DriverAdapter extends BaseDriverAdapter<Cqld4BaseOp<?>, Cqld4Space> {
private final static Logger logger = LogManager.getLogger(Cqld4DriverAdapter.class);
public Cqld4DriverAdapter(NBComponent parentComponent, NBLabels labels) {
@ -47,7 +45,7 @@ public class Cqld4DriverAdapter extends BaseDriverAdapter<Cqld4BaseOp, Cqld4Spac
}
@Override
public OpMapper<Cqld4BaseOp,Cqld4Space> getOpMapper() {
public OpMapper<Cqld4BaseOp<?>, Cqld4Space> getOpMapper() {
NBConfiguration config = getConfiguration();
return new Cqld4CoreOpMapper(this, config);
}

View File

@ -43,7 +43,7 @@ import java.util.Map;
import java.util.function.IntFunction;
import java.util.function.LongFunction;
public abstract class Cqld4BaseOpDispenser<T extends Cqld4BaseOp> extends BaseOpDispenser<T, Cqld4Space> implements CqlOpMetrics {
public abstract class Cqld4BaseOpDispenser<T extends Cqld4BaseOp<?>> extends BaseOpDispenser<T, Cqld4Space> implements CqlOpMetrics {
private final static Logger logger = LogManager.getLogger("CQLD4");

View File

@ -31,7 +31,7 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.Optional;
import java.util.function.LongFunction;
public class Cqld4GremlinOpDispenser extends BaseOpDispenser<Cqld4BaseOp, Cqld4Space> {
public class Cqld4GremlinOpDispenser extends BaseOpDispenser<Cqld4BaseOp<?>, Cqld4Space> {
private final LongFunction<? extends ScriptGraphStatement> stmtFunc;
private final LongFunction<CqlSession> sessionFunc;

View File

@ -16,6 +16,7 @@
package io.nosqlbench.adapter.cqld4.opmappers;
import com.datastax.oss.driver.api.core.cql.Row;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.opdispensers.CqlD4BatchStmtDispenser;
@ -25,9 +26,10 @@ import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.engine.api.templating.TypeAndTarget;
import java.util.List;
import java.util.function.LongFunction;
public class CqlD4BatchStmtMapper extends Cqld4CqlBaseOpMapper<Cqld4CqlBatchStatement> {
public class CqlD4BatchStmtMapper<RESULT extends List<? extends Row>> extends Cqld4CqlBaseOpMapper<Cqld4CqlBatchStatement> {
private final TypeAndTarget<CqlD4OpType, String> target;

View File

@ -20,21 +20,16 @@ import com.datastax.oss.driver.api.core.CqlSession;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4BaseOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.BaseSpace;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.engine.api.templating.TypeAndTarget;
import io.nosqlbench.nb.api.config.standard.NBConfiguration;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.function.LongFunction;
public abstract class Cqld4BaseOpMapper<T extends Cqld4BaseOp> implements OpMapper<T,Cqld4Space> {
public abstract class Cqld4BaseOpMapper<T extends Cqld4BaseOp<?>> implements OpMapper<T,Cqld4Space> {
protected final static Logger logger = LogManager.getLogger(Cqld4BaseOpMapper.class);
protected final Cqld4DriverAdapter adapter;

View File

@ -19,8 +19,7 @@ package io.nosqlbench.adapter.cqld4.opmappers;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4BaseOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.nb.api.config.standard.NBConfiguration;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.templating.ParsedOp;
@ -31,12 +30,11 @@ import org.apache.logging.log4j.Logger;
import java.util.function.LongFunction;
public class Cqld4CoreOpMapper extends Cqld4BaseOpMapper<Cqld4BaseOp> {
public class Cqld4CoreOpMapper extends Cqld4BaseOpMapper<Cqld4BaseOp<?>> {
private final static Logger logger = LogManager.getLogger(Cqld4CoreOpMapper.class);
public Cqld4CoreOpMapper(Cqld4DriverAdapter adapter,
NBConfiguration config) {
public Cqld4CoreOpMapper(Cqld4DriverAdapter adapter, NBConfiguration config) {
super(adapter);
}
@ -53,16 +51,17 @@ public class Cqld4CoreOpMapper extends Cqld4BaseOpMapper<Cqld4BaseOp> {
*/
@Override
public OpDispenser<Cqld4BaseOp> apply(ParsedOp op, LongFunction<Cqld4Space> cqld4SpaceLongFunction) {
public OpDispenser<Cqld4BaseOp<?>> apply(ParsedOp op, LongFunction<Cqld4Space> cqld4SpaceLongFunction) {
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()+"'");
logger.info(() -> "Using " + target.enumId + " statement form for '" + op.getName() + "'");
return (OpDispenser<Cqld4BaseOp>) 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);
case rainbow -> new CqlD4RainbowTableMapper(adapter, sessionFunc, target.targetFunction).apply(op, spaceFunc);
case rainbow ->
new CqlD4RainbowTableMapper(adapter, sessionFunc, target.targetFunction).apply(op, spaceFunc);
default -> throw new OpConfigError("Unsupported op type " + opType);
// case sst -> new Cqld4SsTableMapper(adapter, sessionFunc, target.targetFunction).apply(op);
};

View File

@ -22,6 +22,7 @@ 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.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
@ -34,4 +35,5 @@ public abstract class Cqld4CqlBaseOpMapper<T extends Cqld4CqlOp> extends Cqld4Ba
@Override
public abstract OpDispenser<T> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF);
}

View File

@ -17,21 +17,14 @@
package io.nosqlbench.adapter.cqld4.opmappers;
import com.datastax.dse.driver.api.core.graph.DseGraph;
import com.datastax.oss.driver.api.core.CqlSession;
import groovy.lang.Binding;
import groovy.lang.GroovyShell;
import groovy.lang.Script;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.opdispensers.Cqld4FluentGraphOpDispenser;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4BaseOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4FluentGraphOp;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.engine.api.templating.TypeAndTarget;
import io.nosqlbench.nb.api.errors.OpConfigError;

View File

@ -18,7 +18,8 @@ package io.nosqlbench.adapter.cqld4.optypes;
*/
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
public interface Cqld4BaseOp extends Op {
public interface Cqld4BaseOp<T> extends CycleOp<T> {
}

View File

@ -18,9 +18,13 @@ package io.nosqlbench.adapter.cqld4.optypes;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.BatchStatement;
import com.datastax.oss.driver.api.core.cql.Row;
import io.nosqlbench.adapter.cqld4.RSProcessors;
import io.nosqlbench.adapter.cqld4.instruments.CqlOpMetrics;
import java.util.ArrayList;
import java.util.List;
public class Cqld4CqlBatchStatement extends Cqld4CqlOp {
private final BatchStatement stmt;

View File

@ -17,10 +17,7 @@
package io.nosqlbench.adapter.cqld4.optypes;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.AsyncResultSet;
import com.datastax.oss.driver.api.core.cql.BoundStatement;
import com.datastax.oss.driver.api.core.cql.Row;
import com.datastax.oss.driver.api.core.cql.Statement;
import com.datastax.oss.driver.api.core.cql.*;
import io.nosqlbench.adapter.cqld4.Cqld4CqlReboundStatement;
import io.nosqlbench.adapter.cqld4.LWTRebinder;
import io.nosqlbench.adapter.cqld4.RSProcessors;
@ -50,7 +47,7 @@ import java.util.concurrent.*;
public abstract class Cqld4CqlOp
implements Cqld4BaseOp, CycleOp<List<Row>>, VariableCapture, OpGenerator, OpResultSize {
implements Cqld4BaseOp<List<Row>>, VariableCapture, OpGenerator, OpResultSize {
private final static Logger logger = LogManager.getLogger(Cqld4CqlOp.class);
@ -101,7 +98,8 @@ public abstract class Cqld4CqlOp
this.metrics = metrics;
}
public final ArrayList<Row> apply(long cycle) {
@Override
public List<Row> apply(long cycle) {
Statement<?> statement = getStmt();
logger.trace(() -> "apply() invoked, statement obtained, executing async with page size: " + statement.getPageSize() + " thread local rows: ");
@ -136,15 +134,16 @@ public abstract class Cqld4CqlOp
metrics.recordFetchedRows(fetchedRows);
metrics.recordFetchedBytes(fetchedBytes);
}
}
// logger.trace(() -> "\n\n--- Rows collected for cycle: " + cycle + " count: "
// + rs.size() + " dt: " + System.nanoTime());
//
// results.set(completeRowSet);
// processors.flush();
}
private static class PrintableRowList extends ArrayList<Row> {
public static class PrintableRowList extends ArrayList<Row> {
public PrintableRowList(List<Row> values) {
super(values);
}
@ -159,10 +158,9 @@ public abstract class Cqld4CqlOp
}
}
// private BiFunction<AsyncResultSet,Throwable> handler
@Override
public Op getNextOp() {
Op next = nextOp;
public CycleOp<?> getNextOp() {
CycleOp<?> next = nextOp;
nextOp = null;
return next;
}
@ -181,7 +179,7 @@ public abstract class Cqld4CqlOp
}
private CompletionStage<List<Row>> collect(AsyncResultSet resultSet, ArrayList<Row> rowList, final long cycle) {
fetchedBytes+=resultSet.getExecutionInfo().getResponseSizeInBytes();
fetchedBytes += resultSet.getExecutionInfo().getResponseSizeInBytes();
if (++fetchedPages > maxPages) {
throw new UnexpectedPagingException(resultSet, getQueryString(), fetchedPages, maxPages, getStmt().getPageSize());
}

View File

@ -0,0 +1,40 @@
package io.nosqlbench.adapter.cqld4.optypes;
/*
* Copyright (c) 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 com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.Statement;
import io.nosqlbench.adapter.cqld4.RSProcessors;
import io.nosqlbench.adapter.cqld4.instruments.CqlOpMetrics;
public class Cqld4CqlOpImpl extends Cqld4CqlOp {
public Cqld4CqlOpImpl(CqlSession session, int maxPages, boolean retryReplace, int maxLwtRetries, RSProcessors processors, CqlOpMetrics metrics) {
super(session, maxPages, retryReplace, maxLwtRetries, processors, metrics);
}
@Override
public Statement<?> getStmt() {
return null;
}
@Override
public String getQueryString() {
return "";
}
}

View File

@ -22,7 +22,7 @@ import com.datastax.oss.driver.api.core.CqlSession;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.OpResultSize;
public class Cqld4FluentGraphOp implements Cqld4BaseOp, CycleOp<GraphResultSet>, OpResultSize {
public class Cqld4FluentGraphOp implements Cqld4BaseOp<GraphResultSet>, OpResultSize {
private final CqlSession session;
private final FluentGraphStatement stmt;
private int resultSize=0;

View File

@ -23,7 +23,7 @@ import java.util.Map;
// Need to create RainbowTableStatement
public class Cqld4RainbowTableOp
implements Cqld4BaseOp, CycleOp<ResultSet>, VariableCapture, OpGenerator, OpResultSize {
implements Cqld4BaseOp<ResultSet>, VariableCapture, OpGenerator, OpResultSize {
// private final CqlSession session;
// private final RainbowTableStatement stmt;
@ -35,7 +35,7 @@ public class Cqld4RainbowTableOp
}
@Override
public Op getNextOp() {
public CycleOp getNextOp() {
throw new RuntimeException("implement me");
}

View File

@ -22,7 +22,7 @@ import com.datastax.oss.driver.api.core.CqlSession;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.OpResultSize;
public class Cqld4ScriptGraphOp implements Cqld4BaseOp, CycleOp<GraphResultSet>, OpResultSize {
public class Cqld4ScriptGraphOp implements Cqld4BaseOp<GraphResultSet>, OpResultSize {
private final CqlSession session;
private final ScriptGraphStatement stmt;
private int resultSize=0;

View File

@ -21,7 +21,7 @@ import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public abstract class DataApiBaseOp implements CycleOp {
public abstract class DataApiBaseOp implements CycleOp<Object> {
protected static final Logger logger = LogManager.getLogger(DataApiBaseOp.class);
protected final Database db;

View File

@ -32,14 +32,14 @@ import java.util.function.LongFunction;
import static io.nosqlbench.adapter.gcpspanner.GCPSpannerAdapterUtils.SPANNER;
@Service(value = DriverAdapter.class, selector = SPANNER)
public class GCPSpannerDriverAdapter extends BaseDriverAdapter<GCPSpannerBaseOp, GCPSpannerSpace> {
public class GCPSpannerDriverAdapter extends BaseDriverAdapter<GCPSpannerBaseOp<?,?>, GCPSpannerSpace> {
public GCPSpannerDriverAdapter(NBComponent parentComponent, NBLabels labels) {
super(parentComponent, labels);
}
@Override
public OpMapper<GCPSpannerBaseOp,GCPSpannerSpace> getOpMapper() {
public OpMapper<GCPSpannerBaseOp<?,?>,GCPSpannerSpace> getOpMapper() {
return new GCPSpannerOpMapper(this);
}

View File

@ -30,7 +30,7 @@ import org.apache.logging.log4j.Logger;
import java.util.function.IntFunction;
import java.util.function.LongFunction;
public class GCPSpannerOpMapper implements OpMapper<GCPSpannerBaseOp, GCPSpannerSpace> {
public class GCPSpannerOpMapper implements OpMapper<GCPSpannerBaseOp<?,?>, GCPSpannerSpace> {
private static final Logger logger = LogManager.getLogger(GCPSpannerOpMapper.class);
private final GCPSpannerDriverAdapter adapter;
@ -56,12 +56,12 @@ public class GCPSpannerOpMapper implements OpMapper<GCPSpannerBaseOp, GCPSpanner
* the op type
*/
@Override
public OpDispenser<GCPSpannerBaseOp> apply(ParsedOp op, LongFunction<GCPSpannerSpace> spaceInitF) {
public OpDispenser<GCPSpannerBaseOp<?,?>> apply(ParsedOp op, LongFunction<GCPSpannerSpace> spaceInitF) {
TypeAndTarget<GCPSpannerOpType, String> typeAndTarget = op.getTypeAndTarget(GCPSpannerOpType.class,
String.class, "type", "target");
logger.info(() -> "Using '" + typeAndTarget.enumId + "' op type for op template '" + op.getName() + "'");
return switch (typeAndTarget.enumId) {
OpDispenser<GCPSpannerBaseOp<?, ?>> dispenser = switch (typeAndTarget.enumId) {
case drop_database_ddl ->
new GCPSpannerDropDatabaseDdlOpDispenser(adapter, op, typeAndTarget.targetFunction);
case create_database_ddl ->
@ -71,5 +71,6 @@ public class GCPSpannerOpMapper implements OpMapper<GCPSpannerBaseOp, GCPSpanner
case insert -> new GCPSpannerInsertOpDispenser(adapter, op, typeAndTarget.targetFunction);
case execute_dml -> new GCPSpannerExecuteDmlOpDispenser(adapter, op, typeAndTarget.targetFunction);
};
return dispenser;
}
}

View File

@ -32,7 +32,7 @@ import java.util.function.LongFunction;
* for creating GCP Spanner operations.
*/
public abstract class GCPSpannerBaseOpDispenser<OP extends GCPSpannerBaseOp,RESULT>
extends BaseOpDispenser<GCPSpannerBaseOp, GCPSpannerSpace> {
extends BaseOpDispenser<GCPSpannerBaseOp<?,?>, GCPSpannerSpace> {
/**
* A function that provides the target string based on a long input.
*/

View File

@ -18,7 +18,6 @@ package io.nosqlbench.adapter.gcpspanner.ops;
import com.google.cloud.spanner.Spanner;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

View File

@ -27,7 +27,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
public class HttpOp implements CycleOp {
public class HttpOp implements CycleOp<Object> {
public final Pattern ok_status;
public final Pattern ok_body;

View File

@ -18,20 +18,17 @@ package io.nosqlbench.adapter.mongodb.core;
import io.nosqlbench.adapter.mongodb.dispensers.MongoCommandOpDispenser;
import io.nosqlbench.adapter.mongodb.ops.MongoDirectCommandOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.activityimpl.uniform.ConcurrentSpaceCache;
import io.nosqlbench.nb.api.config.standard.NBConfiguration;
import io.nosqlbench.nb.api.errors.BasicError;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.engine.api.templating.TypeAndTarget;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.Optional;
import java.util.function.IntFunction;
import java.util.function.LongFunction;
public class MongoOpMapper<MC extends MongoDirectCommandOp> implements OpMapper<MongoDirectCommandOp,MongoSpace> {

View File

@ -17,31 +17,30 @@
package io.nosqlbench.adapter.mongodb.core;
import io.nosqlbench.adapter.mongodb.ops.MongoDirectCommandOp;
import io.nosqlbench.adapter.mongodb.ops.MongoOp;
import io.nosqlbench.nb.api.config.standard.NBConfigModel;
import io.nosqlbench.nb.api.config.standard.NBConfiguration;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.BaseDriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.nb.api.labels.NBLabels;
import io.nosqlbench.nb.api.components.core.NBComponent;
import io.nosqlbench.nb.annotations.Service;
import java.util.function.IntFunction;
import java.util.function.LongFunction;
/**
* Special thanks to Justin Chu who authored the original NoSQLBench MongoDB ActivityType.
*/
@Service(value = DriverAdapter.class, selector = "mongodb")
public class MongodbDriverAdapter extends BaseDriverAdapter<MongoDirectCommandOp, MongoSpace> {
public class MongodbDriverAdapter extends BaseDriverAdapter<MongoOp<?>, MongoSpace> {
public MongodbDriverAdapter(NBComponent parentComponent, NBLabels labels) {
super(parentComponent, labels);
}
@Override
public OpMapper<MongoDirectCommandOp,MongoSpace> getOpMapper() {
public OpMapper<MongoOp<?>,MongoSpace> getOpMapper() {
return new MongoOpMapper(this, getConfiguration(), getSpaceCache());
}

View File

@ -20,14 +20,11 @@ import io.nosqlbench.adapter.mongodb.core.MongoSpace;
import io.nosqlbench.adapter.mongodb.ops.MongoDirectCommandOp;
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import org.bson.Document;
import org.bson.conversions.Bson;
import java.util.Map;
import java.util.function.IntFunction;
import java.util.function.LongFunction;
public class MongoCommandOpDispenser extends BaseOpDispenser<MongoDirectCommandOp, MongoSpace> {

View File

@ -20,9 +20,14 @@ import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoDatabase;
import io.nosqlbench.adapter.mongodb.core.MongoSpace;
import io.nosqlbench.adapter.mongodb.core.MongodbDriverAdapter;
import io.nosqlbench.adapter.mongodb.ops.MongoDbUpdateOp;
import io.nosqlbench.adapter.mongodb.ops.MongoDirectCommandOp;
import io.nosqlbench.adapter.mongodb.ops.MongoOp;
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import org.bson.BsonDocument;
import org.bson.conversions.Bson;
import java.util.function.LongFunction;
@ -30,9 +35,9 @@ import java.util.function.LongFunction;
* https://www.mongodb.com/docs/manual/reference/command/update/#mongodb-dbcommand-dbcmd.update
* https://www.mongodb.com/docs/drivers/java/sync/current/usage-examples/updateOne/
*/
public class MongoDbUpdateOpDispenser extends BaseOpDispenser<Op, MongoSpace> {
public class MongoDbUpdateOpDispenser extends BaseOpDispenser<MongoOp<?>, MongoSpace> {
private final LongFunction<MongoSpace> spaceF;
private final LongFunction<Op> opF;
private final LongFunction<MongoOp<?>> opF;
private final LongFunction<String> collectionF;
public MongoDbUpdateOpDispenser(MongodbDriverAdapter adapter, ParsedOp pop, LongFunction<String> collectionF) {
@ -42,15 +47,16 @@ public class MongoDbUpdateOpDispenser extends BaseOpDispenser<Op, MongoSpace> {
this.opF = createOpF(pop);
}
private LongFunction<Op> createOpF(ParsedOp pop) {
private LongFunction<MongoOp<?>> createOpF(ParsedOp pop) {
LongFunction<MongoClient> clientF = cycle -> spaceF.apply(cycle).getClient();
LongFunction<MongoDatabase> docF = l -> clientF.apply(l).getDatabase(collectionF.apply(l));
return l -> new Op() {};
// TODO This needs to be completed for at least one working example of a specialized op form.
return l -> new MongoDirectCommandOp(clientF.apply(l),docF.apply(l).getName(),new BsonDocument());
}
@Override
public Op getOp(long value) {
Op op = opF.apply(value);
public MongoOp<?> getOp(long value) {
MongoOp<?> op = opF.apply(value);
return op;
}

View File

@ -0,0 +1,30 @@
package io.nosqlbench.adapter.mongodb.ops;
/*
* Copyright (c) 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.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import org.bson.Document;
public class MongoDbUpdateOp implements CycleOp<Document> {
@Override
public Document apply(long value) {
return null;
}
}

View File

@ -21,7 +21,7 @@ import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import org.bson.Document;
import org.bson.conversions.Bson;
public class MongoDirectCommandOp implements CycleOp<Document> {
public class MongoDirectCommandOp implements MongoOp<Document> {
private final MongoClient client;
private final Bson rqBson;

View File

@ -0,0 +1,24 @@
package io.nosqlbench.adapter.mongodb.ops;
/*
* Copyright (c) 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.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
public interface MongoOp<T> extends CycleOp<T> {
}

View File

@ -33,14 +33,14 @@ import java.util.function.LongFunction;
import static io.nosqlbench.adapter.qdrant.QdrantAdapterUtils.QDRANT;
@Service(value = DriverAdapter.class, selector = QDRANT)
public class QdrantDriverAdapter extends BaseDriverAdapter<QdrantBaseOp, QdrantSpace> {
public class QdrantDriverAdapter extends BaseDriverAdapter<QdrantBaseOp<?,?>, QdrantSpace> {
public QdrantDriverAdapter(NBComponent parentComponent, NBLabels labels) {
super(parentComponent, labels);
}
@Override
public OpMapper<QdrantBaseOp,QdrantSpace> getOpMapper() {
public OpMapper<QdrantBaseOp<?,?>,QdrantSpace> getOpMapper() {
return new QdrantOpMapper(this);
}

View File

@ -30,7 +30,7 @@ import org.apache.logging.log4j.Logger;
import java.util.function.IntFunction;
import java.util.function.LongFunction;
public class QdrantOpMapper implements OpMapper<QdrantBaseOp,QdrantSpace> {
public class QdrantOpMapper implements OpMapper<QdrantBaseOp<?,?>,QdrantSpace> {
private static final Logger logger = LogManager.getLogger(QdrantOpMapper.class);
private final QdrantDriverAdapter adapter;
@ -52,7 +52,7 @@ public class QdrantOpMapper implements OpMapper<QdrantBaseOp,QdrantSpace> {
* @return The correct {@link QdrantBaseOpDispenser} subclass based on the op type
*/
@Override
public OpDispenser<QdrantBaseOp> apply(ParsedOp op, LongFunction<QdrantSpace> spaceInitF) {
public OpDispenser<QdrantBaseOp<?,?>> apply(ParsedOp op, LongFunction<QdrantSpace> spaceInitF) {
TypeAndTarget<QdrantOpType, String> typeAndTarget = op.getTypeAndTarget(
QdrantOpType.class,
String.class,
@ -61,7 +61,7 @@ public class QdrantOpMapper implements OpMapper<QdrantBaseOp,QdrantSpace> {
);
logger.info(() -> "Using '" + typeAndTarget.enumId + "' op type for op template '" + op.getName() + "'");
return switch (typeAndTarget.enumId) {
OpDispenser<QdrantBaseOp<?,?>> dispenser = switch (typeAndTarget.enumId) {
case delete_collection -> new QdrantDeleteCollectionOpDispenser(adapter, op, typeAndTarget.targetFunction);
case create_collection -> new QdrantCreateCollectionOpDispenser(adapter, op, typeAndTarget.targetFunction);
case create_payload_index ->
@ -78,6 +78,7 @@ public class QdrantOpMapper implements OpMapper<QdrantBaseOp,QdrantSpace> {
// default -> throw new RuntimeException("Unrecognized op type '" + typeAndTarget.enumId.name() + "' while " +
// "mapping parsed op " + op);
};
return dispenser;
}
}

View File

@ -41,12 +41,13 @@ import java.util.function.LongFunction;
import static io.qdrant.client.ConditionFactory.*;
public abstract class QdrantBaseOpDispenser<T> extends BaseOpDispenser<QdrantBaseOp, QdrantSpace> {
public abstract class QdrantBaseOpDispenser<REQUEST,RESULT>
extends BaseOpDispenser<QdrantBaseOp<?,?>, QdrantSpace> {
protected final LongFunction<QdrantSpace> qdrantSpaceFunction;
protected final LongFunction<QdrantClient> clientFunction;
private final LongFunction<? extends QdrantBaseOp<T>> opF;
private final LongFunction<T> paramF;
private final LongFunction<? extends QdrantBaseOp<REQUEST, RESULT>> opF;
private final LongFunction<REQUEST> paramF;
protected QdrantBaseOpDispenser(QdrantDriverAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
super((DriverAdapter)adapter, op);
@ -59,21 +60,21 @@ public abstract class QdrantBaseOpDispenser<T> extends BaseOpDispenser<QdrantBas
return (QdrantDriverAdapter) adapter;
}
public abstract LongFunction<T> getParamFunc(
public abstract LongFunction<REQUEST> getParamFunc(
LongFunction<QdrantClient> clientF,
ParsedOp op,
LongFunction<String> targetF
);
public abstract LongFunction<QdrantBaseOp<T>> createOpFunc(
LongFunction<T> paramF,
public abstract LongFunction<QdrantBaseOp<REQUEST, RESULT>> createOpFunc(
LongFunction<REQUEST> paramF,
LongFunction<QdrantClient> clientF,
ParsedOp op,
LongFunction<String> targetF
);
@Override
public QdrantBaseOp<T> getOp(long value) {
public QdrantBaseOp<REQUEST, RESULT> getOp(long value) {
return opF.apply(value);
}
@ -477,7 +478,7 @@ public abstract class QdrantBaseOpDispenser<T> extends BaseOpDispenser<QdrantBas
}
/**
* This {@link nested} is only valid within a 'must' filter condition.
* This {@link io.qdrant.client.grpc.Points.NestedCondition} is only valid within a 'must' filter condition.
*
* @param filterFields
* @return

View File

@ -25,7 +25,7 @@ import io.qdrant.client.grpc.Collections.CollectionExistsRequest;
import java.util.function.LongFunction;
public class QdrantCollectionExistsOpDispenser extends QdrantBaseOpDispenser<CollectionExistsRequest> {
public class QdrantCollectionExistsOpDispenser extends QdrantBaseOpDispenser<CollectionExistsRequest,Boolean> {
public QdrantCollectionExistsOpDispenser(QdrantDriverAdapter adapter, ParsedOp op, LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@ -41,7 +41,7 @@ public class QdrantCollectionExistsOpDispenser extends QdrantBaseOpDispenser<Col
}
@Override
public LongFunction<QdrantBaseOp<CollectionExistsRequest>> createOpFunc(
public LongFunction<QdrantBaseOp<CollectionExistsRequest,Boolean>> createOpFunc(
LongFunction<CollectionExistsRequest> paramF,
LongFunction<QdrantClient> clientF,
ParsedOp op,

View File

@ -21,10 +21,11 @@ import io.nosqlbench.adapter.qdrant.ops.QdrantBaseOp;
import io.nosqlbench.adapter.qdrant.ops.QdrantCollectionInfoOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.grpc.Collections;
import java.util.function.LongFunction;
public class QdrantCollectionInfoOpDispenser extends QdrantBaseOpDispenser<String> {
public class QdrantCollectionInfoOpDispenser extends QdrantBaseOpDispenser<String, Collections.CollectionInfo> {
public QdrantCollectionInfoOpDispenser(QdrantDriverAdapter adapter, ParsedOp op, LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@ -36,7 +37,7 @@ public class QdrantCollectionInfoOpDispenser extends QdrantBaseOpDispenser<Strin
}
@Override
public LongFunction<QdrantBaseOp<String>> createOpFunc(
public LongFunction<QdrantBaseOp<String, Collections.CollectionInfo>> createOpFunc(
LongFunction<String> paramF,
LongFunction<QdrantClient> clientF,
ParsedOp op,

View File

@ -26,7 +26,7 @@ import io.qdrant.client.grpc.Points.Filter;
import java.util.function.LongFunction;
public class QdrantCountPointsOpDispenser extends QdrantBaseOpDispenser<CountPoints> {
public class QdrantCountPointsOpDispenser extends QdrantBaseOpDispenser<CountPoints,Long> {
public QdrantCountPointsOpDispenser(QdrantDriverAdapter adapter, ParsedOp op, LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@ -50,7 +50,7 @@ public class QdrantCountPointsOpDispenser extends QdrantBaseOpDispenser<CountPoi
}
@Override
public LongFunction<QdrantBaseOp<CountPoints>> createOpFunc(
public LongFunction<QdrantBaseOp<CountPoints,Long>> createOpFunc(
LongFunction<CountPoints> paramF,
LongFunction<QdrantClient> clientF,
ParsedOp op,

View File

@ -21,6 +21,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.function.LongFunction;
import io.qdrant.client.grpc.Collections;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -48,7 +49,7 @@ import io.qdrant.client.grpc.Collections.VectorParamsMap;
import io.qdrant.client.grpc.Collections.VectorsConfig;
import io.qdrant.client.grpc.Collections.WalConfigDiff;
public class QdrantCreateCollectionOpDispenser extends QdrantBaseOpDispenser<CreateCollection> {
public class QdrantCreateCollectionOpDispenser extends QdrantBaseOpDispenser<CreateCollection, Collections.CollectionOperationResponse> {
private static final Logger logger = LogManager.getLogger(QdrantCreateCollectionOpDispenser.class);
/**
@ -364,7 +365,7 @@ public class QdrantCreateCollectionOpDispenser extends QdrantBaseOpDispenser<Cre
// https://qdrant.tech/documentation/concepts/collections/#create-a-collection
@Override
public LongFunction<QdrantBaseOp<CreateCollection>> createOpFunc(
public LongFunction<QdrantBaseOp<CreateCollection, Collections.CollectionOperationResponse>> createOpFunc(
LongFunction<CreateCollection> paramF,
LongFunction<QdrantClient> clientF,
ParsedOp op,

View File

@ -21,6 +21,7 @@ import io.nosqlbench.adapter.qdrant.ops.QdrantBaseOp;
import io.nosqlbench.adapter.qdrant.ops.QdrantCreatePayloadIndexOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.grpc.Points;
import io.qdrant.client.grpc.Points.CreateFieldIndexCollection;
import io.qdrant.client.grpc.Points.FieldType;
import io.qdrant.client.grpc.Points.WriteOrdering;
@ -29,7 +30,7 @@ import io.qdrant.client.grpc.Points.WriteOrderingType;
import java.util.Optional;
import java.util.function.LongFunction;
public class QdrantCreatePayloadIndexOpDispenser extends QdrantBaseOpDispenser<CreateFieldIndexCollection> {
public class QdrantCreatePayloadIndexOpDispenser extends QdrantBaseOpDispenser<CreateFieldIndexCollection, Points.UpdateResult> {
public QdrantCreatePayloadIndexOpDispenser(
QdrantDriverAdapter adapter,
ParsedOp op,
@ -65,7 +66,7 @@ public class QdrantCreatePayloadIndexOpDispenser extends QdrantBaseOpDispenser<C
}
@Override
public LongFunction<QdrantBaseOp<CreateFieldIndexCollection>> createOpFunc(
public LongFunction<QdrantBaseOp<CreateFieldIndexCollection, Points.UpdateResult>> createOpFunc(
LongFunction<CreateFieldIndexCollection> paramF,
LongFunction<QdrantClient> clientF,
ParsedOp op,

View File

@ -21,11 +21,14 @@ import io.nosqlbench.adapter.qdrant.ops.QdrantBaseOp;
import io.nosqlbench.adapter.qdrant.ops.QdrantDeleteCollectionOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.grpc.Collections;
import io.qdrant.client.grpc.Collections.DeleteCollection;
import java.util.List;
import java.util.function.LongFunction;
public class QdrantDeleteCollectionOpDispenser extends QdrantBaseOpDispenser<DeleteCollection> {
public class QdrantDeleteCollectionOpDispenser
extends QdrantBaseOpDispenser<DeleteCollection, Collections.CollectionOperationResponse> {
/**
* Create a new {@link QdrantDeleteCollectionOpDispenser} subclassed from {@link QdrantBaseOpDispenser}.
@ -42,21 +45,15 @@ public class QdrantDeleteCollectionOpDispenser extends QdrantBaseOpDispenser<Del
}
@Override
public LongFunction<DeleteCollection> getParamFunc(
LongFunction<QdrantClient> clientF,
ParsedOp op,
LongFunction<String> targetF) {
public LongFunction<DeleteCollection> getParamFunc(LongFunction<QdrantClient> clientF, ParsedOp op, LongFunction<String> targetF) {
LongFunction<DeleteCollection.Builder> ebF =
l -> DeleteCollection.newBuilder().setCollectionName(targetF.apply(l));
return l -> ebF.apply(l).build();
}
@Override
public LongFunction<QdrantBaseOp<DeleteCollection>> createOpFunc(
LongFunction<DeleteCollection> paramF,
LongFunction<QdrantClient> clientF,
ParsedOp op,
LongFunction<String> targetF) {
public LongFunction<QdrantBaseOp<DeleteCollection, Collections.CollectionOperationResponse>> createOpFunc(LongFunction<DeleteCollection> paramF, LongFunction<QdrantClient> clientF, ParsedOp op, LongFunction<String> targetF) {
return l -> new QdrantDeleteCollectionOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@ -23,9 +23,10 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.grpc.Collections.ListCollectionAliasesRequest;
import java.util.List;
import java.util.function.LongFunction;
public class QdrantListCollectionAliasesOpDispenser extends QdrantBaseOpDispenser<ListCollectionAliasesRequest> {
public class QdrantListCollectionAliasesOpDispenser extends QdrantBaseOpDispenser<ListCollectionAliasesRequest, List<String>> {
public QdrantListCollectionAliasesOpDispenser(QdrantDriverAdapter adapter, ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
@ -42,7 +43,7 @@ public class QdrantListCollectionAliasesOpDispenser extends QdrantBaseOpDispense
}
@Override
public LongFunction<QdrantBaseOp<ListCollectionAliasesRequest>> createOpFunc(
public LongFunction<QdrantBaseOp<ListCollectionAliasesRequest,List<String>>> createOpFunc(
LongFunction<ListCollectionAliasesRequest> paramF,
LongFunction<QdrantClient> clientF, ParsedOp op, LongFunction<String> targetF) {
return l -> new QdrantListCollectionAliasesOp(clientF.apply(l), paramF.apply(l));

View File

@ -22,24 +22,29 @@ import io.nosqlbench.adapter.qdrant.ops.QdrantListCollectionsOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.qdrant.client.QdrantClient;
import java.util.List;
import java.util.function.LongFunction;
public class QdrantListCollectionsOpDispenser extends QdrantBaseOpDispenser<Object> {
public class QdrantListCollectionsOpDispenser extends QdrantBaseOpDispenser<Void,List<String>> {
public QdrantListCollectionsOpDispenser(QdrantDriverAdapter adapter,
ParsedOp op, LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<Object> getParamFunc(LongFunction<QdrantClient> clientF, ParsedOp op, LongFunction<String> targetF) {
return l -> "";
public LongFunction<Void> getParamFunc(LongFunction<QdrantClient> clientF, ParsedOp op,
LongFunction<String> targetF) {
return null;
}
@Override
public LongFunction<QdrantBaseOp<Object>> createOpFunc(
LongFunction<Object> paramF,
public LongFunction<QdrantBaseOp<Void, List<String>>> createOpFunc(
LongFunction<Void> paramF,
LongFunction<QdrantClient> clientF,
ParsedOp op, LongFunction<String> targetF) {
return l -> new QdrantListCollectionsOp(clientF.apply(l), null);
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new QdrantListCollectionsOp(clientF.apply(l), null);
}
}

View File

@ -21,11 +21,13 @@ import io.nosqlbench.adapter.qdrant.ops.QdrantBaseOp;
import io.nosqlbench.adapter.qdrant.ops.QdrantListSnapshotsOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.grpc.SnapshotsService;
import io.qdrant.client.grpc.SnapshotsService.ListSnapshotsRequest;
import java.util.List;
import java.util.function.LongFunction;
public class QdrantListSnapshotsOpDispenser extends QdrantBaseOpDispenser<ListSnapshotsRequest> {
public class QdrantListSnapshotsOpDispenser extends QdrantBaseOpDispenser<ListSnapshotsRequest, List<SnapshotsService.SnapshotDescription>> {
public QdrantListSnapshotsOpDispenser(QdrantDriverAdapter adapter, ParsedOp op, LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@ -41,9 +43,11 @@ public class QdrantListSnapshotsOpDispenser extends QdrantBaseOpDispenser<ListSn
}
@Override
public LongFunction<QdrantBaseOp<ListSnapshotsRequest>> createOpFunc(LongFunction<ListSnapshotsRequest> paramF,
LongFunction<QdrantClient> clientF,
ParsedOp op, LongFunction<String> targetF) {
public LongFunction<QdrantBaseOp<ListSnapshotsRequest, List<SnapshotsService.SnapshotDescription>>> createOpFunc(
LongFunction<ListSnapshotsRequest> paramF,
LongFunction<QdrantClient> clientF,
ParsedOp op, LongFunction<String> targetF
) {
return l -> new QdrantListSnapshotsOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@ -33,13 +33,13 @@ import java.util.Map;
import java.util.Optional;
import java.util.function.LongFunction;
public class QdrantSearchPointsOpDispenser extends QdrantBaseOpDispenser<SearchPoints> {
public class QdrantSearchPointsOpDispenser extends QdrantBaseOpDispenser<SearchPoints,List<ScoredPoint>> {
public QdrantSearchPointsOpDispenser(QdrantDriverAdapter adapter, ParsedOp op, LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<QdrantBaseOp<SearchPoints>> createOpFunc(
public LongFunction<QdrantBaseOp<SearchPoints,List<ScoredPoint>>> createOpFunc(
LongFunction<SearchPoints> paramF,
LongFunction<QdrantClient> clientF,
ParsedOp op, LongFunction<String> targetF) {

View File

@ -36,7 +36,7 @@ import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.LongFunction;
public class QdrantUpsertPointsOpDispenser extends QdrantBaseOpDispenser<UpsertPoints> {
public class QdrantUpsertPointsOpDispenser extends QdrantBaseOpDispenser<UpsertPoints,UpdateResult> {
private static final Logger logger = LogManager.getLogger(QdrantUpsertPointsOpDispenser.class);
/**
@ -181,7 +181,7 @@ public class QdrantUpsertPointsOpDispenser extends QdrantBaseOpDispenser<UpsertP
* @see <a href="https://qdrant.tech/documentation/concepts/points/">Upsert Points</a>
*/
@Override
public LongFunction<QdrantBaseOp<UpsertPoints>> createOpFunc(
public LongFunction<QdrantBaseOp<UpsertPoints,UpdateResult>> createOpFunc(
LongFunction<UpsertPoints> paramF,
LongFunction<QdrantClient> clientF,
ParsedOp op,

View File

@ -23,32 +23,32 @@ import org.apache.logging.log4j.Logger;
import java.util.function.LongFunction;
public abstract class QdrantBaseOp<T> implements CycleOp<Object> {
public abstract class QdrantBaseOp<REQUEST,RESULT> implements CycleOp<RESULT> {
protected final static Logger logger = LogManager.getLogger(QdrantBaseOp.class);
protected final QdrantClient client;
protected final T request;
protected final REQUEST request;
protected final LongFunction<Object> apiCall;
public QdrantBaseOp(QdrantClient client, T requestParam) {
public QdrantBaseOp(QdrantClient client, REQUEST requestParam) {
this.client = client;
this.request = requestParam;
this.apiCall = this::applyOp;
}
public QdrantBaseOp(QdrantClient client, T requestParam, LongFunction<Object> call) {
public QdrantBaseOp(QdrantClient client, REQUEST requestParam, LongFunction<Object> call) {
this.client = client;
this.request = requestParam;
this.apiCall = call;
}
@Override
public final Object apply(long value) {
public final RESULT apply(long value) {
logger.trace("applying op: {}", this);
try {
Object result = applyOp(value);
RESULT result = applyOp(value);
return result;
} catch (Exception e) {
RuntimeException rte = (RuntimeException) e;
@ -56,7 +56,7 @@ public abstract class QdrantBaseOp<T> implements CycleOp<Object> {
}
}
public abstract Object applyOp(long value);
public abstract RESULT applyOp(long value);
@Override
public String toString() {

View File

@ -21,13 +21,13 @@ import io.qdrant.client.grpc.Collections.CollectionExistsRequest;
import java.time.Duration;
public class QdrantCollectionExistsOp extends QdrantBaseOp<CollectionExistsRequest> {
public class QdrantCollectionExistsOp extends QdrantBaseOp<CollectionExistsRequest,Boolean> {
public QdrantCollectionExistsOp(QdrantClient client, CollectionExistsRequest request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
public Boolean applyOp(long value) {
Boolean response;
try {
response = client.collectionExistsAsync(request.getCollectionName(), Duration.ofSeconds(600)).get();

View File

@ -21,13 +21,13 @@ import io.qdrant.client.grpc.Collections.CollectionInfo;
import java.time.Duration;
public class QdrantCollectionInfoOp extends QdrantBaseOp<String> {
public class QdrantCollectionInfoOp extends QdrantBaseOp<String, CollectionInfo> {
public QdrantCollectionInfoOp(QdrantClient client, String request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
public CollectionInfo applyOp(long value) {
CollectionInfo response;
try {
response = client.getCollectionInfoAsync(request, Duration.ofSeconds(600)).get();

View File

@ -22,13 +22,13 @@ import io.qdrant.client.grpc.Points.CountPoints;
import java.time.Duration;
import java.util.concurrent.ExecutionException;
public class QdrantCountPointsOp extends QdrantBaseOp<CountPoints> {
public class QdrantCountPointsOp extends QdrantBaseOp<CountPoints,Long> {
public QdrantCountPointsOp(QdrantClient client, CountPoints request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
public Long applyOp(long value) {
long result;
try {
boolean hasFilters = request.getFilter() != null && (request.getFilter().getMustCount() > 0

View File

@ -23,7 +23,7 @@ import io.qdrant.client.grpc.Collections.CreateCollection;
import java.util.concurrent.ExecutionException;
public class QdrantCreateCollectionOp extends QdrantBaseOp<CreateCollection> {
public class QdrantCreateCollectionOp extends QdrantBaseOp<CreateCollection,CollectionOperationResponse> {
/**
* Create a new {@link ParsedOp} encapsulating a call to the <b>Qdrant</b> create collection method.
*
@ -35,7 +35,7 @@ public class QdrantCreateCollectionOp extends QdrantBaseOp<CreateCollection> {
}
@Override
public Object applyOp(long value) {
public CollectionOperationResponse applyOp(long value) {
CollectionOperationResponse response = null;
try {
response = client.createCollectionAsync(request).get();

View File

@ -23,13 +23,13 @@ import io.qdrant.client.grpc.Points.UpdateResult;
import java.time.Duration;
public class QdrantCreatePayloadIndexOp extends QdrantBaseOp<CreateFieldIndexCollection> {
public class QdrantCreatePayloadIndexOp extends QdrantBaseOp<CreateFieldIndexCollection,UpdateResult> {
public QdrantCreatePayloadIndexOp(QdrantClient client, CreateFieldIndexCollection request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
public UpdateResult applyOp(long value) {
UpdateResult response;
try {
response = client.createPayloadIndexAsync(

View File

@ -22,13 +22,13 @@ import io.qdrant.client.grpc.Collections.DeleteCollection;
import java.util.concurrent.ExecutionException;
public class QdrantDeleteCollectionOp extends QdrantBaseOp<DeleteCollection> {
public class QdrantDeleteCollectionOp extends QdrantBaseOp<DeleteCollection,CollectionOperationResponse> {
public QdrantDeleteCollectionOp(QdrantClient client, DeleteCollection request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
public CollectionOperationResponse applyOp(long value) {
CollectionOperationResponse response = null;
try {
response = client.deleteCollectionAsync(request.getCollectionName()).get();

View File

@ -22,13 +22,13 @@ import io.qdrant.client.grpc.Collections.ListCollectionAliasesRequest;
import java.time.Duration;
import java.util.List;
public class QdrantListCollectionAliasesOp extends QdrantBaseOp<ListCollectionAliasesRequest> {
public class QdrantListCollectionAliasesOp extends QdrantBaseOp<ListCollectionAliasesRequest,List<String>> {
public QdrantListCollectionAliasesOp(QdrantClient client, ListCollectionAliasesRequest request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
public List<String> applyOp(long value) {
List<String> response;
try {
response = client.listCollectionAliasesAsync(request.getCollectionName(), Duration.ofSeconds(600)).get();

View File

@ -21,12 +21,12 @@ import io.qdrant.client.QdrantClient;
import java.time.Duration;
import java.util.List;
public class QdrantListCollectionsOp extends QdrantBaseOp<Object> {
public class QdrantListCollectionsOp extends QdrantBaseOp<Void,List<String>> {
public QdrantListCollectionsOp(QdrantClient client, Object request) {
super(client, request);
super(client, (Void)request);
}
@Override
public Object applyOp(long value) {
public List<String> applyOp(long value) {
List<String> response;
try {
response = client.listCollectionsAsync(Duration.ofSeconds(300)).get();

View File

@ -23,13 +23,13 @@ import io.qdrant.client.grpc.SnapshotsService.SnapshotDescription;
import java.time.Duration;
import java.util.List;
public class QdrantListSnapshotsOp extends QdrantBaseOp<ListSnapshotsRequest> {
public class QdrantListSnapshotsOp extends QdrantBaseOp<ListSnapshotsRequest,List<SnapshotDescription>> {
public QdrantListSnapshotsOp(QdrantClient client, ListSnapshotsRequest request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
public List<SnapshotDescription> applyOp(long value) {
List<SnapshotDescription> response;
try {
response = client.listSnapshotAsync(request.getCollectionName(), Duration.ofSeconds(600)).get();

View File

@ -23,13 +23,13 @@ import io.qdrant.client.grpc.Points.SearchPoints;
import java.util.List;
import java.util.concurrent.ExecutionException;
public class QdrantSearchPointsOp extends QdrantBaseOp<SearchPoints> {
public class QdrantSearchPointsOp extends QdrantBaseOp<SearchPoints,List<ScoredPoint>> {
public QdrantSearchPointsOp(QdrantClient client, SearchPoints request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
public List<ScoredPoint> applyOp(long value) {
List<ScoredPoint> response = null;
try {
logger.debug("[QdrantSearchPointsOp] Cycle {} has request: {}", value, request.toString());

View File

@ -22,13 +22,13 @@ import io.qdrant.client.grpc.Points.UpsertPoints;
import java.util.concurrent.ExecutionException;
public class QdrantUpsertPointsOp extends QdrantBaseOp<UpsertPoints> {
public class QdrantUpsertPointsOp extends QdrantBaseOp<UpsertPoints,UpdateResult> {
public QdrantUpsertPointsOp(QdrantClient client, UpsertPoints request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
public UpdateResult applyOp(long value) {
UpdateResult response = null;
String responseStatus;
long responseOperationId;

View File

@ -27,6 +27,8 @@ public class TcpClientOp implements RunnableOp {
this.ctx = ctx;
this.text = text;
}
@Override
public void run() {
ctx.writeflush(text);
}

View File

@ -20,10 +20,10 @@ package io.nosqlbench.adapter.diag;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.nb.api.labels.NBLabels;
import io.nosqlbench.nb.api.components.core.NBComponent;
public interface DriverAdapterLoader {
public <A extends Op,B extends Space> DriverAdapter<A,B> load(NBComponent parent, NBLabels childLabels);
public <A extends CycleOp<?>,B extends Space> DriverAdapter<A,B> load(NBComponent parent, NBLabels childLabels);
}

View File

@ -20,7 +20,7 @@ import com.codahale.metrics.Timer;
import groovy.lang.Binding;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.evalctx.*;
import io.nosqlbench.adapters.api.metrics.ThreadLocalNamedTimers;
import io.nosqlbench.adapters.api.templating.ParsedOp;
@ -46,7 +46,8 @@ import java.util.concurrent.TimeUnit;
* @param <OP>
* The type of operation
*/
public abstract class BaseOpDispenser<OP extends Op,SPACE extends Space> extends NBBaseComponent implements OpDispenser<OP>{
public abstract class BaseOpDispenser<OP extends CycleOp<?>,SPACE extends Space>
extends NBBaseComponent implements OpDispenser<OP> {
protected final static Logger logger = LogManager.getLogger(BaseOpDispenser.class);
public static final String VERIFIER = "verifier";
public static final String VERIFIER_INIT = "verifier-init";

View File

@ -16,7 +16,7 @@
package io.nosqlbench.adapters.api.activityimpl;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.evalctx.CycleFunction;
import java.util.function.LongFunction;
@ -67,9 +67,9 @@ import java.util.function.LongFunction;
*
* @param <OP> The parameter type of the actual operation which will be used
* to hold all the details for executing an operation,
* something that implements {@link Op}.
* something that implements {@link io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp}.
*/
public interface OpDispenser<OP extends Op> extends LongFunction<OP>, OpResultTracker {
public interface OpDispenser<OP extends CycleOp<?>> extends LongFunction<OP>, OpResultTracker {
/**
* The apply method in an op dispenser should do all the work of

View File

@ -18,12 +18,10 @@ package io.nosqlbench.adapters.api.activityimpl;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.LongFunction;
/**
@ -83,7 +81,7 @@ import java.util.function.LongFunction;
* to hold all the details for executing an operation,
* generally something that implements {@link Runnable}.
*/
public interface OpMapper<OPTYPE extends Op, SPACETYPE extends Space>
public interface OpMapper<OPTYPE extends CycleOp<?>, SPACETYPE extends Space>
extends BiFunction<ParsedOp, LongFunction<SPACETYPE>, OpDispenser<OPTYPE>> {
/**
@ -96,6 +94,7 @@ public interface OpMapper<OPTYPE extends Op, SPACETYPE extends Space>
* @param spaceInitF
* @return An OpDispenser which can be used to synthesize real operations.
*/
OpDispenser<OPTYPE> apply(ParsedOp op, LongFunction<SPACETYPE> spaceInitF);
@Override
OpDispenser<OPTYPE> apply(ParsedOp op, LongFunction<SPACETYPE> spaceInitF);
}

View File

@ -19,7 +19,7 @@ package io.nosqlbench.adapters.api.activityimpl.docs;
import io.nosqlbench.adapter.diag.DriverAdapterLoader;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.nb.api.docsapi.BundledMarkdownManifest;
import io.nosqlbench.nb.api.docsapi.Docs;
import io.nosqlbench.nb.api.docsapi.DocsBinder;
@ -41,7 +41,7 @@ public class BundledDriverAdapterDocs implements BundledMarkdownManifest {
List<SimpleServiceLoader.Component<? extends DriverAdapterLoader>> namedProviders = loader.getNamedProviders();
for (SimpleServiceLoader.Component<? extends DriverAdapterLoader> namedProvider : namedProviders) {
DriverAdapterLoader driverAdapterLoader = namedProvider.provider.get();
DriverAdapter<Op, Space> driverAdapter = driverAdapterLoader.load(
DriverAdapter<? extends CycleOp<?>, Space> driverAdapter = driverAdapterLoader.load(
NBComponent.EMPTY_COMPONENT,
NBLabels.forKV()
);

View File

@ -16,8 +16,8 @@
package io.nosqlbench.adapters.api.activityimpl.uniform;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.activityimpl.uniform.fieldmappers.FieldDestructuringMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.nb.api.config.standard.*;
import io.nosqlbench.nb.api.labels.NBLabels;
@ -33,10 +33,9 @@ import java.util.Optional;
import java.util.function.Function;
import java.util.function.LongFunction;
import java.util.function.LongToIntFunction;
import java.util.function.LongUnaryOperator;
import java.util.stream.Collectors;
public abstract class BaseDriverAdapter<R extends Op, S extends Space> extends NBBaseComponent implements DriverAdapter<R, S>, NBConfigurable, NBReconfigurable {
public abstract class BaseDriverAdapter<R extends CycleOp<?>, S extends Space> extends NBBaseComponent implements DriverAdapter<R, S>, NBConfigurable, NBReconfigurable {
private final static Logger logger = LogManager.getLogger("ADAPTER");
private ConcurrentSpaceCache<S> spaceCache;

View File

@ -18,10 +18,7 @@ package io.nosqlbench.adapters.api.activityimpl.uniform;
*/
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import java.util.function.IntFunction;
import java.util.function.LongFunction;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
public class BaseSpace<SelfT extends BaseSpace<SelfT> > implements Space {
@ -39,7 +36,7 @@ public class BaseSpace<SelfT extends BaseSpace<SelfT> > implements Space {
}
public static class BasicSpace extends BaseSpace<BasicSpace> implements Space {
public BasicSpace(DriverAdapter<Op, BasicSpace> adapter, long idx) {
public BasicSpace(DriverAdapter<? extends CycleOp<?>, BasicSpace> adapter, long idx) {
super(adapter, idx);
}
}

View File

@ -18,7 +18,7 @@ package io.nosqlbench.adapters.api.activityimpl.uniform;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.nb.api.docsapi.Docs;
import io.nosqlbench.nb.api.docsapi.DocsBinder;
import io.nosqlbench.adapters.api.templating.ParsedOp;
@ -33,7 +33,6 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.LongFunction;
/**
@ -56,7 +55,7 @@ import java.util.function.LongFunction;
* during construction of R type operations, or even for individual
* operations.
*/
public interface DriverAdapter<OPTYPE extends Op, SPACETYPE extends Space> extends NBComponent {
public interface DriverAdapter<OPTYPE extends CycleOp<?>, SPACETYPE extends Space> extends NBComponent {
/**
* <p>

View File

@ -1,43 +0,0 @@
/*
* Copyright (c) 2022-2023 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.
*/
package io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes;
import java.util.function.Function;
/**
* <H2>ChainingOp&lt;I,O&gt;: f(I) -> O&lt;I,O&gt;</H2>
* <P>
* Run a function on the current cached result in the current thread and replace it
* with the result of the function. ChainingOps are one way of invoking
* logic within a cycle. However, they are not intended to stand alone.
* A ChainingOp must always have an input to work on,
* provided by either a {@link CycleOp} OR <em>another</em> call to a {@link ChainingOp}</P>
*
* @param <I> Some input type, as determined by a previous {@link CycleOp} or {@link ChainingOp} on the same thread.
* @param <O> Some output type.
*/
public interface ChainingOp<I, O> extends Op, Function<I, O> {
/**
* Transform a value from a previous action and provide the result for a subsequent action.
*
* @param lastResult object form a previous operation or action
* @return a new result
*/
@Override
O apply(I lastResult);
}

View File

@ -27,12 +27,6 @@ import java.util.function.LongFunction;
* and produces a value of type T. It is implemented as
* {@link LongFunction} of T.</p>
*
* <P>This variant of {@link Op} has the ability to see the cycle
* which was previously used to select the op implementation.</p>
*
* <p>It also has the ability to emit an value which can be seen a subsequent operation, if
* and only if it is a {@link ChainingOp}s.</P>
*
* <h2>Designer Notes</h2>
* <p>
* If you are using the value in this call to select a specific type of behavior, it is very
@ -43,12 +37,11 @@ import java.util.function.LongFunction;
* </p>
*
*/
public interface CycleOp<T> extends Op, LongFunction<T> {
public interface CycleOp<T> extends LongFunction<T> {
/**
* <p>Run an action for the given cycle.</p>
*
* @param value The cycle value for which an operation is run
* @return A result object which <em>may</em> be used by a subsequent {@link ChainingOp}
*/
@Override
T apply(long value);

View File

@ -1,37 +0,0 @@
/*
* Copyright (c) 2022-2023 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.
*/
package io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes;
/**
* <p>This is the root type of any operation which is used in a NoSQLBench
* DriverAdapter. It is a tagging interface for incremental type validation
* in the NB runtime. You probably don't want to use it directly.</p>
*
* <p>Instead, use <em>one</em> of these:
* <ul>
* <li>{@link CycleOp}</li> - An interface that will called if there is nothing to consume
* the result type from your operation. In some cases preparing a result body to
* hand down the chain is more costly, so implementing this interface allows the runtime
* to be more optimized.</li>
* <li>{@link ChainingOp}</li>
* <li>{@link RunnableOp}</li>
* </ul>
* </p>
*/
// TODO: optimize the runtime around the specific op type
public interface Op {
}

View File

@ -31,5 +31,5 @@ package io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes;
*
*/
public interface OpGenerator {
Op getNextOp();
CycleOp<?> getNextOp();
}

View File

@ -1,34 +1,28 @@
package io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes;
/*
* Copyright (c) 2022-2023 nosqlbench
*
* Copyright (c) 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.
*
* 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.
*/
package io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes;
/**
* <H2>RunnableOp</H2>
* <P>This is the simplest form of an executable operation in NoSQLBench.
* It is simply an operation is run for side-effect only.</P>
*/
public interface RunnableOp extends Op, Runnable {
public interface RunnableOp extends CycleOp<Void>,Runnable {
/**
* Invoke the operation. If you need to see the value of the current
* cycle, then you can use {@link CycleOp} instead. If you need to
* use a cached result of a previous operation, then you may need to
* use {@link ChainingOp}.
*/
@Override
void run();
default Void apply(long value) {
run();
return null;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@ -17,7 +17,6 @@
package io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
public class DryCycleOp<T> implements CycleOp<T> {

View File

@ -21,7 +21,6 @@ import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
public class DryCycleOpDispenserWrapper<S extends Space, RESULT> extends BaseOpDispenser<CycleOp<RESULT>, S> {

View File

@ -1,32 +0,0 @@
/*
* Copyright (c) 2022-2024 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.
*/
package io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
public class DryRunableOp implements RunnableOp {
private final RunnableOp op;
public DryRunableOp(RunnableOp op) {
this.op = op;
}
@Override
public void run() {
}
}

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2022-2024 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.
*/
package io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers;
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class DryRunnableOpDispenserWrapper<S extends Space> extends BaseOpDispenser<RunnableOp, S> {
private final OpDispenser<RunnableOp> realDispenser;
public DryRunnableOpDispenserWrapper(
DriverAdapter<RunnableOp, S> adapter,
ParsedOp pop,
OpDispenser<RunnableOp> realDispenser
) {
super(adapter, pop);
this.realDispenser = realDispenser;
logger.warn(
"initialized {} for dry run only. " +
"This op will be synthesized for each cycle, but will not be executed.",
pop.getName()
);
}
@Override
public DryRunableOp getOp(long cycle) {
RunnableOp op = realDispenser.getOp(cycle);
return new DryRunableOp(op);
}
}

View File

@ -21,7 +21,6 @@ import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
public class EmitterCycleOpDispenserWrapper<O,S extends Space,R> extends BaseOpDispenser<CycleOp<R>, S> {

View File

@ -21,14 +21,14 @@ import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.templating.ParsedOp;
public class EmitterOpDispenserWrapper extends BaseOpDispenser<Op, Space> {
public class EmitterOpDispenserWrapper extends BaseOpDispenser<CycleOp<?>, Space> {
private final OpDispenser<? extends CycleOp<?>> realDispenser;
public EmitterOpDispenserWrapper(DriverAdapter<Op,Space> adapter, ParsedOp pop, OpDispenser<? extends CycleOp<?>> realDispenser) {
public EmitterOpDispenserWrapper(DriverAdapter<CycleOp<?>,Space> adapter, ParsedOp pop,
OpDispenser<? extends CycleOp<?>> realDispenser) {
super(adapter, pop);
this.realDispenser = realDispenser;
}

View File

@ -1,32 +0,0 @@
/*
* Copyright (c) 2022-2024 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.
*/
package io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
public class EmitterRunnableOp implements RunnableOp {
private final RunnableOp runnableOp;
public EmitterRunnableOp(RunnableOp runnableOp) {
this.runnableOp = runnableOp;
}
@Override
public void run() {
runnableOp.run();
}
}

View File

@ -1,50 +0,0 @@
/*
* Copyright (c) 2022-2024 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.
*/
package io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers;
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
public class EmitterRunnableOpDispenserWrapper<O,S> extends BaseOpDispenser<RunnableOp, Space> {
private final OpDispenser<RunnableOp> realDispenser;
public EmitterRunnableOpDispenserWrapper(
DriverAdapter<? extends RunnableOp, ? extends Space> adapter,
ParsedOp pop,
OpDispenser<RunnableOp> realDispenser
) {
super(adapter, pop);
this.realDispenser = realDispenser;
logger.warn(
"initialized {} for to emit the result type to stdout. ",
pop.getName()
);
}
@Override
public EmitterRunnableOp getOp(long cycle) {
RunnableOp cycleOp = realDispenser.getOp(cycle);
return new EmitterRunnableOp(cycleOp);
}
}

View File

@ -17,14 +17,11 @@
package io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.OpGenerator;
import io.nosqlbench.adapters.api.evalctx.CycleFunction;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.function.Predicate;
public class PollingOp<T> implements CycleOp<T>, OpGenerator {
private final static Logger logger = LogManager.getLogger(PollingOp.class);
@ -52,7 +49,7 @@ public class PollingOp<T> implements CycleOp<T>, OpGenerator {
}
@Override
public synchronized Op getNextOp() {
public synchronized CycleOp<T> getNextOp() {
return nextOp;
}

View File

@ -17,7 +17,6 @@
package io.nosqlbench.engine.api.activityapi.planning;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import java.util.function.LongFunction;
@ -29,7 +28,7 @@ import java.util.function.LongFunction;
*/
public interface OpSource<T> extends LongFunction<T> {
static <O extends Op> OpSource<O> of(OpSequence<OpDispenser<? extends O>> seq) {
static <O extends LongFunction<?>> OpSource<O> of(OpSequence<OpDispenser<? extends O>> seq) {
return (long l) -> seq.apply(l).getOp(l);
}

View File

@ -22,14 +22,9 @@ import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers.DryCycleOpDispenserWrapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers.DryRunnableOpDispenserWrapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers.EmitterCycleOpDispenserWrapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers.EmitterRunnableOpDispenserWrapper;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.nb.api.errors.OpConfigError;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -37,7 +32,7 @@ public class OpWrappers {
public final static Logger logger = LogManager.getLogger(OpWrappers.class);
public static <OP extends Op, SPACE extends Space> OpDispenser<OP> wrapOptionally(
public static <OP extends CycleOp<?>, SPACE extends Space> OpDispenser<OP> wrapOptionally(
DriverAdapter<OP, SPACE> adapter,
OpDispenser<OP> dispenser,
ParsedOp pop,
@ -46,27 +41,8 @@ public class OpWrappers {
Dryrun dryrun = Dryrun.valueOf(dryrunSpec);
return switch (dryrun) {
case none -> dispenser;
case op -> {
Op exampleOp = dispenser.getOp(0L);
yield switch (exampleOp) {
case RunnableOp runnableOp -> new DryRunnableOpDispenserWrapper(adapter, pop, dispenser);
case CycleOp<?> cycleOp -> new DryCycleOpDispenserWrapper(adapter, pop, dispenser);
default -> throw new OpConfigError(
"Unable to wrap op named '"
+ pop.getDefinedNames() + "' for dry run, since"
+ "only RunnableOp and CycleOp<Result> types are supported");
};
}
case emit -> {
Op exampleOp = dispenser.getOp(0L);
yield switch (exampleOp) {
case RunnableOp runnableOp -> new EmitterRunnableOpDispenserWrapper(adapter, pop, dispenser);
case CycleOp<?> cycleOp -> new EmitterCycleOpDispenserWrapper(adapter, pop, dispenser);
default ->
throw new OpConfigError("Unable to make op named '" + pop.getName() + "' emit a value, " +
"since only RunnableOp and CycleOp<Result> types are supported");
};
}
case op -> new DryCycleOpDispenserWrapper(adapter, pop, dispenser);
case emit -> new EmitterCycleOpDispenserWrapper(adapter, pop, dispenser);
};
}
}

View File

@ -26,11 +26,6 @@ import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.activityimpl.uniform.decorators.SyntheticOpTemplateProvider;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers.DryRunnableOpDispenserWrapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers.EmitterCycleOpDispenserWrapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers.EmitterRunnableOpDispenserWrapper;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.engine.api.activityapi.core.*;
import io.nosqlbench.engine.api.activityapi.core.progress.ActivityMetricProgressMeter;
@ -396,10 +391,10 @@ public class SimpleActivity extends NBStatusComponent implements Activity, Invok
}
protected <O extends Op> OpSequence<OpDispenser<? extends O>> createOpSourceFromParsedOps(
protected <O extends LongFunction> OpSequence<OpDispenser<? extends CycleOp<?>>> createOpSourceFromParsedOps(
// Map<String, DriverAdapter<?,?>> adapterCache,
// Map<String, OpMapper<? extends Op>> mapperCache,
List<DriverAdapter<Op, Space>> adapters,
List<DriverAdapter<CycleOp<?>, Space>> adapters,
List<ParsedOp> pops
) {
try {
@ -415,7 +410,7 @@ public class SimpleActivity extends NBStatusComponent implements Activity, Invok
.getOptionalString("seq")
.map(SequencerType::valueOf)
.orElse(SequencerType.bucket);
SequencePlanner<OpDispenser<? extends O>> planner = new SequencePlanner<>(sequencerType);
SequencePlanner<OpDispenser<? extends CycleOp<?>>> planner = new SequencePlanner<>(sequencerType);
for (int i = 0; i < pops.size(); i++) {
long ratio = ratios.get(i);
@ -427,17 +422,17 @@ public class SimpleActivity extends NBStatusComponent implements Activity, Invok
continue;
}
DriverAdapter<Op, Space> adapter = adapters.get(i);
OpMapper<Op, Space> opMapper = adapter.getOpMapper();
DriverAdapter<CycleOp<?>, Space> adapter = adapters.get(i);
OpMapper<CycleOp<?>, Space> opMapper = adapter.getOpMapper();
LongFunction<Space> spaceFunc = adapter.getSpaceFunc(pop);
OpDispenser<Op> dispenser = opMapper.apply(pop, spaceFunc);
OpDispenser<CycleOp<?>> dispenser = opMapper.apply(pop, spaceFunc);
String dryrunSpec = pop.takeStaticConfigOr("dryrun", "none");
dispenser = OpWrappers.wrapOptionally(adapter, dispenser, pop, dryrunSpec);
// if (strict) {
// optemplate.assertConsumed();
// }
planner.addOp((OpDispenser<? extends O>) dispenser, ratio);
planner.addOp((OpDispenser<? extends CycleOp<?>>) dispenser, ratio);
} catch (Exception e) {
throw new OpConfigError("Error while mapping op from template named '" + pop.getName() + "': " + e.getMessage(), e);
}

View File

@ -25,7 +25,7 @@ import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.activityimpl.uniform.decorators.SyntheticOpTemplateProvider;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.nb.api.engine.metrics.instruments.MetricCategory;
import io.nosqlbench.nb.api.lifecycle.Shutdownable;
@ -60,10 +60,10 @@ import java.util.concurrent.ConcurrentHashMap;
* @param <S>
* The context type for the activity, AKA the 'space' for a named driver instance and its associated object graph
*/
public class StandardActivity<R extends Op, S> extends SimpleActivity implements SyntheticOpTemplateProvider, ActivityDefObserver {
public class StandardActivity<R extends java.util.function.LongFunction, S> extends SimpleActivity implements SyntheticOpTemplateProvider, ActivityDefObserver {
private static final Logger logger = LogManager.getLogger("ACTIVITY");
private final OpSequence<OpDispenser<? extends Op>> sequence;
private final ConcurrentHashMap<String, DriverAdapter<Op,Space>> adapters = new ConcurrentHashMap<>();
private final OpSequence<OpDispenser<? extends CycleOp<?>>> sequence;
private final ConcurrentHashMap<String, DriverAdapter<CycleOp<?>,Space>> adapters = new ConcurrentHashMap<>();
public StandardActivity(NBComponent parent, ActivityDef activityDef) {
super(parent, activityDef);
@ -93,11 +93,11 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity implements
List<ParsedOp> pops = new ArrayList<>();
List<DriverAdapter<Op, Space>> adapterlist = new ArrayList<>();
List<DriverAdapter<CycleOp<?>, Space>> adapterlist = new ArrayList<>();
NBConfigModel supersetConfig = ConfigModel.of(StandardActivity.class).add(yamlmodel);
Optional<String> defaultDriverOption = defaultDriverName;
ConcurrentHashMap<String, OpMapper<? extends Op, ? extends Space>> mappers = new ConcurrentHashMap<>();
ConcurrentHashMap<String, OpMapper<? extends CycleOp<?>, ? extends Space>> mappers = new ConcurrentHashMap<>();
for (OpTemplate ot : opTemplates) {
// ParsedOp incompleteOpDef = new ParsedOp(ot, NBConfiguration.empty(), List.of(), this);
String driverName = ot.getOptionalStringParam("driver", String.class)
@ -113,7 +113,7 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity implements
// HERE
if (!adapters.containsKey(driverName)) {
DriverAdapter<Op,Space> adapter = Optional.of(driverName)
DriverAdapter<CycleOp<?>,Space> adapter = Optional.of(driverName)
.flatMap(
name -> ServiceSelector.of(
name,
@ -145,7 +145,7 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity implements
supersetConfig.assertValidConfig(activityDef.getParams().getStringStringMap());
DriverAdapter<Op, Space> adapter = adapters.get(driverName);
DriverAdapter<CycleOp<?>, Space> adapter = adapters.get(driverName);
adapterlist.add(adapter);
ParsedOp pop = new ParsedOp(ot, adapter.getConfiguration(), List.of(adapter.getPreprocessor()), this);
Optional<String> discard = pop.takeOptionalStaticValue("driver", String.class);
@ -195,7 +195,7 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity implements
}
public OpSequence<OpDispenser<? extends Op>> getOpSequence() {
public OpSequence<OpDispenser<? extends CycleOp<?>>> getOpSequence() {
return sequence;
}
@ -262,7 +262,7 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity implements
*/
@Override
public void shutdownActivity() {
for (Map.Entry<String, DriverAdapter<Op,Space>> entry : adapters.entrySet()) {
for (Map.Entry<String, DriverAdapter<CycleOp<?>,Space>> entry : adapters.entrySet()) {
String adapterName = entry.getKey();
DriverAdapter<?, ?> adapter = entry.getValue();
for (Space space : adapter.getSpaceCache()) {

View File

@ -46,7 +46,7 @@ import java.util.concurrent.TimeUnit;
* @param <R>
* The type of operation
*/
public class StandardAction<A extends StandardActivity<R, ?>, R extends Op> implements SyncAction, ActivityDefObserver {
public class StandardAction<A extends StandardActivity<R, ?>, R extends java.util.function.LongFunction> implements SyncAction, ActivityDefObserver {
private final static Logger logger = LogManager.getLogger("ACTION");
private final Timer executeTimer;
private final Histogram triesHistogram;
@ -54,7 +54,7 @@ public class StandardAction<A extends StandardActivity<R, ?>, R extends Op> impl
private final Timer resultTimer;
private final Timer bindTimer;
private final NBErrorHandler errorHandler;
private final OpSequence<OpDispenser<? extends Op>> opsequence;
private final OpSequence<OpDispenser<? extends CycleOp<?>>> opsequence;
private final int maxTries;
private final Timer verifierTimer;
@ -73,8 +73,8 @@ public class StandardAction<A extends StandardActivity<R, ?>, R extends Op> impl
@Override
public int runCycle(long cycle) {
OpDispenser<? extends Op> dispenser=null;
Op op = null;
OpDispenser<? extends CycleOp<?>> dispenser=null;
CycleOp op = null;
try (Timer.Context ct = bindTimer.time()) {
dispenser = opsequence.apply(cycle);
@ -96,16 +96,7 @@ public class StandardAction<A extends StandardActivity<R, ?>, R extends Op> impl
dispenser.onStart(cycle);
try (Timer.Context ct = executeTimer.time()) {
if (op instanceof RunnableOp runnableOp) {
runnableOp.run();
} else if (op instanceof CycleOp<?> cycleOp) {
result = cycleOp.apply(cycle);
} else if (op instanceof ChainingOp chainingOp) {
result = chainingOp.apply(result);
} else {
throw new RuntimeException("The op implementation did not implement any active logic. Implement " +
"one of [RunnableOp, CycleOp, or ChainingOp]");
}
result = op.apply(cycle);
// TODO: break out validation timer from execute
try (Timer.Context ignored = verifierTimer.time()) {
CycleFunction<Boolean> verifier = dispenser.getVerifier();