mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
implement DeleteTable for dynamodb driver
This commit is contained in:
@@ -16,8 +16,15 @@
|
||||
|
||||
package io.nosqlbench.adapter.dynamodb;
|
||||
|
||||
/**
|
||||
* Op templates which are supported by the NoSQLBench DynamoDB driver are
|
||||
* enumerated below. These command names should mirror those in the official
|
||||
* DynamoDB API exactly. See the official API for more details.
|
||||
* @see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/Welcome.html">DynamoDB API Reference</a>
|
||||
*/
|
||||
public enum DynamoDBCmdType {
|
||||
CreateTable,
|
||||
DeleteTable,
|
||||
PutItem,
|
||||
GetItem,
|
||||
Query
|
||||
|
||||
@@ -17,10 +17,7 @@
|
||||
package io.nosqlbench.adapter.dynamodb;
|
||||
|
||||
import com.amazonaws.services.dynamodbv2.document.DynamoDB;
|
||||
import io.nosqlbench.adapter.dynamodb.opdispensers.DDBCreateTableOpDispenser;
|
||||
import io.nosqlbench.adapter.dynamodb.opdispensers.DDBGetItemOpDispenser;
|
||||
import io.nosqlbench.adapter.dynamodb.opdispensers.DDBPutItemOpDispenser;
|
||||
import io.nosqlbench.adapter.dynamodb.opdispensers.DDBQueryOpDispenser;
|
||||
import io.nosqlbench.adapter.dynamodb.opdispensers.*;
|
||||
import io.nosqlbench.adapter.dynamodb.optypes.DynamoDBOp;
|
||||
import io.nosqlbench.engine.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.engine.api.activityimpl.OpMapper;
|
||||
@@ -56,6 +53,7 @@ public class DynamoDBOpMapper implements OpMapper<DynamoDBOp> {
|
||||
TypeAndTarget<DynamoDBCmdType,String> cmdType = cmd.getTargetEnum(DynamoDBCmdType.class,String.class);
|
||||
return switch (cmdType.enumId) {
|
||||
case CreateTable -> new DDBCreateTableOpDispenser(ddb, cmd, cmdType.targetFunction);
|
||||
case DeleteTable -> new DDBDeleteTableOpDispenser(ddb, cmd, cmdType.targetFunction);
|
||||
case PutItem -> new DDBPutItemOpDispenser(ddb, cmd, cmdType.targetFunction);
|
||||
case GetItem -> new DDBGetItemOpDispenser(ddb, cmd, cmdType.targetFunction);
|
||||
case Query -> new DDBQueryOpDispenser(ddb, cmd, cmdType.targetFunction);
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.adapter.dynamodb.opdispensers;
|
||||
|
||||
import com.amazonaws.services.dynamodbv2.document.DynamoDB;
|
||||
import com.amazonaws.services.dynamodbv2.model.DeleteTableRequest;
|
||||
import io.nosqlbench.adapter.dynamodb.optypes.DDBDeleteTableOp;
|
||||
import io.nosqlbench.adapter.dynamodb.optypes.DynamoDBOp;
|
||||
import io.nosqlbench.engine.api.activityimpl.BaseOpDispenser;
|
||||
import io.nosqlbench.engine.api.templating.ParsedOp;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
/**
|
||||
* <pre>{@code
|
||||
* Request Syntax
|
||||
* {
|
||||
* "TableName": "string"
|
||||
* }
|
||||
* }</pre>
|
||||
*/
|
||||
public class DDBDeleteTableOpDispenser extends BaseOpDispenser<DynamoDBOp> {
|
||||
|
||||
private final DynamoDB ddb;
|
||||
private final LongFunction<String> tableNameFunc;
|
||||
|
||||
public DDBDeleteTableOpDispenser(DynamoDB ddb, ParsedOp cmd, LongFunction<?> targetFunc) {
|
||||
super(cmd);
|
||||
this.ddb = ddb;
|
||||
this.tableNameFunc = l -> targetFunc.apply(l).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DDBDeleteTableOp apply(long cycle) {
|
||||
DeleteTableRequest rq = new DeleteTableRequest();
|
||||
rq.setTableName(tableNameFunc.apply(cycle));
|
||||
return new DDBDeleteTableOp(ddb, rq);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2022 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.adapter.dynamodb.optypes;
|
||||
|
||||
import com.amazonaws.services.dynamodbv2.document.DynamoDB;
|
||||
import com.amazonaws.services.dynamodbv2.model.DeleteTableRequest;
|
||||
import com.amazonaws.services.dynamodbv2.model.DeleteTableResult;
|
||||
|
||||
public class DDBDeleteTableOp extends DynamoDBOp {
|
||||
|
||||
private final DeleteTableRequest rq;
|
||||
|
||||
public DDBDeleteTableOp(DynamoDB ddb, DeleteTableRequest rq) {
|
||||
super(ddb);
|
||||
this.rq = rq;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeleteTableResult apply(long value) {
|
||||
return ddb.getTable(rq.getTableName()).delete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user