diff --git a/nb-adapters/adapter-qdrant/src/main/java/io/nosqlbench/adapter/qdrant/QdrantOpMapper.java b/nb-adapters/adapter-qdrant/src/main/java/io/nosqlbench/adapter/qdrant/QdrantOpMapper.java index 1440dba6b..c7df70fd5 100644 --- a/nb-adapters/adapter-qdrant/src/main/java/io/nosqlbench/adapter/qdrant/QdrantOpMapper.java +++ b/nb-adapters/adapter-qdrant/src/main/java/io/nosqlbench/adapter/qdrant/QdrantOpMapper.java @@ -18,6 +18,7 @@ package io.nosqlbench.adapter.qdrant; import io.nosqlbench.adapter.qdrant.opdispensers.QdrantBaseOpDispenser; import io.nosqlbench.adapter.qdrant.opdispensers.QdrantCreateCollectionOpDispenser; +import io.nosqlbench.adapter.qdrant.opdispensers.QdrantDeleteCollectionOpDispenser; import io.nosqlbench.adapter.qdrant.ops.QdrantBaseOp; import io.nosqlbench.adapter.qdrant.types.QdrantOpType; import io.nosqlbench.adapters.api.activityimpl.OpDispenser; @@ -57,7 +58,7 @@ public class QdrantOpMapper implements OpMapper> { logger.info(() -> "Using '" + typeAndTarget.enumId + "' op type for op template '" + op.getName() + "'"); return switch (typeAndTarget.enumId) { -// case drop_collection -> new QdrantDropCollectionOpDispenser(adapter, op, typeAndTarget.targetFunction); + case delete_collection -> new QdrantDeleteCollectionOpDispenser(adapter, op, typeAndTarget.targetFunction); case create_collection -> new QdrantCreateCollectionOpDispenser(adapter, op, typeAndTarget.targetFunction); // default -> throw new RuntimeException("Unrecognized op type '" + typeAndTarget.enumId.name() + "' while " + // "mapping parsed op " + op); diff --git a/nb-adapters/adapter-qdrant/src/main/java/io/nosqlbench/adapter/qdrant/opdispensers/QdrantDeleteCollectionOpDispenser.java b/nb-adapters/adapter-qdrant/src/main/java/io/nosqlbench/adapter/qdrant/opdispensers/QdrantDeleteCollectionOpDispenser.java new file mode 100644 index 000000000..1a29c1f01 --- /dev/null +++ b/nb-adapters/adapter-qdrant/src/main/java/io/nosqlbench/adapter/qdrant/opdispensers/QdrantDeleteCollectionOpDispenser.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2020-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.adapter.qdrant.opdispensers; + +import io.nosqlbench.adapter.qdrant.QdrantDriverAdapter; +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.DeleteCollection; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.function.LongFunction; + +public class QdrantDeleteCollectionOpDispenser extends QdrantBaseOpDispenser { + private static final Logger logger = LogManager.getLogger(QdrantDeleteCollectionOpDispenser.class); + + /** + * Create a new {@link QdrantDeleteCollectionOpDispenser} subclassed from {@link QdrantBaseOpDispenser}. + * + * @param adapter The associated {@link QdrantDriverAdapter} + * @param op The {@link ParsedOp} encapsulating the activity for this cycle + * @param targetFunction A LongFunction that returns the specified Qdrant object for this Op + * @see Qdrant Delete Collection. + */ + public QdrantDeleteCollectionOpDispenser(QdrantDriverAdapter adapter, + ParsedOp op, + LongFunction targetFunction) { + super(adapter, op, targetFunction); + } + + @Override + public LongFunction getParamFunc( + LongFunction clientF, + ParsedOp op, + LongFunction targetF) { + LongFunction ebF = + l -> DeleteCollection.newBuilder().setCollectionName(targetF.apply(l)); + return l -> ebF.apply(l).build(); + } + + @Override + public LongFunction> createOpFunc( + LongFunction paramF, + LongFunction clientF, + ParsedOp op, + LongFunction targetF) { + return l -> new QdrantDeleteCollectionOp(clientF.apply(l), paramF.apply(l)); + } +} diff --git a/nb-adapters/adapter-qdrant/src/main/java/io/nosqlbench/adapter/qdrant/ops/QdrantDeleteCollectionOp.java b/nb-adapters/adapter-qdrant/src/main/java/io/nosqlbench/adapter/qdrant/ops/QdrantDeleteCollectionOp.java new file mode 100644 index 000000000..9613b4723 --- /dev/null +++ b/nb-adapters/adapter-qdrant/src/main/java/io/nosqlbench/adapter/qdrant/ops/QdrantDeleteCollectionOp.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2020-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.adapter.qdrant.ops; + +import com.google.common.util.concurrent.ListenableFuture; +import io.qdrant.client.QdrantClient; +import io.qdrant.client.grpc.Collections.CollectionOperationResponse; +import io.qdrant.client.grpc.Collections.DeleteCollection; + +public class QdrantDeleteCollectionOp extends QdrantBaseOp { + public QdrantDeleteCollectionOp(QdrantClient client, DeleteCollection request) { + super(client, request); + } + + @Override + public Object applyOp(long value) { + ListenableFuture response = client.deleteCollectionAsync(request.getCollectionName()); + + return response; + } +} diff --git a/nb-adapters/adapter-qdrant/src/main/java/io/nosqlbench/adapter/qdrant/types/QdrantOpType.java b/nb-adapters/adapter-qdrant/src/main/java/io/nosqlbench/adapter/qdrant/types/QdrantOpType.java index f932fdbd3..b083c7246 100644 --- a/nb-adapters/adapter-qdrant/src/main/java/io/nosqlbench/adapter/qdrant/types/QdrantOpType.java +++ b/nb-adapters/adapter-qdrant/src/main/java/io/nosqlbench/adapter/qdrant/types/QdrantOpType.java @@ -18,4 +18,5 @@ package io.nosqlbench.adapter.qdrant.types; public enum QdrantOpType { create_collection, + delete_collection, }