project restructuring

This commit is contained in:
Jonathan Shook
2024-04-11 22:50:13 -05:00
parent 7810178f0c
commit 4358344029
2892 changed files with 1134 additions and 821 deletions

38
nb-adapters/adapter-milvus/.gitignore vendored Normal file
View File

@@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@@ -0,0 +1,64 @@
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>adapter-milvus</artifactId>
<packaging>jar</packaging>
<parent>
<artifactId>mvn-defaults</artifactId>
<groupId>io.nosqlbench</groupId>
<version>${revision}</version>
<relativePath>../../mvn-defaults</relativePath>
</parent>
<name>${project.artifactId}</name>
<description>
An nosqlbench adapter driver module for the Milvus/Zilliz database.
</description>
<dependencies>
<dependency>
<groupId>io.nosqlbench</groupId>
<artifactId>nb-annotations</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.nosqlbench</groupId>
<artifactId>adapters-api</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>3.24.0</version>
</dependency>
<dependency>
<groupId>io.milvus</groupId>
<artifactId>milvus-sdk-java</artifactId>
<version>2.3.4</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,75 @@
/*
* 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;
import io.milvus.grpc.SearchResults;
import io.milvus.param.R;
import io.milvus.response.SearchResultsWrapper;
import org.apache.commons.lang3.StringUtils;
import java.util.Arrays;
import java.util.List;
public class MilvusAdapterUtils {
public static final String MILVUS = "milvus";
public static List<String> splitNames(String input) {
assert StringUtils.isNotBlank(input) && StringUtils.isNotEmpty(input);
return Arrays.stream(input.split("( +| *, *)"))
.filter(StringUtils::isNotBlank)
.toList();
}
public static List<Long> splitLongs(String input) {
assert StringUtils.isNotBlank(input) && StringUtils.isNotEmpty(input);
return Arrays.stream(input.split("( +| *, *)"))
.filter(StringUtils::isNotBlank)
.map(Long::parseLong)
.toList();
}
/**
* Mask the digits in the given string with '*'
*
* @param unmasked The string to mask
* @return The masked string
*/
protected static String maskDigits(String unmasked) {
assert StringUtils.isNotBlank(unmasked) && StringUtils.isNotEmpty(unmasked);
int inputLength = unmasked.length();
StringBuilder masked = new StringBuilder(inputLength);
for (char ch : unmasked.toCharArray()) {
if (Character.isDigit(ch)) {
masked.append("*");
} else {
masked.append(ch);
}
}
return masked.toString();
}
public static int[] intArrayFromMilvusSearchResults(String fieldName, R<SearchResults> result) {
SearchResultsWrapper wrapper = new SearchResultsWrapper(result.getData().getResults());
List<String> fieldData = (List<String>) wrapper.getFieldData(fieldName, 0);
int[] indices = new int[fieldData.size()];
for (int i = 0; i < indices.length; i++) {
indices[i] = Integer.parseInt(fieldData.get(i));
}
return indices;
}
}

View File

@@ -0,0 +1,56 @@
/*
* 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;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
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.nb.annotations.Service;
import io.nosqlbench.nb.api.components.core.NBComponent;
import io.nosqlbench.nb.api.config.standard.NBConfigModel;
import io.nosqlbench.nb.api.config.standard.NBConfiguration;
import io.nosqlbench.nb.api.labels.NBLabels;
import java.util.function.Function;
import static io.nosqlbench.adapter.milvus.MilvusAdapterUtils.MILVUS;
@Service(value = DriverAdapter.class, selector = MILVUS)
public class MilvusDriverAdapter extends BaseDriverAdapter<MilvusBaseOp<?>, MilvusSpace> {
public MilvusDriverAdapter(NBComponent parentComponent, NBLabels labels) {
super(parentComponent, labels);
}
@Override
public OpMapper<MilvusBaseOp<?>> getOpMapper() {
return new MilvusOpMapper(this);
}
@Override
public Function<String, ? extends MilvusSpace> getSpaceInitializer(NBConfiguration cfg) {
return (s) -> new MilvusSpace(s, cfg);
}
@Override
public NBConfigModel getConfigModel() {
return super.getConfigModel().add(MilvusSpace.getConfigModel());
}
}

View File

@@ -0,0 +1,32 @@
/*
* 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;
import io.nosqlbench.adapter.diag.DriverAdapterLoader;
import io.nosqlbench.nb.annotations.Service;
import io.nosqlbench.nb.api.components.core.NBComponent;
import io.nosqlbench.nb.api.labels.NBLabels;
import static io.nosqlbench.adapter.milvus.MilvusAdapterUtils.MILVUS;
@Service(value = DriverAdapterLoader.class, selector = MILVUS)
public class MilvusDriverAdapterLoader implements DriverAdapterLoader {
@Override
public MilvusDriverAdapter load(NBComponent parent, NBLabels childLabels) {
return new MilvusDriverAdapter(parent, childLabels);
}
}

View File

@@ -0,0 +1,132 @@
/*
* 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;
import io.nosqlbench.adapter.milvus.opdispensers.*;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.types.MilvusOpType;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
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 MilvusOpMapper implements OpMapper<MilvusBaseOp<?>> {
private static final Logger logger = LogManager.getLogger(MilvusOpMapper.class);
private final MilvusDriverAdapter adapter;
/**
* Create a new MilvusOpMapper implementing the {@link OpMapper} interface.
*
* @param adapter The associated {@link MilvusDriverAdapter}
*/
public MilvusOpMapper(MilvusDriverAdapter adapter) {
this.adapter = adapter;
}
/**
* Given an instance of a {@link ParsedOp} returns the appropriate {@link MilvusBaseOpDispenser} subclass
*
* @param op The {@link ParsedOp} to be evaluated
* @return The correct {@link MilvusBaseOpDispenser} subclass based on the op type
*/
@Override
public OpDispenser<? extends MilvusBaseOp<?>> apply(ParsedOp op) {
TypeAndTarget<MilvusOpType, String> typeAndTarget = op.getTypeAndTarget(
MilvusOpType.class,
String.class,
"type",
"target"
);
logger.info(() -> "Using '" + typeAndTarget.enumId + "' op type for op template '" + op.getName() + "'");
return switch (typeAndTarget.enumId) {
case drop_collection -> new MilvusDropCollectionOpDispenser(adapter, op, typeAndTarget.targetFunction);
case create_collection -> new MilvusCreateCollectionOpDispenser(adapter, op, typeAndTarget.targetFunction);
case create_index -> new MilvusCreateIndexOpDispenser(adapter, op, typeAndTarget.targetFunction);
case drop_index -> new MilvusDropIndexOpDispenser(adapter, op, typeAndTarget.targetFunction);
// Uses the Collection-specific fields (columnar) insert mode
case insert_rows -> new MilvusInsertRowsOpDispenser(adapter, op, typeAndTarget.targetFunction);
// Uses the High-Level row-by-row JSONObject (tabular) insert mode
case insert -> new MilvusInsertOpDispenser(adapter, op, typeAndTarget.targetFunction);
case delete -> new MilvusDeleteOpDispenser(adapter, op, typeAndTarget.targetFunction);
case search -> new MilvusSearchOpDispenser(adapter, op, typeAndTarget.targetFunction);
case alter_alias -> new MilvusAlterAliasOpDispenser(adapter, op, typeAndTarget.targetFunction);
case alter_collection -> new MilvusAlterCollectionOpDispenser(adapter, op, typeAndTarget.targetFunction);
case flush -> new MilvusFlushOpDispenser(adapter, op, typeAndTarget.targetFunction);
case bulk_insert -> new MilvusBulkInsertOpDispenser(adapter, op, typeAndTarget.targetFunction);
case create_alias -> new MilvusCreateAliasOpDispenser(adapter, op, typeAndTarget.targetFunction);
case get -> new MilvusGetOpDispenser(adapter, op, typeAndTarget.targetFunction);
case create_partition -> new MilvusCreatePartitionOpDispenser(adapter, op, typeAndTarget.targetFunction);
case create_credential -> new MilvusCreateCredentialOpDispenser(adapter, op, typeAndTarget.targetFunction);
case create_database -> new MilvusCreateDatabaseOpDispenser(adapter, op, typeAndTarget.targetFunction);
case query -> new MilvusQueryOpDispenser(adapter, op, typeAndTarget.targetFunction);
case delete_credential -> new MilvusDeleteCredentialOpDispenser(adapter, op, typeAndTarget.targetFunction);
case describe_collection ->
new MilvusDescribeCollectionOpDispenser(adapter, op, typeAndTarget.targetFunction);
case describe_index -> new MilvusDescribeIndexOpDispenser(adapter, op, typeAndTarget.targetFunction);
case drop_alias -> new MilvusDropAliasOpDispenser(adapter, op, typeAndTarget.targetFunction);
case get_metrics -> new MilvusGetMetricsOpDispenser(adapter, op, typeAndTarget.targetFunction);
case drop_database -> new MilvusDropDatabaseOpDispenser(adapter, op, typeAndTarget.targetFunction);
case get_replicas -> new MilvusGetReplicasOpDispenser(adapter, op, typeAndTarget.targetFunction);
case load_balance -> new MilvusLoadBalanceOpDispenser(adapter, op, typeAndTarget.targetFunction);
case has_partition -> new MilvusHasPartitionOpDispenser(adapter, op, typeAndTarget.targetFunction);
case drop_partition -> new MilvusDropPartitionOpDispenser(adapter, op, typeAndTarget.targetFunction);
case get_load_state -> new MilvusGetLoadStateOpDispenser(adapter, op, typeAndTarget.targetFunction);
case list_databases -> new MilvusListDatabasesOpDispenser(adapter, op, typeAndTarget.targetFunction);
case manual_compact -> new MilvusManualCompactOpDispenser(adapter, op, typeAndTarget.targetFunction);
case get_index_state -> new MilvusGetIndexStateOpDispenser(adapter, op, typeAndTarget.targetFunction);
case list_cred_users -> new MilvusListCredUsersOpDispenser(adapter, op, typeAndTarget.targetFunction);
case load_collection -> new MilvusLoadCollectionOpDispenser(adapter, op, typeAndTarget.targetFunction);
case show_partitions -> new MilvusShowPartitionsOpDispenser(adapter, op, typeAndTarget.targetFunction);
case load_partitions -> new MilvusLoadPartitionsOpDispenser(adapter, op, typeAndTarget.targetFunction);
case list_collections -> new MilvusListCollectionsOpDispenser(adapter, op, typeAndTarget.targetFunction);
case show_collections -> new MilvusShowCollectionsOpDispenser(adapter, op, typeAndTarget.targetFunction);
case update_credential -> new MilvusUpdateCredentialOpDispenser(adapter, op, typeAndTarget.targetFunction);
case release_collection -> new MilvusReleaseCollectionOpDispenser(adapter, op,
typeAndTarget.targetFunction);
case get_bulk_insert_state -> new MilvusGetBulkInsertStateOpDispenser(adapter, op,
typeAndTarget.targetFunction);
case release_partitions -> new MilvusReleasePartitionsOpDispenser(adapter, op,
typeAndTarget.targetFunction);
case get_flush_all_state -> new MilvusGetFlushAllStateOpDispenser(adapter, op,
typeAndTarget.targetFunction);
case get_compaction_state -> new MilvusGetCompactionStateOpDispenser(adapter, op,
typeAndTarget.targetFunction);
case get_loading_progress -> new MilvusGetLoadingProgressOpDispenser(adapter, op,
typeAndTarget.targetFunction);
case get_persistent_segment_info -> new MilvusGetPersistentSegmentInfoOpDispenser(adapter, op,
typeAndTarget.targetFunction);
case get_query_segment_info -> new MilvusGetQuerySegmentInfoOpDispenser(adapter, op,
typeAndTarget.targetFunction);
case list_bulk_insert_tasks -> new MilvusListBulkInsertTasksOpDispenser(adapter, op,
typeAndTarget.targetFunction);
case get_index_build_progress -> new MilvusGetIndexBuildProgressOpDispenser(adapter, op,
typeAndTarget.targetFunction);
case get_partition_statistics -> new MilvusGetPartitionStatisticsOpDispenser(adapter, op,
typeAndTarget.targetFunction);
case get_collection_statistics -> new MilvusGetCollectionStatisticsOpDispenser(adapter, op,
typeAndTarget.targetFunction);
case get_compaction_state_with_plans -> new MilvusGetCompactionStateWithPlansOpDispenser(adapter, op,
typeAndTarget.targetFunction);
// default -> throw new RuntimeException("Unrecognized op type '" + typeAndTarget.enumId.name() + "' while " +
// "mapping parsed op " + op);
};
}
}

View File

