mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-12-22 15:13:41 -06:00
align adapter-gcp-spanner to API changes
This commit is contained in:
parent
3bcda60485
commit
a7e5580203
@ -50,6 +50,7 @@
|
||||
<dependency>
|
||||
<groupId>com.google.cloud</groupId>
|
||||
<artifactId>google-cloud-spanner</artifactId>
|
||||
<version>6.76.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -27,23 +27,24 @@ import io.nosqlbench.nb.api.config.standard.NBConfiguration;
|
||||
import io.nosqlbench.nb.api.labels.NBLabels;
|
||||
|
||||
import java.util.function.Function;
|
||||
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<?>> getOpMapper() {
|
||||
public OpMapper<GCPSpannerBaseOp,GCPSpannerSpace> getOpMapper() {
|
||||
return new GCPSpannerOpMapper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function<String, ? extends GCPSpannerSpace> getSpaceInitializer(NBConfiguration cfg) {
|
||||
public LongFunction<GCPSpannerSpace> getSpaceInitializer(NBConfiguration cfg) {
|
||||
return (s) -> new GCPSpannerSpace(s, cfg);
|
||||
}
|
||||
|
||||
|
@ -21,12 +21,16 @@ import io.nosqlbench.adapter.gcpspanner.ops.GCPSpannerBaseOp;
|
||||
import io.nosqlbench.adapter.gcpspanner.types.GCPSpannerOpType;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
|
||||
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;
|
||||
|
||||
public class GCPSpannerOpMapper implements OpMapper<GCPSpannerBaseOp<?>> {
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class GCPSpannerOpMapper implements OpMapper<GCPSpannerBaseOp, GCPSpannerSpace> {
|
||||
private static final Logger logger = LogManager.getLogger(GCPSpannerOpMapper.class);
|
||||
private final GCPSpannerDriverAdapter adapter;
|
||||
|
||||
@ -34,7 +38,8 @@ public class GCPSpannerOpMapper implements OpMapper<GCPSpannerBaseOp<?>> {
|
||||
* Create a new {@code GCPSpannerOpMapper} implementing the {@link OpMapper}.
|
||||
* interface.
|
||||
*
|
||||
* @param adapter The associated {@link GCPSpannerDriverAdapter}
|
||||
* @param adapter
|
||||
* The associated {@link GCPSpannerDriverAdapter}
|
||||
*/
|
||||
public GCPSpannerOpMapper(GCPSpannerDriverAdapter adapter) {
|
||||
this.adapter = adapter;
|
||||
@ -44,12 +49,14 @@ public class GCPSpannerOpMapper implements OpMapper<GCPSpannerBaseOp<?>> {
|
||||
* Given an instance of a {@link ParsedOp} returns the appropriate
|
||||
* {@link GCPSpannerBaseOpDispenser} subclass.
|
||||
*
|
||||
* @param op The {@link ParsedOp} to be evaluated
|
||||
* @param op
|
||||
* The {@link ParsedOp} to be evaluated
|
||||
* @param spaceInitF
|
||||
* @return The correct {@link GCPSpannerBaseOpDispenser} subclass based on
|
||||
* the op type
|
||||
* the op type
|
||||
*/
|
||||
@Override
|
||||
public OpDispenser<? extends GCPSpannerBaseOp<?>> apply(ParsedOp op) {
|
||||
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() + "'");
|
||||
@ -61,10 +68,8 @@ public class GCPSpannerOpMapper implements OpMapper<GCPSpannerBaseOp<?>> {
|
||||
new GCPSpannerCreateDatabaseDdlOpDispenser(adapter, op, typeAndTarget.targetFunction);
|
||||
case update_database_ddl ->
|
||||
new GCPSpannerUpdateDatabaseDdlOpDispenser(adapter, op, typeAndTarget.targetFunction);
|
||||
case insert ->
|
||||
new GCPSpannerInsertOpDispenser(adapter, op, typeAndTarget.targetFunction);
|
||||
case execute_dml ->
|
||||
new GCPSpannerExecuteDmlOpDispenser(adapter, op, typeAndTarget.targetFunction);
|
||||
case insert -> new GCPSpannerInsertOpDispenser(adapter, op, typeAndTarget.targetFunction);
|
||||
case execute_dml -> new GCPSpannerExecuteDmlOpDispenser(adapter, op, typeAndTarget.targetFunction);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
package io.nosqlbench.adapter.gcpspanner;
|
||||
|
||||
import com.google.cloud.spanner.*;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.BaseSpace;
|
||||
import io.nosqlbench.nb.api.config.standard.ConfigModel;
|
||||
import io.nosqlbench.nb.api.config.standard.NBConfigModel;
|
||||
import io.nosqlbench.nb.api.config.standard.NBConfiguration;
|
||||
@ -34,9 +35,8 @@ import org.apache.logging.log4j.Logger;
|
||||
* @see <a href="https://cloud.google.com/spanner/docs/reference/rpc">spanner rpc api calls</a>
|
||||
* @see <a href="https://cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language#vector_index_statements">SQL functionality related to vector indices</a>
|
||||
*/
|
||||
public class GCPSpannerSpace implements AutoCloseable {
|
||||
public class GCPSpannerSpace extends BaseSpace {
|
||||
private final static Logger logger = LogManager.getLogger(GCPSpannerSpace.class);
|
||||
private final String name;
|
||||
private final NBConfiguration cfg;
|
||||
protected Spanner spanner;
|
||||
protected DatabaseAdminClient dbAdminClient;
|
||||
@ -47,11 +47,11 @@ public class GCPSpannerSpace implements AutoCloseable {
|
||||
* contextual information needed to interact with the <b>Google Spanner</b>
|
||||
* database instance.
|
||||
*
|
||||
* @param name The name of this space
|
||||
* @param idx The name of this space
|
||||
* @param cfg The configuration ({@link NBConfiguration}) for this nb run
|
||||
*/
|
||||
public GCPSpannerSpace(String name, NBConfiguration cfg) {
|
||||
this.name = name;
|
||||
public GCPSpannerSpace(long idx, NBConfiguration cfg) {
|
||||
super(idx);
|
||||
this.cfg = cfg;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package io.nosqlbench.adapter.gcpspanner.opdispensers;
|
||||
|
||||
import io.nosqlbench.adapter.gcpspanner.GCPSpannerDriverAdapter;
|
||||
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
|
||||
import io.nosqlbench.adapter.gcpspanner.ops.GCPSpannerBaseOp;
|
||||
import io.nosqlbench.adapter.gcpspanner.GCPSpannerSpace;
|
||||
@ -30,7 +31,8 @@ import java.util.function.LongFunction;
|
||||
* This class extends the BaseOpDispenser and provides common functionality
|
||||
* for creating GCP Spanner operations.
|
||||
*/
|
||||
public abstract class GCPSpannerBaseOpDispenser extends BaseOpDispenser<GCPSpannerBaseOp<?>, GCPSpannerSpace> {
|
||||
public abstract class GCPSpannerBaseOpDispenser<OP extends GCPSpannerBaseOp,RESULT>
|
||||
extends BaseOpDispenser<GCPSpannerBaseOp, GCPSpannerSpace> {
|
||||
/**
|
||||
* A function that provides the target string based on a long input.
|
||||
*/
|
||||
@ -48,7 +50,7 @@ public abstract class GCPSpannerBaseOpDispenser extends BaseOpDispenser<GCPSpann
|
||||
* @param op the parsed operation
|
||||
* @param targetFunction a function that provides the target string
|
||||
*/
|
||||
protected GCPSpannerBaseOpDispenser(DriverAdapter<? extends GCPSpannerBaseOp<?>, GCPSpannerSpace> adapter, ParsedOp op,
|
||||
protected GCPSpannerBaseOpDispenser(GCPSpannerDriverAdapter adapter, ParsedOp op,
|
||||
LongFunction<String> targetFunction) {
|
||||
super(adapter, op);
|
||||
this.targetFunction = targetFunction;
|
||||
|
@ -17,6 +17,7 @@
|
||||
package io.nosqlbench.adapter.gcpspanner.opdispensers;
|
||||
|
||||
|
||||
import com.google.cloud.spanner.Database;
|
||||
import io.nosqlbench.adapter.gcpspanner.GCPSpannerDriverAdapter;
|
||||
import io.nosqlbench.adapter.gcpspanner.ops.GCPSpannerBaseOp;
|
||||
import io.nosqlbench.adapter.gcpspanner.ops.GCPSpannerCreateDatabaseDdlOp;
|
||||
@ -30,19 +31,27 @@ import java.util.function.LongFunction;
|
||||
/**
|
||||
* Dispenser class for creating databases of {@link GCPSpannerCreateDatabaseDdlOp}.
|
||||
*
|
||||
* @see <a href="https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#createdatabaserequest">
|
||||
* CreateDatabaseRequest</a> which can be a stretch goal to combine all of DB, Table(s), and Indexes into one-single call.
|
||||
* @see <a
|
||||
* href="https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#createdatabaserequest">
|
||||
* CreateDatabaseRequest</a> which can be a stretch goal to combine all of DB, Table(s), and Indexes into one-single
|
||||
* call.
|
||||
*/
|
||||
public class GCPSpannerCreateDatabaseDdlOpDispenser extends GCPSpannerBaseOpDispenser {
|
||||
public class GCPSpannerCreateDatabaseDdlOpDispenser
|
||||
extends GCPSpannerBaseOpDispenser<GCPSpannerCreateDatabaseDdlOp, Database>
|
||||
{
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(GCPSpannerCreateDatabaseDdlOpDispenser.class);
|
||||
private final LongFunction<GCPSpannerCreateDatabaseDdlOp> opFunction;
|
||||
|
||||
/**
|
||||
* Constructor for {@link GCPSpannerCreateDatabaseDdlOpDispenser}.
|
||||
*
|
||||
* @param adapter the {@link GCPSpannerDriverAdapter} instance
|
||||
* @param op the {@link ParsedOp} instance
|
||||
* @param targetFunction a {@link LongFunction} that provides the target string
|
||||
* @param adapter
|
||||
* the {@link GCPSpannerDriverAdapter} instance
|
||||
* @param op
|
||||
* the {@link ParsedOp} instance
|
||||
* @param targetFunction
|
||||
* a {@link LongFunction} that provides the target string
|
||||
*/
|
||||
public GCPSpannerCreateDatabaseDdlOpDispenser(GCPSpannerDriverAdapter adapter, ParsedOp op, LongFunction<String> targetFunction) {
|
||||
super(adapter, op, targetFunction);
|
||||
@ -52,7 +61,8 @@ public class GCPSpannerCreateDatabaseDdlOpDispenser extends GCPSpannerBaseOpDisp
|
||||
/**
|
||||
* Creates a {@link LongFunction} that generates {@link GCPSpannerUpdateDatabaseDdlOp} instances.
|
||||
*
|
||||
* @param op the {@link ParsedOp} instance
|
||||
* @param op
|
||||
* the {@link ParsedOp} instance
|
||||
* @return a {@link LongFunction} that generates {@link GCPSpannerUpdateDatabaseDdlOp} instances
|
||||
*/
|
||||
private LongFunction<GCPSpannerCreateDatabaseDdlOp> createOpFunction(ParsedOp op) {
|
||||
@ -68,11 +78,12 @@ public class GCPSpannerCreateDatabaseDdlOpDispenser extends GCPSpannerBaseOpDisp
|
||||
/**
|
||||
* Retrieves an operation instance based on the provided value.
|
||||
*
|
||||
* @param value the long value used to generate the operation
|
||||
* @param value
|
||||
* the long value used to generate the operation
|
||||
* @return a {@link GCPSpannerBaseOp} instance
|
||||
*/
|
||||
@Override
|
||||
public GCPSpannerBaseOp<?> getOp(long value) {
|
||||
public GCPSpannerCreateDatabaseDdlOp getOp(long value) {
|
||||
return opFunction.apply(value);
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import java.util.function.LongFunction;
|
||||
* @see <a href="https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#dropdatabaserequest">
|
||||
* DropDatabaseRequest</a> which can be a stretch goal to combine all of DB, Table(s), and Indexes into one-single call.
|
||||
*/
|
||||
public class GCPSpannerDropDatabaseDdlOpDispenser extends GCPSpannerBaseOpDispenser {
|
||||
public class GCPSpannerDropDatabaseDdlOpDispenser extends GCPSpannerBaseOpDispenser<GCPSpannerDropDatabaseDdlOp,Void> {
|
||||
private static final Logger logger = LogManager.getLogger(GCPSpannerDropDatabaseDdlOpDispenser.class);
|
||||
private final LongFunction<GCPSpannerDropDatabaseDdlOp> opFunction;
|
||||
|
||||
@ -87,7 +87,7 @@ public class GCPSpannerDropDatabaseDdlOpDispenser extends GCPSpannerBaseOpDispen
|
||||
* @return a {@link GCPSpannerBaseOp} instance
|
||||
*/
|
||||
@Override
|
||||
public GCPSpannerBaseOp<?> getOp(long value) {
|
||||
return opFunction != null ? opFunction.apply(value) : null;
|
||||
public GCPSpannerDropDatabaseDdlOp getOp(long value) {
|
||||
return opFunction.apply(value);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package io.nosqlbench.adapter.gcpspanner.opdispensers;
|
||||
|
||||
import com.google.cloud.spanner.ResultSet;
|
||||
import com.google.cloud.spanner.Statement;
|
||||
import io.nosqlbench.adapter.gcpspanner.GCPSpannerDriverAdapter;
|
||||
import io.nosqlbench.adapter.gcpspanner.ops.GCPSpannerBaseOp;
|
||||
@ -32,7 +33,7 @@ import java.util.function.LongFunction;
|
||||
* This class extends the GCPSpannerBaseOpDispenser and provides functionality
|
||||
* to create and configure GCPSpannerExecuteDmlOp instances.
|
||||
*/
|
||||
public class GCPSpannerExecuteDmlOpDispenser extends GCPSpannerBaseOpDispenser {
|
||||
public class GCPSpannerExecuteDmlOpDispenser extends GCPSpannerBaseOpDispenser<GCPSpannerExecuteDmlOp, ResultSet> {
|
||||
private static final Logger logger = LogManager.getLogger(GCPSpannerExecuteDmlOpDispenser.class);
|
||||
private final LongFunction<GCPSpannerExecuteDmlOp> opFunction;
|
||||
|
||||
@ -80,7 +81,7 @@ public class GCPSpannerExecuteDmlOpDispenser extends GCPSpannerBaseOpDispenser {
|
||||
* @return the GCP Spanner operation
|
||||
*/
|
||||
@Override
|
||||
public GCPSpannerBaseOp<?> getOp(long value) {
|
||||
public GCPSpannerExecuteDmlOp getOp(long value) {
|
||||
return opFunction.apply(value);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package io.nosqlbench.adapter.gcpspanner.opdispensers;
|
||||
|
||||
import com.google.cloud.Timestamp;
|
||||
import com.google.cloud.spanner.Mutation;
|
||||
import com.google.cloud.spanner.Value;
|
||||
import io.nosqlbench.adapter.gcpspanner.GCPSpannerDriverAdapter;
|
||||
@ -35,7 +36,7 @@ import java.util.function.LongFunction;
|
||||
* It extends the GCPSpannerBaseOpDispenser and provides the necessary implementation
|
||||
* to create and configure GCPSpannerInsertVectorOp instances.
|
||||
*/
|
||||
public class GCPSpannerInsertOpDispenser extends GCPSpannerBaseOpDispenser {
|
||||
public class GCPSpannerInsertOpDispenser extends GCPSpannerBaseOpDispenser<GCPSpannerInsertOp, Timestamp> {
|
||||
private static final Logger logger = LogManager.getLogger(GCPSpannerInsertOpDispenser.class);
|
||||
private final LongFunction<Map> queryParamsFunction;
|
||||
|
||||
@ -69,7 +70,7 @@ public class GCPSpannerInsertOpDispenser extends GCPSpannerBaseOpDispenser {
|
||||
* @return a configured GCPSpannerInsertVectorOp instance
|
||||
*/
|
||||
@Override
|
||||
public GCPSpannerBaseOp<?> getOp(long value) {
|
||||
public GCPSpannerInsertOp getOp(long value) {
|
||||
Mutation.WriteBuilder builder = Mutation.newInsertBuilder(targetFunction.apply(value));
|
||||
Map<String, Object> params = queryParamsFunction.apply(value);
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
|
@ -29,7 +29,8 @@ import java.util.function.LongFunction;
|
||||
/**
|
||||
* Dispenser class for creating instances of GCPSpannerUpdateDatabaseDdlOp.
|
||||
*/
|
||||
public class GCPSpannerUpdateDatabaseDdlOpDispenser extends GCPSpannerBaseOpDispenser {
|
||||
public class GCPSpannerUpdateDatabaseDdlOpDispenser
|
||||
extends GCPSpannerBaseOpDispenser<GCPSpannerUpdateDatabaseDdlOp,Void> {
|
||||
private static final Logger logger = LogManager.getLogger(GCPSpannerUpdateDatabaseDdlOpDispenser.class);
|
||||
private final LongFunction<GCPSpannerUpdateDatabaseDdlOp> opFunction;
|
||||
|
||||
@ -52,6 +53,7 @@ public class GCPSpannerUpdateDatabaseDdlOpDispenser extends GCPSpannerBaseOpDisp
|
||||
* @return a LongFunction that generates GCPSpannerUpdateDatabaseDdlOp instances
|
||||
*/
|
||||
private LongFunction<GCPSpannerUpdateDatabaseDdlOp> createOpFunction(ParsedOp op) {
|
||||
|
||||
return (l) -> new GCPSpannerUpdateDatabaseDdlOp(
|
||||
spaceFunction.apply(l).getSpanner(),
|
||||
l,
|
||||
@ -68,7 +70,7 @@ public class GCPSpannerUpdateDatabaseDdlOpDispenser extends GCPSpannerBaseOpDisp
|
||||
* @return a GCPSpannerBaseOp instance
|
||||
*/
|
||||
@Override
|
||||
public GCPSpannerBaseOp<?> getOp(long value) {
|
||||
public GCPSpannerUpdateDatabaseDdlOp getOp(long value) {
|
||||
return opFunction.apply(value);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ 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;
|
||||
|
||||
@ -27,14 +28,14 @@ import java.util.function.LongFunction;
|
||||
* Abstract base class for GCP Spanner operations.
|
||||
* This class implements the CycleOp interface and provides a template for executing operations with a Spanner client.
|
||||
*
|
||||
* @param <T> the type of the request parameter
|
||||
* @param <RESULT> the type of the request parameter
|
||||
*/
|
||||
public abstract class GCPSpannerBaseOp<T> implements CycleOp<Object> {
|
||||
public abstract class GCPSpannerBaseOp<REQUEST, RESULT> implements CycleOp<RESULT> {
|
||||
|
||||
protected final static Logger logger = LogManager.getLogger(GCPSpannerBaseOp.class);
|
||||
|
||||
protected final Spanner spannerClient;
|
||||
protected final T request;
|
||||
protected final REQUEST request;
|
||||
protected final LongFunction<Object> apiCall;
|
||||
|
||||
/**
|
||||
@ -43,7 +44,7 @@ public abstract class GCPSpannerBaseOp<T> implements CycleOp<Object> {
|
||||
* @param spannerClient the Spanner client to use for operations
|
||||
* @param requestParam the request parameter for the operation
|
||||
*/
|
||||
public GCPSpannerBaseOp(Spanner spannerClient, T requestParam) {
|
||||
public GCPSpannerBaseOp(Spanner spannerClient, REQUEST requestParam) {
|
||||
this.spannerClient = spannerClient;
|
||||
this.request = requestParam;
|
||||
this.apiCall = this::applyOp;
|
||||
@ -57,11 +58,11 @@ public abstract class GCPSpannerBaseOp<T> implements CycleOp<Object> {
|
||||
* @return the result of the operation
|
||||
*/
|
||||
@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 rte) {
|
||||
throw new RuntimeException(rte);
|
||||
@ -74,7 +75,7 @@ public abstract class GCPSpannerBaseOp<T> implements CycleOp<Object> {
|
||||
* @param value the cycle value
|
||||
* @return the result of the operation
|
||||
*/
|
||||
public abstract Object applyOp(long value);
|
||||
public abstract RESULT applyOp(long value);
|
||||
|
||||
/**
|
||||
* Returns a string representation of the GCPSpannerBaseOp.
|
||||
|
@ -28,7 +28,7 @@ import java.util.Collections;
|
||||
* This class represents an operation to create the database DDL (Data Definition Language) in Google Cloud Spanner.
|
||||
* It extends the {@link GCPSpannerBaseOp} class and provides the implementation for applying the DDL update operation.
|
||||
*/
|
||||
public class GCPSpannerCreateDatabaseDdlOp extends GCPSpannerBaseOp<Long> {
|
||||
public class GCPSpannerCreateDatabaseDdlOp extends GCPSpannerBaseOp<Long,Database> {
|
||||
private final String databaseId;
|
||||
private final DatabaseAdminClient dbAdminClient;
|
||||
private final String instanceId;
|
||||
@ -58,7 +58,7 @@ public class GCPSpannerCreateDatabaseDdlOp extends GCPSpannerBaseOp<Long> {
|
||||
* @throws RuntimeException if an error occurs during the operation
|
||||
*/
|
||||
@Override
|
||||
public Object applyOp(long value) {
|
||||
public Database applyOp(long value) {
|
||||
OperationFuture<Database, CreateDatabaseMetadata> operation = dbAdminClient.createDatabase(
|
||||
instanceId, databaseId, Collections.emptyList());
|
||||
try {
|
||||
|
@ -25,7 +25,7 @@ import com.google.cloud.spanner.Spanner;
|
||||
* This class represents an operation to Drop the database DDL (Data Definition Language) in Google Cloud Spanner.
|
||||
* It extends the {@link GCPSpannerBaseOp} class and provides the implementation for applying the DDL update operation.
|
||||
*/
|
||||
public class GCPSpannerDropDatabaseDdlOp extends GCPSpannerBaseOp<Long> {
|
||||
public class GCPSpannerDropDatabaseDdlOp extends GCPSpannerBaseOp<Long,Void> {
|
||||
private final String databaseId;
|
||||
private final DatabaseAdminClient dbAdminClient;
|
||||
private final Database db;
|
||||
@ -55,7 +55,7 @@ public class GCPSpannerDropDatabaseDdlOp extends GCPSpannerBaseOp<Long> {
|
||||
* @throws RuntimeException if an error occurs during the operation
|
||||
*/
|
||||
@Override
|
||||
public Object applyOp(long value) {
|
||||
public Void applyOp(long value) {
|
||||
try {
|
||||
if (null != db && db.exists()) {
|
||||
db.drop();
|
||||
|
@ -23,7 +23,7 @@ import com.google.cloud.spanner.*;
|
||||
* This class represents an operation to execute a DML statement on Google Cloud Spanner.
|
||||
* It extends the GCPSpannerBaseOp class and overrides the applyOp method to execute the DML statement.
|
||||
*/
|
||||
public class GCPSpannerExecuteDmlOp extends GCPSpannerBaseOp<Long> {
|
||||
public class GCPSpannerExecuteDmlOp extends GCPSpannerBaseOp<Long,ResultSet> {
|
||||
private final Statement statement;
|
||||
private final DatabaseClient dbClient;
|
||||
|
||||
@ -49,7 +49,7 @@ public class GCPSpannerExecuteDmlOp extends GCPSpannerBaseOp<Long> {
|
||||
* @return the result of the DML execution
|
||||
*/
|
||||
@Override
|
||||
public Object applyOp(long value) {
|
||||
public ResultSet applyOp(long value) {
|
||||
try (ReadContext context = dbClient.singleUse()) {
|
||||
return context.executeQuery(statement);
|
||||
}
|
||||
|
@ -17,9 +17,11 @@
|
||||
|
||||
package io.nosqlbench.adapter.gcpspanner.ops;
|
||||
|
||||
import com.google.cloud.Timestamp;
|
||||
import com.google.cloud.spanner.Spanner;
|
||||
import com.google.cloud.spanner.DatabaseClient;
|
||||
import com.google.cloud.spanner.Mutation;
|
||||
import com.google.monitoring.v3.TimeSeries;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@ -27,7 +29,7 @@ import java.util.Collections;
|
||||
* This class represents an operation to insert a vector into a Google Cloud Spanner database.
|
||||
* It extends the GCPSpannerBaseOp class and provides the implementation for the applyOp method.
|
||||
*/
|
||||
public class GCPSpannerInsertOp extends GCPSpannerBaseOp<Long> {
|
||||
public class GCPSpannerInsertOp extends GCPSpannerBaseOp<Long, Timestamp> {
|
||||
private final Mutation mutation;
|
||||
private final DatabaseClient dbClient;
|
||||
|
||||
@ -52,7 +54,7 @@ public class GCPSpannerInsertOp extends GCPSpannerBaseOp<Long> {
|
||||
* @return the result of the write operation
|
||||
*/
|
||||
@Override
|
||||
public Object applyOp(long value) {
|
||||
public Timestamp applyOp(long value) {
|
||||
return dbClient.write(Collections.singletonList(mutation));
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata;
|
||||
* This class represents an operation to update the database DDL (Data Definition Language) in Google Cloud Spanner.
|
||||
* It extends the GCPSpannerBaseOp class and provides the implementation for applying the DDL update operation.
|
||||
*/
|
||||
public class GCPSpannerUpdateDatabaseDdlOp extends GCPSpannerBaseOp<Long> {
|
||||
public class GCPSpannerUpdateDatabaseDdlOp extends GCPSpannerBaseOp<Long,Void> {
|
||||
private final String createTableStatement;
|
||||
private final DatabaseAdminClient dbAdminClient;
|
||||
private final Database db;
|
||||
@ -56,7 +56,7 @@ public class GCPSpannerUpdateDatabaseDdlOp extends GCPSpannerBaseOp<Long> {
|
||||
* @throws RuntimeException if an error occurs during the operation
|
||||
*/
|
||||
@Override
|
||||
public Object applyOp(long value) {
|
||||
public Void applyOp(long value) {
|
||||
OperationFuture<Void, UpdateDatabaseDdlMetadata> operation = dbAdminClient.updateDatabaseDdl(
|
||||
db,
|
||||
ImmutableList.of(createTableStatement),
|
||||
|
Loading…
Reference in New Issue
Block a user