mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
op refinements
This commit is contained in:
@@ -61,6 +61,7 @@ public class MilvusOpMapper implements OpMapper<MilvusOp> {
|
|||||||
case create_index -> new MilvusCreateIndexOpDispenser(adapter,op, typeAndTarget.targetFunction);
|
case create_index -> new MilvusCreateIndexOpDispenser(adapter,op, typeAndTarget.targetFunction);
|
||||||
case drop_index -> new MilvusDropIndexOpDispenser(adapter,op,typeAndTarget.targetFunction);
|
case drop_index -> new MilvusDropIndexOpDispenser(adapter,op,typeAndTarget.targetFunction);
|
||||||
case insert -> new MilvusInsertOpDispenser(adapter,op,typeAndTarget.targetFunction);
|
case insert -> new MilvusInsertOpDispenser(adapter,op,typeAndTarget.targetFunction);
|
||||||
|
case delete -> new MilvusDeleteOpDispenser(adapter,op,typeAndTarget.targetFunction);
|
||||||
default -> throw new RuntimeException("Unrecognized op type '" + typeAndTarget.enumId.name() + "' while " +
|
default -> throw new RuntimeException("Unrecognized op type '" + typeAndTarget.enumId.name() + "' while " +
|
||||||
"mapping parsed op " + op);
|
"mapping parsed op " + op);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,10 +24,7 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class MilvusCreateCollectionOp extends MilvusOp {
|
public class MilvusCreateCollectionOp extends MilvusOp<CreateCollectionParam> {
|
||||||
private static final Logger logger = LogManager.getLogger(MilvusCreateCollectionOp.class);
|
|
||||||
private final CreateCollectionParam request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link ParsedOp} encapsulating a call to the Milvus/Zilliz client delete method
|
* Create a new {@link ParsedOp} encapsulating a call to the Milvus/Zilliz client delete method
|
||||||
*
|
*
|
||||||
@@ -35,14 +32,11 @@ public class MilvusCreateCollectionOp extends MilvusOp {
|
|||||||
* @param request The {@link CreateCollectionParam} built for this operation
|
* @param request The {@link CreateCollectionParam} built for this operation
|
||||||
*/
|
*/
|
||||||
public MilvusCreateCollectionOp(MilvusServiceClient client, CreateCollectionParam request) {
|
public MilvusCreateCollectionOp(MilvusServiceClient client, CreateCollectionParam request) {
|
||||||
super(client);
|
super(client, request);
|
||||||
this.request = request;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object applyOp(long value) {
|
public Object applyOp(long value) {
|
||||||
logger.debug("Milvus/Zilliz create collection request");
|
return client.createCollection(request);
|
||||||
R<RpcStatus> response = client.createCollection(request);
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,19 +25,13 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class MilvusCreateIndexOp extends MilvusOp {
|
public class MilvusCreateIndexOp extends MilvusOp<CreateIndexParam> {
|
||||||
private static final Logger logger = LogManager.getLogger(MilvusCreateIndexOp.class);
|
|
||||||
private final CreateIndexParam request;
|
|
||||||
|
|
||||||
public MilvusCreateIndexOp(MilvusServiceClient client, CreateIndexParam request) {
|
public MilvusCreateIndexOp(MilvusServiceClient client, CreateIndexParam request) {
|
||||||
super(client);
|
super(client, request);
|
||||||
this.request = request;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object applyOp(long value) {
|
public Object applyOp(long value) {
|
||||||
logger.debug("Milvus/Zilliz create index request");
|
return client.createIndex(request);
|
||||||
R<RpcStatus> response = client.createIndex(request);
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 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.milvus.ops;
|
||||||
|
|
||||||
|
import io.milvus.client.MilvusServiceClient;
|
||||||
|
import io.milvus.grpc.MutationResult;
|
||||||
|
import io.milvus.param.R;
|
||||||
|
import io.milvus.param.RpcStatus;
|
||||||
|
import io.milvus.param.dml.DeleteParam;
|
||||||
|
import io.milvus.param.index.CreateIndexParam;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
public class MilvusDeleteOp extends MilvusOp<DeleteParam> {
|
||||||
|
|
||||||
|
public MilvusDeleteOp(MilvusServiceClient client, DeleteParam request) {
|
||||||
|
super(client,request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object applyOp(long value) {
|
||||||
|
return client.delete(this.request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,10 +22,7 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class MilvusDropCollectionOp extends MilvusOp {
|
public class MilvusDropCollectionOp extends MilvusOp<DropCollectionParam> {
|
||||||
private static final Logger logger = LogManager.getLogger(MilvusDropCollectionOp.class);
|
|
||||||
private final DropCollectionParam request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link ParsedOp} encapsulating a call to the Milvus/Zilliz client delete method
|
* Create a new {@link ParsedOp} encapsulating a call to the Milvus/Zilliz client delete method
|
||||||
*
|
*
|
||||||
@@ -33,13 +30,11 @@ public class MilvusDropCollectionOp extends MilvusOp {
|
|||||||
* @param request The {@link DropCollectionParam} built for this operation
|
* @param request The {@link DropCollectionParam} built for this operation
|
||||||
*/
|
*/
|
||||||
public MilvusDropCollectionOp(MilvusServiceClient client, DropCollectionParam request) {
|
public MilvusDropCollectionOp(MilvusServiceClient client, DropCollectionParam request) {
|
||||||
super(client);
|
super(client, request);
|
||||||
this.request = request;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object applyOp(long value) {
|
public Object applyOp(long value) {
|
||||||
logger.debug("Milvus/Zilliz drop collection request");
|
|
||||||
return client.dropCollection(request);
|
return client.dropCollection(request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,7 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class MilvusDropIndexOp extends MilvusOp {
|
public class MilvusDropIndexOp extends MilvusOp<DropIndexParam> {
|
||||||
private static final Logger logger = LogManager.getLogger(MilvusDropIndexOp.class);
|
|
||||||
private final DropIndexParam request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link ParsedOp} encapsulating a call to the Milvus/Zilliz client delete method
|
* Create a new {@link ParsedOp} encapsulating a call to the Milvus/Zilliz client delete method
|
||||||
*
|
*
|
||||||
@@ -35,13 +32,11 @@ public class MilvusDropIndexOp extends MilvusOp {
|
|||||||
* @param request The {@link DropCollectionParam} built for this operation
|
* @param request The {@link DropCollectionParam} built for this operation
|
||||||
*/
|
*/
|
||||||
public MilvusDropIndexOp(MilvusServiceClient client, DropIndexParam request) {
|
public MilvusDropIndexOp(MilvusServiceClient client, DropIndexParam request) {
|
||||||
super(client);
|
super(client,request);
|
||||||
this.request = request;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object applyOp(long value) {
|
public Object applyOp(long value) {
|
||||||
logger.debug("Milvus/Zilliz drop collection request");
|
|
||||||
return client.dropIndex(request);
|
return client.dropIndex(request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class MilvusInsertOp extends MilvusOp {
|
public class MilvusInsertOp extends MilvusOp<InsertParam> {
|
||||||
private static final Logger logger = LogManager.getLogger(MilvusInsertOp.class);
|
|
||||||
private final InsertParam request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link ParsedOp} encapsulating a call to the Milvus/Zilliz client delete method
|
* Create a new {@link ParsedOp} encapsulating a call to the Milvus/Zilliz client delete method
|
||||||
@@ -37,14 +35,11 @@ public class MilvusInsertOp extends MilvusOp {
|
|||||||
* @param request The {@link CreateCollectionParam} built for this operation
|
* @param request The {@link CreateCollectionParam} built for this operation
|
||||||
*/
|
*/
|
||||||
public MilvusInsertOp(MilvusServiceClient client, InsertParam request) {
|
public MilvusInsertOp(MilvusServiceClient client, InsertParam request) {
|
||||||
super(client);
|
super(client,request);
|
||||||
this.request = request;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R<MutationResult> applyOp(long value) {
|
public R<MutationResult> applyOp(long value) {
|
||||||
logger.debug("Milvus/Zilliz create collection request");
|
return client.insert(request);
|
||||||
R<MutationResult> response = client.insert(request);
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,16 +18,25 @@ package io.nosqlbench.adapter.milvus.ops;
|
|||||||
|
|
||||||
import io.milvus.client.MilvusServiceClient;
|
import io.milvus.client.MilvusServiceClient;
|
||||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
|
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
public abstract class MilvusOp<T> implements CycleOp<Object> {
|
||||||
|
|
||||||
|
protected final static Logger logger = LogManager.getLogger(MilvusOp.class);
|
||||||
|
|
||||||
public abstract class MilvusOp implements CycleOp<Object> {
|
|
||||||
protected final MilvusServiceClient client;
|
protected final MilvusServiceClient client;
|
||||||
|
protected final T request;
|
||||||
|
|
||||||
public MilvusOp(MilvusServiceClient client) {
|
public MilvusOp(MilvusServiceClient client, T requestParam) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
this.request = requestParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Object apply(long value) {
|
public final Object apply(long value) {
|
||||||
|
logger.trace("applying op: " + this);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Object result = applyOp(value);
|
Object result = applyOp(value);
|
||||||
return result;
|
return result;
|
||||||
@@ -41,4 +50,9 @@ public abstract class MilvusOp implements CycleOp<Object> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public abstract Object applyOp(long value) throws Exception;
|
public abstract Object applyOp(long value) throws Exception;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "MilvusOp(" + this.request.getClass().getSimpleName() + ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ public enum MilvusOpTypes {
|
|||||||
create_index,
|
create_index,
|
||||||
|
|
||||||
drop_index,
|
drop_index,
|
||||||
insert
|
insert,
|
||||||
// update,
|
update,
|
||||||
// upsert,
|
// upsert,
|
||||||
// delete,
|
// delete,
|
||||||
// describeindexstats,
|
// describeindexstats,
|
||||||
|
|||||||
Reference in New Issue
Block a user