@@ -0,0 +1,133 @@
/*
* 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;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.ConnectParam;
import io.nosqlbench.nb.api.config.standard.ConfigModel;
import io.nosqlbench.nb.api.config.standard.NBConfigModel;
import io.nosqlbench.nb.api.config.standard.NBConfiguration;
import io.nosqlbench.nb.api.config.standard.Param;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The MilvusSpace class is a context object which stores all stateful contextual information needed to interact
* with the Milvus/Zilliz database instance.
* https://milvus.io/docs/install-java.md
* https://docs.zilliz.com/docs/connect-to-cluster
*/
public class MilvusSpace implements AutoCloseable {
private final static Logger logger = LogManager.getLogger(MilvusSpace.class);
private final String name;
private final NBConfiguration cfg;
protected MilvusServiceClient client;
private final Map<String, ConnectParam> connections = new HashMap<>();
/**
* Create a new MilvusSpace Object which stores all stateful contextual information needed to interact
* with the Milvus/Zilliz database instance.
*
* @param name
* The name of this space
* @param cfg
* The configuration ({@link NBConfiguration}) for this nb run
*/
public MilvusSpace(String name, NBConfiguration cfg) {
this.name = name;
this.cfg = cfg;
}
public synchronized MilvusServiceClient getClient() {
if (client == null) {
client = createClient();
}
return client;
}
private MilvusServiceClient createClient() {
var builder = ConnectParam.newBuilder();
builder = builder.withUri(cfg.get("uri"));
cfg.getOptional("database_name").ifPresent(builder::withDatabaseName);
cfg.getOptional("database").ifPresent(builder::withDatabaseName);
var requiredToken = cfg.getOptional("token_file")
.map(Paths::get)
.map(
tokenFilePath -> {
try {
return Files.readAllLines(tokenFilePath).getFirst();
} catch (IOException e) {
String error = "Error while reading token from file:" + tokenFilePath;
logger.error(error, e);
throw new RuntimeException(e);
}
}
).orElseGet(
() -> cfg.getOptional("token")
.orElseThrow(() -> new RuntimeException("You must provide either a token_file or a token to " +
"configure a Milvus client"))
);
builder = builder.withToken(requiredToken);
ConnectParam connectParams = builder.build();
logger.info(this.name + ": Creating new Milvus/Zilliz Client with (masked) " +
"token [" + MilvusAdapterUtils.maskDigits(builder.getToken()) + "], uri/endpoint [" + builder.getUri() + "]"
);
return new MilvusServiceClient(connectParams);
}
public static NBConfigModel getConfigModel() {
return ConfigModel.of(MilvusSpace.class)
.add(
Param.optional("token_file", String.class, "the file to load the token from")
)
.add(
Param.defaultTo("token", "root:Milvus")
.setDescription("the Milvus/Zilliz token to use to connect to the database")
)
.add(
Param.defaultTo("uri", "127.0.0.1:19530")
.setDescription("the URI endpoint in which the database is running.")
)
.add(
Param.optional(List.of("database_name","database"))
.setDescription("the name of the database to use. Defaults to 'baselines'")
)
.asReadOnly();
}
@Override
public void close() throws Exception {
if (client != null) {
client.close();
}
}
}

View File

@@ -0,0 +1,39 @@
/*
* 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.exceptions;
import io.milvus.grpc.GetLoadStateResponse;
import io.milvus.param.R;
import java.time.Duration;
public class MilvusAwaitStateIncompleteError extends RuntimeException {
private final R<GetLoadStateResponse> loadState;
private final Duration timeout;
private final String timeSummary;
public MilvusAwaitStateIncompleteError(R<GetLoadStateResponse> loadState, Duration timeout, String timeSummary) {
this.loadState = loadState;
this.timeout = timeout;
this.timeSummary = timeSummary;
}
@Override
public String getMessage() {
return super.getMessage() + ": at time " +timeSummary;
}
}

View File

@@ -0,0 +1,43 @@
/*
* 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.exceptions;
import io.milvus.param.index.DescribeIndexParam;
import io.nosqlbench.adapter.milvus.ops.MilvusDescribeIndexOp;
import java.util.List;
public class MilvusIndexingIncompleteError extends RuntimeException {
private final DescribeIndexParam milvusDescribeIndexOp;
private final int tried;
private final List<MilvusDescribeIndexOp.IndexStat> stats;
public MilvusIndexingIncompleteError(DescribeIndexParam milvusDescribeIndexOp, int tried, List<MilvusDescribeIndexOp.IndexStat> stats) {
this.milvusDescribeIndexOp = milvusDescribeIndexOp;
this.tried = tried;
this.stats = stats;
}
@Override
public String getMessage() {
return super.getMessage() + ": "
+ "tries:" + tried + "/" + tried
+ ", index:" + milvusDescribeIndexOp.getIndexName()
+ ", database:" + milvusDescribeIndexOp.getDatabaseName()
+ ", collection:" + milvusDescribeIndexOp.getCollectionName();
}
}

View File

@@ -0,0 +1,72 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.common.clientenum.ConsistencyLevelEnum;
import io.milvus.param.alias.AlterAliasParam;
import io.milvus.param.collection.CreateCollectionParam;
import io.milvus.param.collection.FieldType;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusAlterAliasOp;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusCreateCollectionOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.List;
import java.util.Map;
import java.util.function.LongFunction;
public class MilvusAlterAliasOpDispenser extends MilvusBaseOpDispenser<AlterAliasParam> {
private static final Logger logger = LogManager.getLogger(MilvusAlterAliasOpDispenser.class);
public MilvusAlterAliasOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<AlterAliasParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<AlterAliasParam.Builder> ebF =
l -> AlterAliasParam.newBuilder().withAlias(targetF.apply(l));
// Add enhancement functions here
ebF = op.enhanceFuncOptionally(
ebF,List.of("collection_name","collection"),String.class,AlterAliasParam.Builder::withCollectionName);
final LongFunction<AlterAliasParam.Builder> lastF = ebF;
final LongFunction<AlterAliasParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<AlterAliasParam>> createOpFunc(
LongFunction<AlterAliasParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusAlterAliasOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,62 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.collection.AlterCollectionParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusAlterCollectionOp;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusAlterCollectionOpDispenser extends MilvusBaseOpDispenser<AlterCollectionParam> {
public MilvusAlterCollectionOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<AlterCollectionParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<AlterCollectionParam.Builder> ebF =
l -> AlterCollectionParam.newBuilder().withCollectionName(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, "ttl", Number.class,
(AlterCollectionParam.Builder b, Number n) -> b.withTTL(n.intValue()));
final LongFunction<AlterCollectionParam.Builder> lastF = ebF;
final LongFunction<AlterCollectionParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<AlterCollectionParam>> createOpFunc(
LongFunction<AlterCollectionParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusAlterCollectionOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,64 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.MilvusSpace;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public abstract class MilvusBaseOpDispenser<T> extends BaseOpDispenser<MilvusBaseOp<T>, MilvusSpace> {
protected final LongFunction<MilvusSpace> mzSpaceFunction;
protected final LongFunction<MilvusServiceClient> clientFunction;
private final LongFunction<? extends MilvusBaseOp<T>> opF;
private final LongFunction<T> paramF;
protected MilvusBaseOpDispenser(MilvusDriverAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
super((DriverAdapter)adapter, op);
this.mzSpaceFunction = adapter.getSpaceFunc(op);
this.clientFunction = (long l) -> this.mzSpaceFunction.apply(l).getClient();
this.paramF = getParamFunc(this.clientFunction,op,targetF);
this.opF = createOpFunc(paramF, this.clientFunction, op, targetF);
}
protected MilvusDriverAdapter getDriverAdapter() {
return (MilvusDriverAdapter) adapter;
}
public abstract LongFunction<T> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
);
public abstract LongFunction<MilvusBaseOp<T>> createOpFunc(
LongFunction<T> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
);
@Override
public MilvusBaseOp<T> getOp(long value) {
return opF.apply(value);
}
}

View File

@@ -0,0 +1,71 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.bulkinsert.BulkInsertParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusBulkInsertOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.Map;
import java.util.function.LongFunction;
public class MilvusBulkInsertOpDispenser extends MilvusBaseOpDispenser<BulkInsertParam> {
public MilvusBulkInsertOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<BulkInsertParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<BulkInsertParam.Builder> ebF =
l -> BulkInsertParam.newBuilder().withCollectionName(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, "options", Map.class,
(BulkInsertParam.Builder builder, Map map) -> {
map.forEach((k, v) -> {
builder.withOption(k.toString(), v.toString());
});
return builder;
}
);
ebF = op.enhanceFuncOptionally(ebF, "files", List.class, BulkInsertParam.Builder::withFiles);
ebF = op.enhanceFuncOptionally(ebF, List.of("partition_name", "partition"), String.class,
BulkInsertParam.Builder::withPartitionName);
LongFunction<BulkInsertParam.Builder> finalEbF = ebF;
return l -> finalEbF.apply(l).build();
}
@Override
public LongFunction<MilvusBaseOp<BulkInsertParam>> createOpFunc(
LongFunction<BulkInsertParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusBulkInsertOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,63 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.alias.CreateAliasParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusCreateAliasOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusCreateAliasOpDispenser extends MilvusBaseOpDispenser<CreateAliasParam> {
public MilvusCreateAliasOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<CreateAliasParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<CreateAliasParam.Builder> ebF =
l -> CreateAliasParam.newBuilder().withAlias(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, List.of("collection_name","collection"),String.class,
CreateAliasParam.Builder::withCollectionName);
final LongFunction<CreateAliasParam.Builder> lastF = ebF;
final LongFunction<CreateAliasParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<CreateAliasParam>> createOpFunc(
LongFunction<CreateAliasParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusCreateAliasOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,132 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.common.clientenum.ConsistencyLevelEnum;
import io.milvus.grpc.DataType;
import io.milvus.param.collection.CreateCollectionParam;
import io.milvus.param.collection.FieldType;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusCreateCollectionOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.LongFunction;
public class MilvusCreateCollectionOpDispenser extends MilvusBaseOpDispenser<CreateCollectionParam> {
private static final Logger logger = LogManager.getLogger(MilvusCreateCollectionOpDispenser.class);
/**
* Create a new MilvusCreateCollectionOpDispenser subclassed from {@link MilvusBaseOpDispenser}.
*
* @param adapter The associated {@link MilvusDriverAdapter}
* @param op The {@link ParsedOp} encapsulating the activity for this cycle
* @param targetFunction A LongFunction that returns the specified Milvus Index for this Op
*/
public MilvusCreateCollectionOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<CreateCollectionParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<CreateCollectionParam.Builder> ebF =
l -> CreateCollectionParam.newBuilder().withCollectionName(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, "shards_num", Number.class,
(CreateCollectionParam.Builder b, Number n) -> b.withShardsNum(n.intValue()));
ebF = op.enhanceFuncOptionally(ebF, "partition_num", Number.class,
(CreateCollectionParam.Builder b, Number n) -> b.withPartitionsNum(n.intValue()));
ebF = op.enhanceFuncOptionally(ebF, "description", String.class,
CreateCollectionParam.Builder::withDescription);
ebF = op.enhanceEnumOptionally(ebF, "consistency_level",
ConsistencyLevelEnum.class, CreateCollectionParam.Builder::withConsistencyLevel);
ebF = op.enhanceFuncOptionally(ebF, "database_name", String.class,
CreateCollectionParam.Builder::withDatabaseName);
List<FieldType> fieldTypes = buildFieldTypesStruct(
op.getAsSubOps("field_types", ParsedOp.SubOpNaming.SubKey),
ebF
);
final LongFunction<CreateCollectionParam.Builder> f = ebF;
ebF = l -> f.apply(l).withFieldTypes(fieldTypes);
final LongFunction<CreateCollectionParam.Builder> lastF = ebF;
return l -> lastF.apply(l).build();
}
// https://milvus.io/docs/create_collection.md
@Override
public LongFunction<MilvusBaseOp<CreateCollectionParam>> createOpFunc(
LongFunction<CreateCollectionParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusCreateCollectionOp(clientF.apply(l), paramF.apply(l));
}
/**
* Function to build the {@link FieldType}s for the {@link CreateCollectionParam}.
*
* @param fieldTypesData The static map of config data from the create collection request
* @param ebF
* @return a list of static field types
*/
private List<FieldType> buildFieldTypesStruct(Map<String, ParsedOp> fieldTypesData, LongFunction<CreateCollectionParam.Builder> ebF) {
List<FieldType> fieldTypes = new ArrayList<>();
fieldTypesData.forEach((name, fieldspec) -> {
FieldType.Builder builder = FieldType.newBuilder()
.withName(name);
fieldspec.getOptionalStaticValue("primary_key", Boolean.class)
.ifPresent(builder::withPrimaryKey);
fieldspec.getOptionalStaticValue("auto_id", Boolean.class)
.ifPresent(builder::withAutoID);
fieldspec.getOptionalStaticConfig("max_length", Number.class)
.ifPresent((Number n) -> builder.withMaxLength(n.intValue()));
fieldspec.getOptionalStaticConfig("max_capacity", Number.class)
.ifPresent((Number n) -> builder.withMaxCapacity(n.intValue()));
fieldspec.getOptionalStaticValue(List.of("partition_key", "partition"), Boolean.class)
.ifPresent(builder::withPartitionKey);
fieldspec.getOptionalStaticValue("dimension", Number.class)
.ifPresent((Number n) -> builder.withDimension(n.intValue()));
fieldspec.getOptionalStaticConfig("data_type", String.class)
.map(DataType::valueOf)
.ifPresent(builder::withDataType);
fieldspec.getOptionalStaticConfig("type_params", Map.class)
.ifPresent(builder::withTypeParams);
fieldspec.getOptionalStaticConfig("element_type", String.class)
.map(DataType::valueOf)
.ifPresent(builder::withElementType);
fieldTypes.add(builder.build());
});
return fieldTypes;
}
}

View File

@@ -0,0 +1,61 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.credential.CreateCredentialParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusCreateCredentialOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusCreateCredentialOpDispenser extends MilvusBaseOpDispenser<CreateCredentialParam> {
public MilvusCreateCredentialOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<CreateCredentialParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<CreateCredentialParam.Builder> ebF =
l -> CreateCredentialParam.newBuilder().withUsername(targetF.apply(l));
ebF = op.enhanceFunc(ebF,"password",String.class,CreateCredentialParam.Builder::withPassword);
final LongFunction<CreateCredentialParam.Builder> lastF = ebF;
final LongFunction<CreateCredentialParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<CreateCredentialParam>> createOpFunc(
LongFunction<CreateCredentialParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusCreateCredentialOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,54 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.collection.CreateDatabaseParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusCreateDatabaseOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusCreateDatabaseOpDispenser extends MilvusBaseOpDispenser<CreateDatabaseParam> {
public MilvusCreateDatabaseOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<CreateDatabaseParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l1 -> CreateDatabaseParam.newBuilder().withDatabaseName(targetF.apply(l1)).build();
}
@Override
public LongFunction<MilvusBaseOp<CreateDatabaseParam>> createOpFunc(
LongFunction<CreateDatabaseParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusCreateDatabaseOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,80 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.IndexType;
import io.milvus.param.MetricType;
import io.milvus.param.index.CreateIndexParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusCreateIndexOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusCreateIndexOpDispenser extends MilvusBaseOpDispenser<CreateIndexParam> {
private static final Logger logger = LogManager.getLogger(MilvusCreateIndexOpDispenser.class);
/**
* Create a new MilvusCreateIndexOpDispenser subclassed from {@link MilvusBaseOpDispenser}.
*
* @param adapter The associated {@link MilvusDriverAdapter}
* @param op The {@link ParsedOp} encapsulating the activity for this cycle
* @param targetFunction A LongFunction that returns the specified Milvus Index for this Op
*/
public MilvusCreateIndexOpDispenser(
MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction
) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<CreateIndexParam> getParamFunc(LongFunction<MilvusServiceClient> clientF, ParsedOp op, LongFunction<String> targetF) {
LongFunction<CreateIndexParam.Builder> bF =
l -> CreateIndexParam.newBuilder().withIndexName(targetF.apply(l));
bF = op.enhanceFunc(bF, List.of("collection", "collection_name"), String.class,
CreateIndexParam.Builder::withCollectionName);
bF = op.enhanceFunc(bF, "field_name", String.class, CreateIndexParam.Builder::withFieldName);
bF = op.enhanceEnumOptionally(bF, "index_type", IndexType.class, CreateIndexParam.Builder::withIndexType);
bF = op.enhanceEnumOptionally(bF, "metric_type", MetricType.class, CreateIndexParam.Builder::withMetricType);
bF = op.enhanceFuncOptionally(bF, "extra_param", String.class, CreateIndexParam.Builder::withExtraParam);
bF = op.enhanceFuncOptionally(bF, "sync_mode", Boolean.class, CreateIndexParam.Builder::withSyncMode);
bF = op.enhanceFuncOptionally(bF, "sync_waiting_interval", Number.class,
(CreateIndexParam.Builder b, Number n) -> b.withSyncWaitingInterval(n.longValue()));
bF = op.enhanceFuncOptionally(bF, "sync_waiting_timeout", Number.class,
(CreateIndexParam.Builder b, Number n) -> b.withSyncWaitingTimeout(n.longValue()));
bF = op.enhanceFuncOptionally(bF, List.of("database", "database_name"), String.class,
CreateIndexParam.Builder::withDatabaseName);
LongFunction<CreateIndexParam.Builder> finalBF1 = bF;
return l -> finalBF1.apply(l).build();
}
@Override
public LongFunction<MilvusBaseOp<CreateIndexParam>> createOpFunc(
LongFunction<CreateIndexParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op, LongFunction<String> targetF) {
return l -> new MilvusCreateIndexOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,63 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.partition.CreatePartitionParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusCreatePartitionOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusCreatePartitionOpDispenser extends MilvusBaseOpDispenser<CreatePartitionParam> {
public MilvusCreatePartitionOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<CreatePartitionParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<CreatePartitionParam.Builder> ebF =
l -> CreatePartitionParam.newBuilder().withCollectionName(targetF.apply(l));
// Add enhancement functions here
ebF = op.enhanceFunc(ebF, List.of("collection","collection_name"),String.class,
CreatePartitionParam.Builder::withCollectionName);
final LongFunction<CreatePartitionParam.Builder> lastF = ebF;
final LongFunction<CreatePartitionParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<CreatePartitionParam>> createOpFunc(
LongFunction<CreatePartitionParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusCreatePartitionOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,54 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.credential.DeleteCredentialParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusDeleteCredentialOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusDeleteCredentialOpDispenser extends MilvusBaseOpDispenser<DeleteCredentialParam> {
public MilvusDeleteCredentialOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<DeleteCredentialParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> DeleteCredentialParam.newBuilder().withUsername(targetF.apply(l)).build();
}
@Override
public LongFunction<MilvusBaseOp<DeleteCredentialParam>> createOpFunc(
LongFunction<DeleteCredentialParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusDeleteCredentialOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,56 @@
package io.nosqlbench.adapter.milvus.opdispensers;
/*
* 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.
*/
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.dml.DeleteParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusDeleteParamOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.milvus.param.dml.DeleteParam.Builder;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusDeleteOpDispenser extends MilvusBaseOpDispenser<DeleteParam> {
public MilvusDeleteOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<DeleteParam> getParamFunc(LongFunction<MilvusServiceClient> clientF, ParsedOp op, LongFunction<String> targetF) {
LongFunction<DeleteParam.Builder> f =
l -> DeleteParam.newBuilder().withCollectionName(targetF.apply(l));
f = op.enhanceFuncOptionally(f, List.of("partition_name","partition"), String.class,
DeleteParam.Builder::withPartitionName);
f = op.enhanceFuncOptionally(f, "expression", String.class, DeleteParam.Builder::withExpr);
f = op.enhanceFuncOptionally(f, "expr", String.class, Builder::withExpr);
LongFunction<DeleteParam.Builder> finalF = f;
return l -> finalF.apply(l).build();
}
@Override
public LongFunction<MilvusBaseOp<DeleteParam>> createOpFunc(LongFunction<DeleteParam> paramF, LongFunction<MilvusServiceClient> clientF, ParsedOp op, LongFunction<String> targetF) {
return l -> new MilvusDeleteParamOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,64 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.collection.DescribeCollectionParam;
import io.milvus.param.partition.CreatePartitionParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusDescribeCollectionOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusDescribeCollectionOpDispenser extends MilvusBaseOpDispenser<DescribeCollectionParam> {
public MilvusDescribeCollectionOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<DescribeCollectionParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<DescribeCollectionParam.Builder> ebF =
l -> DescribeCollectionParam.newBuilder().withCollectionName(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, List.of("database","database_name"),String.class,
DescribeCollectionParam.Builder::withDatabaseName);
final LongFunction<DescribeCollectionParam.Builder> lastF = ebF;
final LongFunction<DescribeCollectionParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<DescribeCollectionParam>> createOpFunc(
LongFunction<DescribeCollectionParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusDescribeCollectionOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,81 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.index.DescribeIndexParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusDescribeIndexOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusDescribeIndexOpDispenser extends MilvusBaseOpDispenser<DescribeIndexParam> {
private Duration awaitTimeout = Duration.ZERO;
private Duration awaitInterval = Duration.of(10, ChronoUnit.SECONDS);
public MilvusDescribeIndexOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
op.getOptionalStaticValue("await_timeout", Number.class)
.map(Number::doubleValue)
.ifPresent(v->this.awaitTimeout = Duration.of((long)(v*1000), ChronoUnit.MILLIS));
op.getOptionalStaticValue("await_interval", Number.class)
.map(Number::doubleValue).ifPresent(v->this.awaitInterval =Duration.of((long)(v*1000),ChronoUnit.MILLIS));
}
@Override
public LongFunction<DescribeIndexParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<DescribeIndexParam.Builder> ebF =
l -> DescribeIndexParam.newBuilder().withIndexName(targetF.apply(l));
ebF = op.enhanceFunc(ebF, List.of("collection","collection_name"), String.class,
DescribeIndexParam.Builder::withCollectionName);
ebF = op.enhanceFuncOptionally(ebF, List.of("database_name","database"), String.class,
DescribeIndexParam.Builder::withDatabaseName);
final LongFunction<DescribeIndexParam.Builder> lastF = ebF;
final LongFunction<DescribeIndexParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<DescribeIndexParam>> createOpFunc(
LongFunction<DescribeIndexParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusDescribeIndexOp(
clientF.apply(l),
paramF.apply(l),
awaitTimeout,
awaitInterval
);
}
}

View File

@@ -0,0 +1,58 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.alias.DropAliasParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusDropAliasOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusDropAliasOpDispenser extends MilvusBaseOpDispenser<DropAliasParam> {
public MilvusDropAliasOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<DropAliasParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<DropAliasParam.Builder> ebF =
l -> DropAliasParam.newBuilder().withAlias(targetF.apply(l));
final LongFunction<DropAliasParam.Builder> lastF = ebF;
final LongFunction<DropAliasParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<DropAliasParam>> createOpFunc(
LongFunction<DropAliasParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusDropAliasOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,72 @@
package io.nosqlbench.adapter.milvus.opdispensers;
/*
* 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.
*/
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.collection.DropCollectionParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusDropCollectionOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusDropCollectionOpDispenser extends MilvusBaseOpDispenser<DropCollectionParam> {
private static final Logger logger = LogManager.getLogger(MilvusDropCollectionOpDispenser.class);
/**
* <P>Create a new {@link MilvusDropCollectionOpDispenser} subclassed from {@link MilvusBaseOpDispenser}.</P>
*
* <P>{@see <A HREF="https://milvus.io/docs/drop_collection.md">Drop Collection</A>}</P>
*
* @param adapter The associated {@link MilvusDriverAdapter}
* @param op The {@link ParsedOp} encapsulating the activity for this cycle
* @param targetFunction A LongFunction that returns the specified Milvus Index for this Op
*/
public MilvusDropCollectionOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<DropCollectionParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF) {
LongFunction<DropCollectionParam.Builder> f =
l -> DropCollectionParam.newBuilder().withCollectionName(targetF.apply(l));
f = op.enhanceFuncOptionally(f, List.of("database","database_name"),String.class,
DropCollectionParam.Builder::withDatabaseName);
LongFunction<DropCollectionParam.Builder> finalF = f;
return l -> finalF.apply(l).build();
}
@Override
public LongFunction<MilvusBaseOp<DropCollectionParam>> createOpFunc(LongFunction<DropCollectionParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op, LongFunction<String> targetF) {
return l -> new MilvusDropCollectionOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,54 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.collection.DropDatabaseParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusDropDatabaseOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusDropDatabaseOpDispenser extends MilvusBaseOpDispenser<DropDatabaseParam> {
public MilvusDropDatabaseOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<DropDatabaseParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> DropDatabaseParam.newBuilder().withDatabaseName(targetF.apply(l)).build();
}
@Override
public LongFunction<MilvusBaseOp<DropDatabaseParam>> createOpFunc(
LongFunction<DropDatabaseParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusDropDatabaseOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,67 @@
package io.nosqlbench.adapter.milvus.opdispensers;
/*
* 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.
*/
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.index.DropIndexParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusDropIndexOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusDropIndexOpDispenser extends MilvusBaseOpDispenser<DropIndexParam> {
/**
* <P>Create a new MilvusDeleteOpDispenser subclassed from {@link MilvusBaseOpDispenser}.</P>
* <P>{@see <a href="https://milvus.io/docs/drop_collection.md">Drop Index</a>}</P>
*
*
* @param adapter
* The associated {@link MilvusDriverAdapter}
* @param op
* The {@link ParsedOp} encapsulating the activity for this cycle
* @param targetFunction
* A LongFunction that returns the specified Milvus Index for this Op
*/
public MilvusDropIndexOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<DropIndexParam> getParamFunc(LongFunction<MilvusServiceClient> clientF, ParsedOp op, LongFunction<String> targetF) {
LongFunction<DropIndexParam.Builder> f =
l -> DropIndexParam.newBuilder().withIndexName(targetF.apply(l));
f = op.enhanceFunc(f, List.of("collection_name","collection"),String.class,
DropIndexParam.Builder::withCollectionName);
LongFunction<DropIndexParam.Builder> finalF = f;
return l -> finalF.apply(1).build();
}
@Override
public LongFunction<MilvusBaseOp<DropIndexParam>> createOpFunc(LongFunction<DropIndexParam> paramF, LongFunction<MilvusServiceClient> clientF, ParsedOp op, LongFunction<String> targetF) {
return l -> new MilvusDropIndexOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,63 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.partition.CreatePartitionParam;
import io.milvus.param.partition.DropPartitionParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusDropPartitionOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusDropPartitionOpDispenser extends MilvusBaseOpDispenser<DropPartitionParam> {
public MilvusDropPartitionOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<DropPartitionParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<DropPartitionParam.Builder> ebF =
l -> DropPartitionParam.newBuilder().withPartitionName(targetF.apply(l));
ebF = op.enhanceFunc(ebF, List.of("collection_name","collection"),String.class,
DropPartitionParam.Builder::withCollectionName);
final LongFunction<DropPartitionParam.Builder> lastF = ebF;
final LongFunction<DropPartitionParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<DropPartitionParam>> createOpFunc(
LongFunction<DropPartitionParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusDropPartitionOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,75 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.collection.FlushParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusFlushOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.Arrays;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusFlushOpDispenser extends MilvusBaseOpDispenser<FlushParam> {
public MilvusFlushOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<FlushParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<FlushParam.Builder> ebF =
l -> FlushParam.newBuilder();
LongFunction<List<String>> cnames = l -> {
List<String> collectionNames = Arrays.asList(targetF.apply(l).split("[\\s,]"));
return collectionNames;
};
LongFunction<FlushParam.Builder> finalEbF = ebF;
ebF = l -> finalEbF.apply(l).withCollectionNames(cnames.apply(l));
ebF = op.enhanceFuncOptionally(ebF, List.of("database_name", "database"), String.class,
FlushParam.Builder::withDatabaseName);
ebF = op.enhanceFuncOptionally(ebF, "sync_flush_waiting_interval", Number.class,
(FlushParam.Builder b, Number n) -> b.withSyncFlushWaitingInterval(n.longValue()));
ebF = op.enhanceFuncOptionally(ebF, "sync_flush_waiting_timeout", Number.class,
(FlushParam.Builder b, Number n) -> b.withSyncFlushWaitingTimeout(n.longValue()));
final LongFunction<FlushParam.Builder> lastF = ebF;
final LongFunction<FlushParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<FlushParam>> createOpFunc(
LongFunction<FlushParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusFlushOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,60 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.bulkinsert.GetBulkInsertStateParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetBulkInsertStateOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetCollectionStatisticsOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusGetBulkInsertStateOpDispenser extends MilvusBaseOpDispenser<GetBulkInsertStateParam> {
public MilvusGetBulkInsertStateOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<GetBulkInsertStateParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetBulkInsertStateParam.Builder> ebF =
l -> GetBulkInsertStateParam.newBuilder().withTask(Long.parseLong(targetF.apply(l)));
final LongFunction<GetBulkInsertStateParam.Builder> lastF = ebF;
final LongFunction<GetBulkInsertStateParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<GetBulkInsertStateParam>> createOpFunc(
LongFunction<GetBulkInsertStateParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetBulkInsertStateOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,64 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.collection.GetCollectionStatisticsParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetCollectionStatisticsOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusGetCollectionStatisticsOpDispenser extends MilvusBaseOpDispenser<GetCollectionStatisticsParam> {
public MilvusGetCollectionStatisticsOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<GetCollectionStatisticsParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetCollectionStatisticsParam.Builder> ebF =
l -> GetCollectionStatisticsParam.newBuilder().withCollectionName(targetF.apply(l));
// Add enhancement functions here
ebF = op.enhanceFuncOptionally(ebF, List.of("database_name","database"), String.class,
GetCollectionStatisticsParam.Builder::withDatabaseName);
ebF = op.enhanceFuncOptionally(ebF,"flush",Boolean.class,GetCollectionStatisticsParam.Builder::withFlush);
final LongFunction<GetCollectionStatisticsParam.Builder> lastF = ebF;
final LongFunction<GetCollectionStatisticsParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<GetCollectionStatisticsParam>> createOpFunc(
LongFunction<GetCollectionStatisticsParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetCollectionStatisticsOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,59 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.control.GetCompactionStateParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetCompactionStateOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusGetCompactionStateOpDispenser extends MilvusBaseOpDispenser<GetCompactionStateParam> {
public MilvusGetCompactionStateOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<GetCompactionStateParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetCompactionStateParam.Builder> ebF =
l -> GetCompactionStateParam.newBuilder().withCompactionID(Long.parseLong(targetF.apply(l)));
final LongFunction<GetCompactionStateParam.Builder> lastF = ebF;
final LongFunction<GetCompactionStateParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<GetCompactionStateParam>> createOpFunc(
LongFunction<GetCompactionStateParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetCompactionStateOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,60 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.control.GetCompactionPlansParam;
import io.milvus.param.control.GetCompactionPlansParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetCompactionStateWithPlansOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusGetCompactionStateWithPlansOpDispenser extends MilvusBaseOpDispenser<GetCompactionPlansParam> {
public MilvusGetCompactionStateWithPlansOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<GetCompactionPlansParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetCompactionPlansParam.Builder> ebF =
l -> GetCompactionPlansParam.newBuilder().withCompactionID(Long.parseLong(targetF.apply(l)));
final LongFunction<GetCompactionPlansParam.Builder> lastF = ebF;
final LongFunction<GetCompactionPlansParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<GetCompactionPlansParam>> createOpFunc(
LongFunction<GetCompactionPlansParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetCompactionStateWithPlansOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,58 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.control.GetFlushAllStateParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetFlushAllStateOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusGetFlushAllStateOpDispenser extends MilvusBaseOpDispenser<GetFlushAllStateParam> {
public MilvusGetFlushAllStateOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<GetFlushAllStateParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetFlushAllStateParam.Builder> ebF =
l -> GetFlushAllStateParam.newBuilder().withFlushAllTs(Long.parseLong(targetF.apply(l)));
final LongFunction<GetFlushAllStateParam.Builder> lastF = ebF;
final LongFunction<GetFlushAllStateParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<GetFlushAllStateParam>> createOpFunc(
LongFunction<GetFlushAllStateParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetFlushAllStateOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,74 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.control.GetFlushStateParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetFlushStateOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.Arrays;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusGetFlushStateOpDispenser extends MilvusBaseOpDispenser<GetFlushStateParam> {
public MilvusGetFlushStateOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<GetFlushStateParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetFlushStateParam.Builder> ebF =
l -> GetFlushStateParam.newBuilder();
// Add enhancement functions here
LongFunction<List<Long>> idsF = l -> {
List<Long> ids = Arrays.stream(targetF.apply(l).split("( +| *, *)"))
.map(Long::valueOf).toList();
return ids;
};
LongFunction<GetFlushStateParam.Builder> finalEbF = ebF;
ebF = l -> finalEbF.apply(l).withSegmentIDs(idsF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, List.of("collection", "collection_name"), String.class,
GetFlushStateParam.Builder::withCollectionName);
ebF = op.enhanceFuncOptionally(ebF, "flush_ts", Number.class,
(GetFlushStateParam.Builder b, Number n) -> b.withFlushTs(n.longValue()));
final LongFunction<GetFlushStateParam.Builder> lastF = ebF;
final LongFunction<GetFlushStateParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<GetFlushStateParam>> createOpFunc(
LongFunction<GetFlushStateParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetFlushStateOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,62 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.index.GetIndexBuildProgressParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetIndexBuildProgressOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusGetIndexBuildProgressOpDispenser extends MilvusBaseOpDispenser<GetIndexBuildProgressParam> {
public MilvusGetIndexBuildProgressOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<GetIndexBuildProgressParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetIndexBuildProgressParam.Builder> ebF =
l -> GetIndexBuildProgressParam.newBuilder().withIndexName(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, List.of("collection_name","collection"),String.class,
GetIndexBuildProgressParam.Builder::withCollectionName);
final LongFunction<GetIndexBuildProgressParam.Builder> lastF = ebF;
final LongFunction<GetIndexBuildProgressParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<GetIndexBuildProgressParam>> createOpFunc(
LongFunction<GetIndexBuildProgressParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetIndexBuildProgressOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,61 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.index.GetIndexStateParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetIndexStateOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusGetIndexStateOpDispenser extends MilvusBaseOpDispenser<GetIndexStateParam> {
public MilvusGetIndexStateOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<GetIndexStateParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetIndexStateParam.Builder> ebF =
l -> GetIndexStateParam.newBuilder().withIndexName(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, List.of("collection_name","collection"),String.class,
GetIndexStateParam.Builder::withCollectionName);
final LongFunction<GetIndexStateParam.Builder> lastF = ebF;
final LongFunction<GetIndexStateParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<GetIndexStateParam>> createOpFunc(
LongFunction<GetIndexStateParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetIndexStateOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,104 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.grpc.LoadState;
import io.milvus.param.collection.GetLoadStateParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.MilvusAdapterUtils;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetLoadStateOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.nb.api.errors.OpConfigError;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Optional;
import java.util.function.LongFunction;
public class MilvusGetLoadStateOpDispenser extends MilvusBaseOpDispenser<GetLoadStateParam> {
private Duration awaitTimeout = Duration.ZERO;
private Duration awaitInterval = Duration.of(10, ChronoUnit.SECONDS);
private LoadState awaitState = LoadState.UNRECOGNIZED;
public MilvusGetLoadStateOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
op.getOptionalStaticValue("await_timeout", Number.class)
.map(Number::doubleValue)
.ifPresent(v->this.awaitTimeout=Duration.of((long)(v*1000),ChronoUnit.MILLIS));
op.getOptionalStaticValue("await_interval", Number.class)
.map(Number::doubleValue).ifPresent(v->this.awaitInterval=Duration.of((long)(v*1000),ChronoUnit.MILLIS));
op.getOptionalStaticValue("await_state", String.class).ifPresent(s -> {
var spec = s.toLowerCase();
for (LoadState value : LoadState.values()) {
if (value.name().toLowerCase().equals(spec) || value.name().toLowerCase().equals("loadstate" + spec)) {
this.awaitState = value;
break;
}
}
if (this.awaitState == null) {
throw new OpConfigError("Unrecognizable load state to await: " + spec);
}
});
}
@Override
public LongFunction<GetLoadStateParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetLoadStateParam.Builder> ebF =
l -> GetLoadStateParam.newBuilder().withCollectionName(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, List.of("database_name", "database"), String.class,
GetLoadStateParam.Builder::withDatabaseName);
Optional<LongFunction<String>> partitionsF = op.getAsOptionalFunction("partition_name", String.class);
if (partitionsF.isPresent()) {
LongFunction<String> pfunc = partitionsF.get();
LongFunction<GetLoadStateParam.Builder> finalEbF = ebF;
ebF = l -> finalEbF.apply(l).withPartitionNames(MilvusAdapterUtils.splitNames(pfunc.apply(l)));
}
final LongFunction<GetLoadStateParam.Builder> lastF = ebF;
return l -> lastF.apply(l).build();
}
@Override
public LongFunction<MilvusBaseOp<GetLoadStateParam>> createOpFunc(
LongFunction<GetLoadStateParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetLoadStateOp(
clientF.apply(l),
paramF.apply(l),
this.awaitState,
this.awaitTimeout,
this.awaitInterval
);
}
}

View File

@@ -0,0 +1,60 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.collection.GetLoadingProgressParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetLoadingProgressOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusGetLoadingProgressOpDispenser extends MilvusBaseOpDispenser<GetLoadingProgressParam> {
public MilvusGetLoadingProgressOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<GetLoadingProgressParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetLoadingProgressParam.Builder> ebF =
l -> GetLoadingProgressParam.newBuilder().withCollectionName(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, List.of("partition_names","partitions"), List.class,
GetLoadingProgressParam.Builder::withPartitionNames);
final LongFunction<GetLoadingProgressParam.Builder> lastF = ebF;
return l -> lastF.apply(l).build();
}
@Override
public LongFunction<MilvusBaseOp<GetLoadingProgressParam>> createOpFunc(
LongFunction<GetLoadingProgressParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetLoadingProgressOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,58 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.control.GetMetricsParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetMetricsOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusGetMetricsOpDispenser extends MilvusBaseOpDispenser<GetMetricsParam> {
public MilvusGetMetricsOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<GetMetricsParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetMetricsParam.Builder> ebF =
l -> GetMetricsParam.newBuilder().withRequest(targetF.apply(l));
final LongFunction<GetMetricsParam.Builder> lastF = ebF;
final LongFunction<GetMetricsParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<GetMetricsParam>> createOpFunc(
LongFunction<GetMetricsParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetMetricsOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,114 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.common.clientenum.ConsistencyLevelEnum;
import io.milvus.param.highlevel.dml.GetIdsParam;
import io.nosqlbench.adapter.milvus.MilvusAdapterUtils;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
/**
* Because we are using type-and-target logic to identify the op variant,
* we are limited to a string target value. In this particular op type, the
* IDs are key target elements. Unfortunately, this creates a type incompatibility
* where the target values should be determined at runtime based on the binding
* in the most dynamic case. This is because the data model in use should determine
* the type needed, and users would generally use bindings for this.
*
* <P>The target is expected to be nominal (naming the operation's noun), and thus is
* historically limited to string forms. This op will need to be refactored around
* a slightly more flexible API which can allow the target value to be type-variant,
* and maybe even structure variant such that all nouns can be passed as named parameters
* underneath the type designator.
*/
public class MilvusGetOpDispenser extends MilvusBaseOpDispenser<GetIdsParam> {
public MilvusGetOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<GetIdsParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetIdsParam.Builder> ebF =
l -> GetIdsParam.newBuilder();
// ebF = l -> ebF.apply(l).withPrimaryIds(MilvusAdapterUtils.splitNames(targetF.apply(l)));
LongFunction<Object> valueFunc = op.getAsRequiredFunction("primary_ids", Object.class);
Object testValue = valueFunc.apply(0L);
LongFunction<List<Object>> pidsF;
if (testValue instanceof String string) {
pidsF = l -> MilvusAdapterUtils.splitNames((String) valueFunc.apply(l))
.stream().map(s -> (Object) s).toList();
} else if (testValue instanceof List) {
pidsF = l -> (List<Object>) valueFunc.apply(l);
} else {
throw new RuntimeException("Invalid type for primary_ids: " + testValue.getClass().getCanonicalName());
}
LongFunction<GetIdsParam.Builder> finalEbF2 = ebF;
ebF = l -> finalEbF2.apply(l).withPrimaryIds(pidsF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, List.of("collection_name", "collection"), String.class,
GetIdsParam.Builder::withCollectionName);
ebF = op.enhanceEnumOptionally(ebF, "consistency_level", ConsistencyLevelEnum.class,
GetIdsParam.Builder::withConsistencyLevel);
ebF = op.enhanceEnumOptionally(ebF, "cl", ConsistencyLevelEnum.class,
GetIdsParam.Builder::withConsistencyLevel);
if (op.isDefined("output_fields")) {
LongFunction<Object> outputFieldsF = op.getAsRequiredFunction("output_fields", Object.class);
Object oftv = outputFieldsF.apply(0L);
LongFunction<List> ofF;
if (oftv instanceof List) {
ofF = op.getAsRequiredFunction("output_fields", List.class);
LongFunction<GetIdsParam.Builder> finalEbF = ebF;
ebF = l -> finalEbF.apply(l).withOutputFields((List<String>) ofF.apply(l));
} else if (oftv instanceof String) {
var sF = op.getAsRequiredFunction("output_fields", String.class);
LongFunction<GetIdsParam.Builder> finalEbF1 = ebF;
ebF = l -> finalEbF1.apply(l).withOutputFields(MilvusAdapterUtils.splitNames(sF.apply(l)));
} else throw new RuntimeException("Invalid type for output fields:" + oftv.getClass().getCanonicalName());
}
final LongFunction<GetIdsParam.Builder> lastF = ebF;
final LongFunction<GetIdsParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<GetIdsParam>> createOpFunc(
LongFunction<GetIdsParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,63 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.partition.GetPartitionStatisticsParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetPartitionStatisticsOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusGetPartitionStatisticsOpDispenser extends MilvusBaseOpDispenser<GetPartitionStatisticsParam> {
public MilvusGetPartitionStatisticsOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<GetPartitionStatisticsParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetPartitionStatisticsParam.Builder> ebF =
l -> GetPartitionStatisticsParam.newBuilder().withPartitionName(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, List.of("collection_name","collection"),String.class,
GetPartitionStatisticsParam.Builder::withCollectionName);
ebF = op.enhanceFuncOptionally(ebF, "flush",Boolean.class, GetPartitionStatisticsParam.Builder::withFlush);
final LongFunction<GetPartitionStatisticsParam.Builder> lastF = ebF;
final LongFunction<GetPartitionStatisticsParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<GetPartitionStatisticsParam>> createOpFunc(
LongFunction<GetPartitionStatisticsParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetPartitionStatisticsOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,64 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.partition.GetPartitionStatisticsParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetPartitionStatisticsOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusGetPersistentSegmentInfoOpDispenser extends MilvusBaseOpDispenser<GetPartitionStatisticsParam> {
public MilvusGetPersistentSegmentInfoOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<GetPartitionStatisticsParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetPartitionStatisticsParam.Builder> ebF =
l -> GetPartitionStatisticsParam.newBuilder().withPartitionName(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF,"flush",Boolean.class,GetPartitionStatisticsParam.Builder::withFlush);
ebF = op.enhanceFuncOptionally(ebF, List.of("collection_name","collection"),String.class,
GetPartitionStatisticsParam.Builder::withCollectionName);
final LongFunction<GetPartitionStatisticsParam.Builder> lastF = ebF;
final LongFunction<GetPartitionStatisticsParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<GetPartitionStatisticsParam>> createOpFunc(
LongFunction<GetPartitionStatisticsParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetPartitionStatisticsOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,59 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.control.GetQuerySegmentInfoParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetQuerySegmentInfoOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusGetQuerySegmentInfoOpDispenser extends MilvusBaseOpDispenser<GetQuerySegmentInfoParam> {
public MilvusGetQuerySegmentInfoOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<GetQuerySegmentInfoParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetQuerySegmentInfoParam.Builder> ebF =
l -> GetQuerySegmentInfoParam.newBuilder().withCollectionName(targetF.apply(l));
final LongFunction<GetQuerySegmentInfoParam.Builder> lastF = ebF;
final LongFunction<GetQuerySegmentInfoParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<GetQuerySegmentInfoParam>> createOpFunc(
LongFunction<GetQuerySegmentInfoParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetQuerySegmentInfoOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,58 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.control.GetReplicasParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetReplicasOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusGetReplicasOpDispenser extends MilvusBaseOpDispenser<GetReplicasParam> {
public MilvusGetReplicasOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<GetReplicasParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetReplicasParam.Builder> ebF =
l -> GetReplicasParam.newBuilder().withCollectionName(targetF.apply(l));
final LongFunction<GetReplicasParam.Builder> lastF = ebF;
final LongFunction<GetReplicasParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<GetReplicasParam>> createOpFunc(
LongFunction<GetReplicasParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetReplicasOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,62 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.partition.HasPartitionParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusHasPartitionOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusHasPartitionOpDispenser extends MilvusBaseOpDispenser<HasPartitionParam> {
public MilvusHasPartitionOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<HasPartitionParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<HasPartitionParam.Builder> ebF =
l -> HasPartitionParam.newBuilder().withPartitionName(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, List.of("collection_name","collection"),String.class,
HasPartitionParam.Builder::withCollectionName);
final LongFunction<HasPartitionParam.Builder> lastF = ebF;
final LongFunction<HasPartitionParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<HasPartitionParam>> createOpFunc(
LongFunction<HasPartitionParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusHasPartitionOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,103 @@
package io.nosqlbench.adapter.milvus.opdispensers;
/*
* 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.
*/
import com.alibaba.fastjson.JSONObject;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.dml.InsertParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusInsertOp;
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;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.LongFunction;
public class MilvusInsertOpDispenser extends MilvusBaseOpDispenser<InsertParam> {
private static final Logger logger = LogManager.getLogger(MilvusInsertOpDispenser.class);
/**
* Create a new MilvusDeleteOpDispenser subclassed from {@link MilvusBaseOpDispenser}.
*
* @param adapter The associated {@link MilvusDriverAdapter}
* @param op The {@link ParsedOp} encapsulating the activity for this cycle
* @param targetFunction A LongFunction that returns the specified Milvus Index for this Op
*/
public MilvusInsertOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<InsertParam> getParamFunc(LongFunction<MilvusServiceClient> clientF, ParsedOp op, LongFunction<String> targetF) {
LongFunction<InsertParam.Builder> f =
l -> InsertParam.newBuilder().withCollectionName(targetF.apply(l));
f = op.enhanceFuncOptionally(
f, List.of("partition_name","partition"), String.class,
InsertParam.Builder::withPartitionName
);
f = op.enhanceFuncOptionally(
f, List.of("database_name","database"), String.class,
InsertParam.Builder::withDatabaseName
);
Optional<LongFunction<List<JSONObject>>> optionalRowsF = MilvusOpUtils.getHighLevelRowsFunction(op, "rows");
Optional<LongFunction<List<InsertParam.Field>>> optionalFieldsF = MilvusOpUtils.getFieldsFunction(op, "fields");
if (optionalFieldsF.isPresent() && optionalRowsF.isPresent()) {
throw new OpConfigError("Must provide either rows or fields, but not both.");
}
if (optionalFieldsF.isEmpty() && optionalRowsF.isEmpty()) {
throw new OpConfigError("Must provide either rows or fields");
}
if (optionalRowsF.isPresent()) {
var rf = optionalRowsF.get();
LongFunction<InsertParam.Builder> finalF2 = f;
f = l -> finalF2.apply(l).withRows(rf.apply(l));
}
if (optionalFieldsF.isPresent()) {
var ff = optionalFieldsF.get();
LongFunction<InsertParam.Builder> finalF3 = f;
f = l -> finalF3.apply(l).withFields(ff.apply(l));
}
LongFunction<InsertParam.Builder> finalF = f;
return l -> finalF.apply(l).build();
}
@Override
public LongFunction<MilvusBaseOp<InsertParam>> createOpFunc(
LongFunction<InsertParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op, LongFunction<String> targetF
) {
return l -> new MilvusInsertOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,85 @@
package io.nosqlbench.adapter.milvus.opdispensers;
/*
* 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.
*/
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.dml.InsertParam;
import io.milvus.param.highlevel.dml.InsertRowsParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusInsertOp;
import io.nosqlbench.adapter.milvus.ops.MilvusInsertRowsOp;
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;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.LongFunction;
public class MilvusInsertRowsOpDispenser extends MilvusBaseOpDispenser<InsertRowsParam> {
private static final Logger logger = LogManager.getLogger(MilvusInsertRowsOpDispenser.class);
/**
* Create a new MilvusDeleteOpDispenser subclassed from {@link MilvusBaseOpDispenser}.
*
* @param adapter
* The associated {@link MilvusDriverAdapter}
* @param op
* The {@link ParsedOp} encapsulating the activity for this cycle
* @param targetFunction
* A LongFunction that returns the specified Milvus Index for this Op
*/
public MilvusInsertRowsOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<InsertRowsParam> getParamFunc(LongFunction<MilvusServiceClient> clientF, ParsedOp op,
LongFunction<String> targetF) {
LongFunction<InsertRowsParam.Builder> f =
l -> InsertRowsParam.newBuilder().withCollectionName(targetF.apply(l));
LongFunction<List<JSONObject>> rowsF = MilvusOpUtils
.getHighLevelRowsFunction(op, "rows")
.orElseThrow(() -> new RuntimeException("rows must be provided for op template '" + op.getName() + "'"));
LongFunction<InsertRowsParam.Builder> finalF1 = f;
f = l -> finalF1.apply(l).withRows(rowsF.apply(l));
LongFunction<InsertRowsParam.Builder> finalF = f;
return l -> finalF.apply(l).build();
}
@Override
public LongFunction<MilvusBaseOp<InsertRowsParam>> createOpFunc(
LongFunction<InsertRowsParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op, LongFunction<String> targetF
) {
return l -> new MilvusInsertRowsOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,61 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.bulkinsert.ListBulkInsertTasksParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusListBulkInsertTasksOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusListBulkInsertTasksOpDispenser extends MilvusBaseOpDispenser<ListBulkInsertTasksParam> {
public MilvusListBulkInsertTasksOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<ListBulkInsertTasksParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<ListBulkInsertTasksParam.Builder> ebF =
l -> ListBulkInsertTasksParam.newBuilder().withCollectionName(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, "limit", Number.class,
(ListBulkInsertTasksParam.Builder b, Number n) -> b.withLimit(n.intValue()));
final LongFunction<ListBulkInsertTasksParam.Builder> lastF = ebF;
final LongFunction<ListBulkInsertTasksParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<ListBulkInsertTasksParam>> createOpFunc(
LongFunction<ListBulkInsertTasksParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusListBulkInsertTasksOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,54 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.highlevel.collection.ListCollectionsParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusListCollectionsOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusListCollectionsOpDispenser extends MilvusBaseOpDispenser<ListCollectionsParam> {
public MilvusListCollectionsOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<ListCollectionsParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> ListCollectionsParam.newBuilder().build();
}
@Override
public LongFunction<MilvusBaseOp<ListCollectionsParam>> createOpFunc(
LongFunction<ListCollectionsParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusListCollectionsOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,54 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.credential.ListCredUsersParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusListCredUsersOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusListCredUsersOpDispenser extends MilvusBaseOpDispenser<ListCredUsersParam> {
public MilvusListCredUsersOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<ListCredUsersParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> ListCredUsersParam.newBuilder().build();
}
@Override
public LongFunction<MilvusBaseOp<ListCredUsersParam>> createOpFunc(
LongFunction<ListCredUsersParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusListCredUsersOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,49 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusListDatabasesOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusListDatabasesOpDispenser extends MilvusBaseOpDispenser<Object> {
public MilvusListDatabasesOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<Object> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> "";
}
@Override
public LongFunction<MilvusBaseOp<Object>> createOpFunc(LongFunction<Object> paramF, LongFunction<MilvusServiceClient> clientF, ParsedOp op, LongFunction<String> targetF) {
return l -> new MilvusListDatabasesOp(clientF.apply(l),null);
}
}

View File

@@ -0,0 +1,64 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.control.LoadBalanceParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusLoadBalanceOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusLoadBalanceOpDispenser extends MilvusBaseOpDispenser<LoadBalanceParam> {
public MilvusLoadBalanceOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<LoadBalanceParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<LoadBalanceParam.Builder> ebF =
l -> LoadBalanceParam.newBuilder();
LongFunction<String> segmentsStringF = op.getAsRequiredFunction("segment_ids");
// ebF = l -> ebF.apply(l).withSegmentIDs(MilvusAdapterUtils.splitLongs(segmentsStringF.apply(l)));
throw new RuntimeException("implement me");
// todo: implement me
// final LongFunction<LoadBalanceParam.Builder> lastF = ebF;
// final LongFunction<LoadBalanceParam> collectionParamF = l -> lastF.apply(l).build();
// return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<LoadBalanceParam>> createOpFunc(
LongFunction<LoadBalanceParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusLoadBalanceOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,73 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.collection.LoadCollectionParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusLoadCollectionOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusLoadCollectionOpDispenser extends MilvusBaseOpDispenser<LoadCollectionParam> {
public MilvusLoadCollectionOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<LoadCollectionParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<LoadCollectionParam.Builder> ebF =
l -> LoadCollectionParam.newBuilder().withCollectionName(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, List.of("database_name", "database"), String.class,
LoadCollectionParam.Builder::withDatabaseName);
ebF = op.enhanceFuncOptionally(ebF, "refresh", Boolean.class, LoadCollectionParam.Builder::withRefresh);
ebF = op.enhanceFuncOptionally(ebF, "sync_load", Boolean.class, LoadCollectionParam.Builder::withSyncLoad);
ebF = op.enhanceFuncOptionally(ebF, "replica_number", Number.class,
(LoadCollectionParam.Builder b, Number n) -> b.withReplicaNumber(n.intValue()));
ebF = op.enhanceFuncOptionally(ebF, "resource_groups", List.class, LoadCollectionParam.Builder::withResourceGroups);
ebF = op.enhanceFuncOptionally(ebF, "sync_load_waiting_interval", Number.class,
(LoadCollectionParam.Builder b, Number n) -> b.withSyncLoadWaitingInterval(n.longValue()));
ebF = op.enhanceFuncOptionally(ebF, "sync_load_waiting_timeout", Number.class,
(LoadCollectionParam.Builder b, Number n) -> b.withSyncLoadWaitingTimeout(n.longValue()));
final LongFunction<LoadCollectionParam.Builder> lastF = ebF;
final LongFunction<LoadCollectionParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<LoadCollectionParam>> createOpFunc(
LongFunction<LoadCollectionParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusLoadCollectionOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,86 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.partition.LoadPartitionsParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusLoadPartitionsOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusLoadPartitionsOpDispenser extends MilvusBaseOpDispenser<LoadPartitionsParam> {
/**
* TODO: Refactor this class after API refinements for more type and target variation
*
* @param adapter
* @param op
* @param targetFunction
*/
public MilvusLoadPartitionsOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<LoadPartitionsParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<LoadPartitionsParam.Builder> ebF =
l -> LoadPartitionsParam.newBuilder().withCollectionName(targetF.apply(l));
ebF = op.enhanceFunc(ebF, List.of("partition_names", "partitions"), List.class,
LoadPartitionsParam.Builder::withPartitionNames);
ebF = op.enhanceFuncOptionally(
ebF, "resource_groups", List.class,
LoadPartitionsParam.Builder::withResourceGroups
);
ebF = op.enhanceFuncOptionally(
ebF, List.of("database_name", "database"), String.class,
LoadPartitionsParam.Builder::withDatabaseName
);
ebF = op.enhanceFuncOptionally(ebF, "refresh", Boolean.class, LoadPartitionsParam.Builder::withRefresh);
ebF = op.enhanceFuncOptionally(ebF, "replica_number", Number.class,
(LoadPartitionsParam.Builder b, Number n) -> b.withReplicaNumber(n.intValue()));
ebF = op.enhanceFuncOptionally(ebF, "sync_load", Boolean.class, LoadPartitionsParam.Builder::withSyncLoad);
ebF = op.enhanceFuncOptionally(ebF, "sync_load_waiting_interval", Number.class,
(LoadPartitionsParam.Builder b, Number n) -> b.withSyncLoadWaitingInterval(n.longValue()));
ebF = op.enhanceFuncOptionally(ebF, "sync_load_waiting_timeout", Number.class,
(LoadPartitionsParam.Builder b, Number n) -> b.withSyncLoadWaitingTimeout(n.longValue()));
final LongFunction<LoadPartitionsParam.Builder> lastF = ebF;
final LongFunction<LoadPartitionsParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<LoadPartitionsParam>> createOpFunc(
LongFunction<LoadPartitionsParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusLoadPartitionsOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,62 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.collection.GetLoadingProgressParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusGetLoadingProgressOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusLoadingProgressOpDispenser extends MilvusBaseOpDispenser<GetLoadingProgressParam> {
public MilvusLoadingProgressOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<GetLoadingProgressParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<GetLoadingProgressParam.Builder> ebF =
l -> GetLoadingProgressParam.newBuilder().withCollectionName(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF,List.of("partition_names","partitions"), List.class,
GetLoadingProgressParam.Builder::withPartitionNames);
final LongFunction<GetLoadingProgressParam.Builder> lastF = ebF;
final LongFunction<GetLoadingProgressParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<GetLoadingProgressParam>> createOpFunc(
LongFunction<GetLoadingProgressParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusGetLoadingProgressOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,58 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.control.ManualCompactParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusManualCompactOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusManualCompactOpDispenser extends MilvusBaseOpDispenser<ManualCompactParam> {
public MilvusManualCompactOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<ManualCompactParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<ManualCompactParam.Builder> ebF =
l -> ManualCompactParam.newBuilder().withCollectionName(targetF.apply(l));
final LongFunction<ManualCompactParam.Builder> lastF = ebF;
final LongFunction<ManualCompactParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<ManualCompactParam>> createOpFunc(
LongFunction<ManualCompactParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusManualCompactOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,99 @@
/*
* 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.opdispensers;
import com.alibaba.fastjson.JSONObject;
import io.milvus.param.dml.InsertParam;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.nb.api.errors.OpConfigError;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.LongFunction;
public class MilvusOpUtils {
public static Optional<LongFunction<List<JSONObject>>> getHighLevelRowsFunction(ParsedOp op, String opfield) {
if (!op.isDefined(opfield)) {
return Optional.empty();
}
LongFunction<Object> rowF = op.getAsRequiredFunction(opfield, Object.class);
Object testObject = rowF.apply(0L);
LongFunction<List<JSONObject>> rowsF = null;
if (testObject instanceof JSONObject) {
rowsF = l -> List.of((JSONObject) rowF.apply(l));
} else if (testObject instanceof Map) {
rowsF = l -> List.of(new JSONObject((Map<String, Object>) rowF.apply(l)));
} else if (testObject instanceof List list) {
if (list.size() == 0) {
throw new OpConfigError("Unable to detect type of list object for empty list for op named '" + op.getName() + "'");
} else if (list.get(0) instanceof JSONObject) {
rowsF = l -> (List<JSONObject>) rowF.apply(l);
} else if (list.get(0) instanceof Map) {
rowsF = l -> List.of(new JSONObject((Map<String, Object>) rowF.apply(l)));
}
}
return Optional.ofNullable(rowsF);
//
// if (rowsF==null) {
// throw new OpConfigError("A Milvus row list can only be created from " +
// "1) a JSONObject (1 row), " +
// "2) A Map (1 row), " +
// "3) a List of JSONObject (multiple rows), or " +
// "4) a list of Maps (multiple rows)");
// }
}
public static Optional<LongFunction<List<InsertParam.Field>>> getFieldsFunction(ParsedOp op, String opfield) {
if (!op.isDefined(opfield)) {
return Optional.empty();
}
ParsedOp valueTemplate = op.getAsSubOp(opfield, ParsedOp.SubOpNaming.SubKey);
Map<String, Object> testFieldsValues = valueTemplate.apply(0L);
List<LongFunction<InsertParam.Field>> fieldsF = new ArrayList<>(testFieldsValues.size());
for (String fieldName : testFieldsValues.keySet()) {
Object testFieldValue = testFieldsValues.get(fieldName);
if (!(testFieldValue instanceof List<?> list)) {
throw new OpConfigError("Every value provided to a named field must be a List, not " + testFieldValue.getClass().getSimpleName());
}
}
LongFunction<List<InsertParam.Field>> f = new FieldsFuncFromMap(valueTemplate::apply);
return Optional.of(f);
}
private record FieldsFuncFromMap(
LongFunction<Map<String, Object>> generator
) implements LongFunction<List<InsertParam.Field>> {
@Override
public List<InsertParam.Field> apply(long value) {
Map<String, Object> datamap = generator.apply(value);
ArrayList<InsertParam.Field> fields = new ArrayList<>(datamap.size());
datamap.forEach((k,v) -> {
fields.add(new InsertParam.Field(k,(List)v));
});
return fields;
}
}
}

View File

@@ -0,0 +1,70 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.common.clientenum.ConsistencyLevelEnum;
import io.milvus.param.dml.QueryParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusQueryOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusQueryOpDispenser extends MilvusBaseOpDispenser<QueryParam> {
public MilvusQueryOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<QueryParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<QueryParam.Builder> ebF =
l -> QueryParam.newBuilder().withCollectionName(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, List.of("partition_names", "partitions"), List.class,
QueryParam.Builder::withPartitionNames);
ebF = op.enhanceEnumOptionally(ebF, "consistency_level", ConsistencyLevelEnum.class, QueryParam.Builder::withConsistencyLevel);
ebF = op.enhanceFuncOptionally(ebF, "expr", String.class, QueryParam.Builder::withExpr);
ebF = op.enhanceFuncOptionally(ebF, "limit", Number.class, (QueryParam.Builder b, Number n) -> b.withLimit(n.longValue()));
ebF = op.enhanceFuncOptionally(ebF, "offset", Number.class, (QueryParam.Builder b, Number n) -> b.withOffset(n.longValue()));
ebF = op.enhanceFuncOptionally(ebF, "ignore_growing", Boolean.class, QueryParam.Builder::withIgnoreGrowing);
ebF = op.enhanceFuncOptionally(ebF, "out_fields", List.class, QueryParam.Builder::withOutFields);
final LongFunction<QueryParam.Builder> lastF = ebF;
final LongFunction<QueryParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<QueryParam>> createOpFunc(
LongFunction<QueryParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusQueryOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,59 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.collection.ReleaseCollectionParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusReleaseCollectionOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusReleaseCollectionOpDispenser extends MilvusBaseOpDispenser<ReleaseCollectionParam> {
public MilvusReleaseCollectionOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<ReleaseCollectionParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<ReleaseCollectionParam.Builder> ebF =
l -> ReleaseCollectionParam.newBuilder().withCollectionName(targetF.apply(l));
final LongFunction<ReleaseCollectionParam.Builder> lastF = ebF;
final LongFunction<ReleaseCollectionParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<ReleaseCollectionParam>> createOpFunc(
LongFunction<ReleaseCollectionParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusReleaseCollectionOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,67 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.partition.ReleasePartitionsParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.MilvusAdapterUtils;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusReleasePartitionsOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusReleasePartitionsOpDispenser extends MilvusBaseOpDispenser<ReleasePartitionsParam> {
public MilvusReleasePartitionsOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<ReleasePartitionsParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<ReleasePartitionsParam.Builder> ebF =
l -> ReleasePartitionsParam.newBuilder();
LongFunction<List<String>> partNamesF = l -> MilvusAdapterUtils.splitNames(targetF.apply(l));
LongFunction<ReleasePartitionsParam.Builder> finalEbF = ebF;
ebF = l -> finalEbF.apply(l).withPartitionNames(partNamesF.apply(l));
ebF = op.enhanceFuncOptionally(ebF,List.of("collection_name","collection"),String.class,
ReleasePartitionsParam.Builder::withCollectionName);
final LongFunction<ReleasePartitionsParam.Builder> lastF = ebF;
final LongFunction<ReleasePartitionsParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<ReleasePartitionsParam>> createOpFunc(
LongFunction<ReleasePartitionsParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusReleasePartitionsOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,78 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.common.clientenum.ConsistencyLevelEnum;
import io.milvus.param.MetricType;
import io.milvus.param.dml.SearchParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusSearchOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusSearchOpDispenser extends MilvusBaseOpDispenser<SearchParam> {
public MilvusSearchOpDispenser(
MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<SearchParam> getParamFunc(LongFunction<MilvusServiceClient> clientF, ParsedOp op, LongFunction<String> targetF) {
LongFunction<SearchParam.Builder> ebF =
l -> SearchParam.newBuilder().withCollectionName(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF, List.of("partition_names", "partitions"), List.class, SearchParam.Builder::withPartitionNames);
ebF = op.enhanceFuncOptionally(ebF, "out_fields", List.class, SearchParam.Builder::withOutFields);
ebF = op.enhanceEnumOptionally(ebF, "consistency_level", ConsistencyLevelEnum.class, SearchParam.Builder::withConsistencyLevel);
ebF = op.enhanceFuncOptionally(ebF, "expr", String.class, SearchParam.Builder::withExpr);
ebF = op.enhanceDefaultFunc(ebF, "top_k", Number.class, 100,
(SearchParam.Builder b, Number n) -> b.withTopK(n.intValue()));
ebF = op.enhanceEnumOptionally(ebF, "metric_type", MetricType.class, SearchParam.Builder::withMetricType);
ebF = op.enhanceFuncOptionally(ebF, "round_decimal", Number.class,
(SearchParam.Builder b, Number n) -> b.withRoundDecimal(n.intValue()));
ebF = op.enhanceFuncOptionally(ebF, "ignore_growing", Boolean.class, SearchParam.Builder::withIgnoreGrowing);
ebF = op.enhanceFuncOptionally(ebF, "params", String.class, SearchParam.Builder::withParams);
ebF = op.enhanceFunc(ebF, List.of("vector_field_name", "vector_field"), String.class,
SearchParam.Builder::withVectorFieldName);
// TODO: sanity check List of Floats vs List of List of Floats at func construction time.
ebF = op.enhanceFuncOptionally(ebF, "vectors", List.class, SearchParam.Builder::withVectors);
ebF = op.enhanceFuncOptionally(ebF, "vector", List.class, (b, l) -> b.withVectors(List.of(l)));
LongFunction<SearchParam.Builder> finalEbF = ebF;
return l -> finalEbF.apply(l).build();
}
@Override
public LongFunction<MilvusBaseOp<SearchParam>> createOpFunc(
LongFunction<SearchParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusSearchOp(clientF.apply(l), paramF.apply(l));
}
}

View File

@@ -0,0 +1,69 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.grpc.ShowType;
import io.milvus.param.collection.ShowCollectionsParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.MilvusAdapterUtils;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusShowCollectionsOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusShowCollectionsOpDispenser extends MilvusBaseOpDispenser<ShowCollectionsParam> {
public MilvusShowCollectionsOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<ShowCollectionsParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<ShowCollectionsParam.Builder> ebF =
l -> ShowCollectionsParam.newBuilder();
LongFunction<List<String>> collectionsF = l -> MilvusAdapterUtils.splitNames(targetF.apply(l));
LongFunction<ShowCollectionsParam.Builder> finalEbF = ebF;
ebF = l -> finalEbF.apply(l).withCollectionNames(collectionsF.apply(l));
ebF = op.enhanceFuncOptionally(ebF,List.of("database_name","database"),String.class,
ShowCollectionsParam.Builder::withDatabaseName);
ebF = op.enhanceEnumOptionally(ebF,"show_type", ShowType.class,ShowCollectionsParam.Builder::withShowType);
logger.warn(this.getClass().getSimpleName() + " is deprecated, use get_loading_progress instead");
final LongFunction<ShowCollectionsParam.Builder> lastF = ebF;
final LongFunction<ShowCollectionsParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<ShowCollectionsParam>> createOpFunc(
LongFunction<ShowCollectionsParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusShowCollectionsOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,66 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.partition.ShowPartitionsParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.MilvusAdapterUtils;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusShowPartitionsOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.List;
import java.util.function.LongFunction;
public class MilvusShowPartitionsOpDispenser extends MilvusBaseOpDispenser<ShowPartitionsParam> {
public MilvusShowPartitionsOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<ShowPartitionsParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<ShowPartitionsParam.Builder> ebF =
l -> ShowPartitionsParam.newBuilder();
LongFunction<List<String>> partitionsF = l -> MilvusAdapterUtils.splitNames(targetF.apply(l));
LongFunction<ShowPartitionsParam.Builder> finalEbF = ebF;
ebF = l -> finalEbF.apply(l).withPartitionNames(partitionsF.apply(l));
ebF = op.enhanceFuncOptionally(ebF,List.of("collection_name","collection"),String.class,
ShowPartitionsParam.Builder::withCollectionName);
final LongFunction<ShowPartitionsParam.Builder> lastF = ebF;
final LongFunction<ShowPartitionsParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<ShowPartitionsParam>> createOpFunc(
LongFunction<ShowPartitionsParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusShowPartitionsOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,61 @@
/*
* 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.opdispensers;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.credential.UpdateCredentialParam;
import io.nosqlbench.adapter.milvus.MilvusDriverAdapter;
import io.nosqlbench.adapter.milvus.ops.MilvusBaseOp;
import io.nosqlbench.adapter.milvus.ops.MilvusUpdateCredentialOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class MilvusUpdateCredentialOpDispenser extends MilvusBaseOpDispenser<UpdateCredentialParam> {
public MilvusUpdateCredentialOpDispenser(MilvusDriverAdapter adapter,
ParsedOp op,
LongFunction<String> targetFunction) {
super(adapter, op, targetFunction);
}
@Override
public LongFunction<UpdateCredentialParam> getParamFunc(
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
LongFunction<UpdateCredentialParam.Builder> ebF =
l -> UpdateCredentialParam.newBuilder().withUsername(targetF.apply(l));
ebF = op.enhanceFuncOptionally(ebF,"old_password",String.class,UpdateCredentialParam.Builder::withOldPassword);
ebF = op.enhanceFuncOptionally(ebF,"new_password",String.class,UpdateCredentialParam.Builder::withNewPassword);
final LongFunction<UpdateCredentialParam.Builder> lastF = ebF;
final LongFunction<UpdateCredentialParam> collectionParamF = l -> lastF.apply(l).build();
return collectionParamF;
}
@Override
public LongFunction<MilvusBaseOp<UpdateCredentialParam>> createOpFunc(
LongFunction<UpdateCredentialParam> paramF,
LongFunction<MilvusServiceClient> clientF,
ParsedOp op,
LongFunction<String> targetF
) {
return l -> new MilvusUpdateCredentialOp(clientF.apply(l),paramF.apply(l));
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.alias.AlterAliasParam;
public class MilvusAlterAliasOp extends MilvusBaseOp<AlterAliasParam> {
public MilvusAlterAliasOp(MilvusServiceClient client, AlterAliasParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.alterAlias(request);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.collection.AlterCollectionParam;
public class MilvusAlterCollectionOp extends MilvusBaseOp<AlterCollectionParam> {
public MilvusAlterCollectionOp(MilvusServiceClient client, AlterCollectionParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.alterCollection(request);
}
}

View File

@@ -0,0 +1,80 @@
/*
* 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.param.R;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.function.Function;
import java.util.function.LongFunction;
public abstract class MilvusBaseOp<T> implements CycleOp<Object> {
protected final static Logger logger = LogManager.getLogger(MilvusBaseOp.class);
protected final MilvusServiceClient client;
protected final T request;
protected final LongFunction<Object> apiCall;
public MilvusBaseOp(MilvusServiceClient client, T requestParam) {
this.client = client;
this.request = requestParam;
this.apiCall = this::applyOp;
}
public MilvusBaseOp(MilvusServiceClient client, T requestParam, LongFunction<Object> call) {
this.client = client;
this.request = requestParam;
this.apiCall = call;
}
@Override
public final Object apply(long value) {
logger.trace("applying op: " + this);
try {
Object result = applyOp(value);
if (result instanceof R<?> r) {
var error = r.getException();
if (error!=null) {
throw error;
}
} else {
logger.warn("Op '" + this.toString() + "' did not return a Result 'R' type." +
" Exception handling will be bypassed"
);
}
return result;
} catch (Exception e) {
if (e instanceof RuntimeException rte) {
throw rte;
} else {
throw new RuntimeException(e);
}
}
};
public abstract Object applyOp(long value);
@Override
public String toString() {
return "MilvusOp(" + this.request.getClass().getSimpleName() + ")";
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.bulkinsert.BulkInsertParam;
public class MilvusBulkInsertOp extends MilvusBaseOp<BulkInsertParam> {
public MilvusBulkInsertOp(MilvusServiceClient client, BulkInsertParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.bulkInsert(request);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.alias.CreateAliasParam;
public class MilvusCreateAliasOp extends MilvusBaseOp<CreateAliasParam> {
public MilvusCreateAliasOp(MilvusServiceClient client, CreateAliasParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.createAlias(request);
}
}

View File

@@ -0,0 +1,41 @@
/*
* 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.param.R;
import io.milvus.param.RpcStatus;
import io.milvus.param.collection.CreateCollectionParam;
import io.nosqlbench.adapters.api.templating.ParsedOp;
public class MilvusCreateCollectionOp extends MilvusBaseOp<CreateCollectionParam> {
/**
* Create a new {@link ParsedOp} encapsulating a call to the Milvus/Zilliz client delete method
*
* @param client The associated {@link MilvusServiceClient} used to communicate with the database
* @param request The {@link CreateCollectionParam} built for this operation
*/
public MilvusCreateCollectionOp(MilvusServiceClient client, CreateCollectionParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
R<RpcStatus> collection = client.createCollection(request);
return collection;
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.credential.CreateCredentialParam;
public class MilvusCreateCredentialOp extends MilvusBaseOp<CreateCredentialParam> {
public MilvusCreateCredentialOp(MilvusServiceClient client, CreateCredentialParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.createCredential(request);
}
}

View File

@@ -0,0 +1,34 @@
/*
* 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.param.R;
import io.milvus.param.RpcStatus;
import io.milvus.param.collection.CreateDatabaseParam;
public class MilvusCreateDatabaseOp extends MilvusBaseOp<CreateDatabaseParam> {
public MilvusCreateDatabaseOp(MilvusServiceClient client, CreateDatabaseParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
R<RpcStatus> database = client.createDatabase(request);
return database;
}
}

View File

@@ -0,0 +1,34 @@
/*
* 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.param.R;
import io.milvus.param.RpcStatus;
import io.milvus.param.index.CreateIndexParam;
public class MilvusCreateIndexOp extends MilvusBaseOp<CreateIndexParam> {
public MilvusCreateIndexOp(MilvusServiceClient client, CreateIndexParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
R<RpcStatus> result = client.createIndex(request);
return result;
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.partition.CreatePartitionParam;
public class MilvusCreatePartitionOp extends MilvusBaseOp<CreatePartitionParam> {
public MilvusCreatePartitionOp(MilvusServiceClient client, CreatePartitionParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.createPartition(request);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.credential.DeleteCredentialParam;
public class MilvusDeleteCredentialOp extends MilvusBaseOp<DeleteCredentialParam> {
public MilvusDeleteCredentialOp(MilvusServiceClient client, DeleteCredentialParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.deleteCredential(request);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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;
public class MilvusDeleteParamOp extends MilvusBaseOp<io.milvus.param.dml.DeleteParam> {
public MilvusDeleteParamOp(MilvusServiceClient client, io.milvus.param.dml.DeleteParam request) {
super(client,request);
}
@Override
public Object applyOp(long value) {
return client.delete(this.request);
}
}

View File

@@ -0,0 +1,34 @@
/*
* 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.DescribeCollectionResponse;
import io.milvus.param.R;
import io.milvus.param.collection.DescribeCollectionParam;
public class MilvusDescribeCollectionOp extends MilvusBaseOp<DescribeCollectionParam> {
public MilvusDescribeCollectionOp(MilvusServiceClient client, DescribeCollectionParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
R<DescribeCollectionResponse> describeCollectionResponseR = client.describeCollection(request);
return describeCollectionResponseR;
}
}

View File

@@ -0,0 +1,104 @@
/*
* 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.DescribeIndexResponse;
import io.milvus.grpc.IndexDescription;
import io.milvus.param.R;
import io.milvus.param.index.DescribeIndexParam;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.OpGenerator;
import io.nosqlbench.adapters.api.scheduling.TimeoutPredicate;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
public class MilvusDescribeIndexOp extends MilvusBaseOp<DescribeIndexParam> implements OpGenerator {
private final Duration timeout;
private final Duration interval;
private final TimeoutPredicate<Integer> timeoutPredicate;
private MilvusDescribeIndexOp nextOp;
private long lastAttemptAt = 0L;
public MilvusDescribeIndexOp(
MilvusServiceClient client,
DescribeIndexParam request,
Duration timeout,
Duration interval
) {
super(client, request);
this.timeout = timeout;
this.interval = interval;
this.timeoutPredicate = TimeoutPredicate.of(p -> p>=100, timeout, interval, true);
}
@Override
public Object applyOp(long value) {
nextOp = null;
timeoutPredicate.blockUntilNextInterval();
R<DescribeIndexResponse> describeIndexResponseR = client.describeIndex(request);
DescribeIndexResponse data = describeIndexResponseR.getData();
TimeoutPredicate.Result<Integer> result = timeoutPredicate.test(getIndexStats(data).percent());
String message = result.status().name() + " await state " + result.value() + " at time " + result.timeSummary();
logger.info(message);
if (result.isPending()) {
this.nextOp=this;
}
return describeIndexResponseR;
}
private IndexStats getIndexStats(DescribeIndexResponse data) {
var stats = new ArrayList<IndexStat>();
for (IndexDescription desc : data.getIndexDescriptionsList()) {
stats.add(new IndexStat(desc.getIndexName(), desc.getIndexedRows(), desc.getPendingIndexRows()));
}
return new IndexStats(stats);
}
public static class IndexStats extends ArrayList<IndexStat> {
public IndexStats(List<IndexStat> stats) {
super(stats);
}
public int percent() {
return stream().mapToInt(IndexStat::percent).min().orElse(0);
}
}
public record IndexStat(
String index_name,
long indexed_rows,
long pending_rows
) {
public int percent() {
if (pending_rows == 0) {
return 100;
}
return (int) (100.0d * ((double) indexed_rows / (double) (indexed_rows + pending_rows)));
}
}
@Override
public Op getNextOp() {
return nextOp;
}
}

View File

@@ -0,0 +1,32 @@
/*
* 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.param.alias.CreateAliasParam;
import io.milvus.param.alias.DropAliasParam;
public class MilvusDropAliasOp extends MilvusBaseOp<DropAliasParam> {
public MilvusDropAliasOp(MilvusServiceClient client, DropAliasParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.dropAlias(request);
}
}

View File

@@ -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.param.collection.DropCollectionParam;
import io.nosqlbench.adapters.api.templating.ParsedOp;
public class MilvusDropCollectionOp extends MilvusBaseOp<DropCollectionParam> {
/**
* Create a new {@link ParsedOp} encapsulating a call to the Milvus/Zilliz client delete method
*
* @param client The associated {@link MilvusServiceClient} used to communicate with the database
* @param request The {@link DropCollectionParam} built for this operation
*/
public MilvusDropCollectionOp(MilvusServiceClient client, DropCollectionParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.dropCollection(request);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.collection.DropDatabaseParam;
public class MilvusDropDatabaseOp extends MilvusBaseOp<DropDatabaseParam> {
public MilvusDropDatabaseOp(MilvusServiceClient client, DropDatabaseParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.dropDatabase(request);
}
}

View File

@@ -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.param.index.DropIndexParam;
import io.nosqlbench.adapters.api.templating.ParsedOp;
public class MilvusDropIndexOp extends MilvusBaseOp<DropIndexParam> {
/**
* Create a new {@link ParsedOp} encapsulating a call to the Milvus/Zilliz client delete method
*
* @param client The associated {@link MilvusServiceClient} used to communicate with the database
* @param request The {@link DropIndexParam} built for this operation
*/
public MilvusDropIndexOp(MilvusServiceClient client, DropIndexParam request) {
super(client,request);
}
@Override
public Object applyOp(long value) {
return client.dropIndex(request);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.partition.DropPartitionParam;
public class MilvusDropPartitionOp extends MilvusBaseOp<DropPartitionParam> {
public MilvusDropPartitionOp(MilvusServiceClient client, DropPartitionParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.dropPartition(request);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.collection.FlushParam;
public class MilvusFlushOp extends MilvusBaseOp<FlushParam> {
public MilvusFlushOp(MilvusServiceClient client, FlushParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.flush(request);
}
}

View File

@@ -0,0 +1,32 @@
/*
* 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.param.bulkinsert.GetBulkInsertStateParam;
import io.milvus.param.collection.GetCollectionStatisticsParam;
public class MilvusGetBulkInsertStateOp extends MilvusBaseOp<GetBulkInsertStateParam> {
public MilvusGetBulkInsertStateOp(MilvusServiceClient client, GetBulkInsertStateParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.getBulkInsertState(request);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.collection.GetCollectionStatisticsParam;
public class MilvusGetCollectionStatisticsOp extends MilvusBaseOp<GetCollectionStatisticsParam> {
public MilvusGetCollectionStatisticsOp(MilvusServiceClient client, GetCollectionStatisticsParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.getCollectionStatistics(request);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.control.GetCompactionStateParam;
public class MilvusGetCompactionStateOp extends MilvusBaseOp<GetCompactionStateParam> {
public MilvusGetCompactionStateOp(MilvusServiceClient client, GetCompactionStateParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.getCompactionState(request);
}
}

View File

@@ -0,0 +1,32 @@
/*
* 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.param.control.GetCompactionPlansParam;
import io.milvus.param.control.GetCompactionStateParam;
public class MilvusGetCompactionStateWithPlansOp extends MilvusBaseOp<GetCompactionPlansParam> {
public MilvusGetCompactionStateWithPlansOp(MilvusServiceClient client, GetCompactionPlansParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.getCompactionStateWithPlans(request);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.control.GetFlushAllStateParam;
public class MilvusGetFlushAllStateOp extends MilvusBaseOp<GetFlushAllStateParam> {
public MilvusGetFlushAllStateOp(MilvusServiceClient client, GetFlushAllStateParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.getFlushAllState(request);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.control.GetFlushStateParam;
public class MilvusGetFlushStateOp extends MilvusBaseOp<GetFlushStateParam> {
public MilvusGetFlushStateOp(MilvusServiceClient client, GetFlushStateParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.getFlushState(request);
}
}

View File

@@ -0,0 +1,43 @@
/*
* 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 com.google.protobuf.DescriptorProtos;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.util.JsonFormat;
import io.milvus.client.MilvusServiceClient;
import io.milvus.grpc.GetIndexBuildProgressResponse;
import io.milvus.param.R;
import io.milvus.param.index.GetIndexBuildProgressParam;
public class MilvusGetIndexBuildProgressOp extends MilvusBaseOp<GetIndexBuildProgressParam> {
public MilvusGetIndexBuildProgressOp(MilvusServiceClient client, GetIndexBuildProgressParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
R<GetIndexBuildProgressResponse> indexBuildProgress = client.getIndexBuildProgress(request);
GetIndexBuildProgressResponse r = indexBuildProgress.getData();
try {
String responseJson = JsonFormat.printer().print(r);
return responseJson;
} catch (InvalidProtocolBufferException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.index.GetIndexStateParam;
public class MilvusGetIndexStateOp extends MilvusBaseOp<GetIndexStateParam> {
public MilvusGetIndexStateOp(MilvusServiceClient client, GetIndexStateParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.getIndexState(request);
}
}

View File

@@ -0,0 +1,71 @@
/*
* 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.GetLoadStateResponse;
import io.milvus.grpc.LoadState;
import io.milvus.param.R;
import io.milvus.param.collection.GetLoadStateParam;
import io.nosqlbench.adapter.milvus.exceptions.MilvusAwaitStateIncompleteError;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.OpGenerator;
import io.nosqlbench.adapters.api.scheduling.TimeoutPredicate;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.concurrent.locks.LockSupport;
public class MilvusGetLoadStateOp extends MilvusBaseOp<GetLoadStateParam> implements OpGenerator {
private final TimeoutPredicate<LoadState> timeoutPredicate;
private int tried;
private MilvusGetLoadStateOp nextOp;
private long lastAttemptAt = 0L;
public MilvusGetLoadStateOp(
MilvusServiceClient client,
GetLoadStateParam request,
LoadState awaitState,
Duration timeout,
Duration interval
) {
super(client, request);
this.timeoutPredicate = TimeoutPredicate.of(s -> s==awaitState, timeout, interval, true);
}
@Override
public Object applyOp(long value) {
this.nextOp = null;
timeoutPredicate.blockUntilNextInterval();
R<GetLoadStateResponse> getLoadStateResponse = client.getLoadState(request);
TimeoutPredicate.Result<LoadState> result = timeoutPredicate.test(getLoadStateResponse.getData().getState());
String message = result.status().name() + " await state " + result.value() + " at time " + result.timeSummary();
logger.info(message);
if (result.status()== TimeoutPredicate.Status.pending) {
nextOp=this;
}
return getLoadStateResponse;
}
@Override
public Op getNextOp() {
return this.nextOp;
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.collection.GetLoadingProgressParam;
public class MilvusGetLoadingProgressOp extends MilvusBaseOp<GetLoadingProgressParam> {
public MilvusGetLoadingProgressOp(MilvusServiceClient client, GetLoadingProgressParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.getLoadingProgress(request);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.control.GetMetricsParam;
public class MilvusGetMetricsOp extends MilvusBaseOp<GetMetricsParam> {
public MilvusGetMetricsOp(MilvusServiceClient client, GetMetricsParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.getMetrics(request);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.highlevel.dml.GetIdsParam;
public class MilvusGetOp extends MilvusBaseOp<GetIdsParam> {
public MilvusGetOp(MilvusServiceClient client, GetIdsParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.get(request);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.partition.GetPartitionStatisticsParam;
public class MilvusGetPartitionStatisticsOp extends MilvusBaseOp<GetPartitionStatisticsParam> {
public MilvusGetPartitionStatisticsOp(MilvusServiceClient client, GetPartitionStatisticsParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.getPartitionStatistics(request);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.control.GetQuerySegmentInfoParam;
public class MilvusGetPersistentSegmentInfoOp extends MilvusBaseOp<GetQuerySegmentInfoParam> {
public MilvusGetPersistentSegmentInfoOp(MilvusServiceClient client, GetQuerySegmentInfoParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.getQuerySegmentInfo(request);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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.param.control.GetQuerySegmentInfoParam;
public class MilvusGetQuerySegmentInfoOp extends MilvusBaseOp<GetQuerySegmentInfoParam> {
public MilvusGetQuerySegmentInfoOp(MilvusServiceClient client, GetQuerySegmentInfoParam request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
return client.getQuerySegmentInfo(request);
}
}

Some files were not shown because too many files have changed in this diff Show More