mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-12-22 15:13:41 -06:00
name all opensearch code files as AOS...
This commit is contained in:
parent
6ec7d34eee
commit
f92a71a81c
@ -19,7 +19,6 @@ package io.nosqlbench.adapter.opensearch;
|
||||
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.adapters.api.activityimpl.uniform.DriverSpaceCache;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
import io.nosqlbench.nb.api.components.core.NBComponent;
|
||||
@ -30,23 +29,23 @@ import io.nosqlbench.nb.api.labels.NBLabels;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service(value= DriverAdapter.class, selector = "opensearch")
|
||||
public class OpenSearchAdapter extends BaseDriverAdapter<Op,OpenSearchSpace> {
|
||||
public OpenSearchAdapter(NBComponent parentComponent, NBLabels labels) {
|
||||
public class AOSAdapter extends BaseDriverAdapter<Op, AOSSpace> {
|
||||
public AOSAdapter(NBComponent parentComponent, NBLabels labels) {
|
||||
super(parentComponent, labels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function<String, ? extends OpenSearchSpace> getSpaceInitializer(NBConfiguration cfg) {
|
||||
return (String spaceName) -> new OpenSearchSpace(cfg);
|
||||
public Function<String, ? extends AOSSpace> getSpaceInitializer(NBConfiguration cfg) {
|
||||
return (String spaceName) -> new AOSSpace(cfg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpMapper<Op> getOpMapper() {
|
||||
return new OpenSearchOpMapper(this);
|
||||
return new AOSOpMapper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBConfigModel getConfigModel() {
|
||||
return super.getConfigModel().add(OpenSearchSpace.getConfigModel());
|
||||
return super.getConfigModel().add(AOSSpace.getConfigModel());
|
||||
}
|
||||
}
|
@ -22,9 +22,9 @@ import io.nosqlbench.nb.api.components.core.NBComponent;
|
||||
import io.nosqlbench.nb.api.labels.NBLabels;
|
||||
|
||||
@Service(value = DriverAdapterLoader.class,selector = "opensearch")
|
||||
public class OpenSearchAdapterLoader implements DriverAdapterLoader {
|
||||
public class AOSAdapterLoader implements DriverAdapterLoader {
|
||||
@Override
|
||||
public OpenSearchAdapter load(NBComponent parent, NBLabels childLabels) {
|
||||
return new OpenSearchAdapter(parent, childLabels);
|
||||
public AOSAdapter load(NBComponent parent, NBLabels childLabels) {
|
||||
return new AOSAdapter(parent, childLabels);
|
||||
}
|
||||
}
|
@ -17,35 +17,31 @@
|
||||
package io.nosqlbench.adapter.opensearch;
|
||||
|
||||
import io.nosqlbench.adapter.opensearch.dispensers.*;
|
||||
import io.nosqlbench.adapter.opensearch.ops.UpdateOp;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverSpaceCache;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
import io.nosqlbench.engine.api.templating.TypeAndTarget;
|
||||
import io.nosqlbench.nb.api.config.standard.NBConfiguration;
|
||||
import org.opensearch.client.opensearch.OpenSearchClient;
|
||||
|
||||
public class OpenSearchOpMapper implements OpMapper<Op> {
|
||||
private final OpenSearchAdapter adapter;
|
||||
public class AOSOpMapper implements OpMapper<Op> {
|
||||
private final AOSAdapter adapter;
|
||||
|
||||
public OpenSearchOpMapper(OpenSearchAdapter openSearchAdapter) {
|
||||
this.adapter = openSearchAdapter;
|
||||
public AOSOpMapper(AOSAdapter AOSAdapter) {
|
||||
this.adapter = AOSAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpDispenser<? extends Op> apply(ParsedOp op) {
|
||||
TypeAndTarget<OpenSearchOpTypes, String> typeAndTarget =
|
||||
op.getTypeAndTarget(OpenSearchOpTypes.class, String.class, "verb", "index");
|
||||
TypeAndTarget<AOSOpTypes, String> typeAndTarget =
|
||||
op.getTypeAndTarget(AOSOpTypes.class, String.class, "verb", "index");
|
||||
return switch (typeAndTarget.enumId) {
|
||||
case create_index -> new CreateIndexOpDispenser(adapter, op, typeAndTarget.targetFunction);
|
||||
case delete_index -> new DeleteIndexOpDispenser(adapter, op, typeAndTarget.targetFunction);
|
||||
case index -> new IndexOpDispenser(adapter,op, typeAndTarget.targetFunction);
|
||||
case update -> new UpdateOpDispenser(adapter,op, typeAndTarget.targetFunction);
|
||||
case delete -> new DeleteOpDispenser(adapter,op, typeAndTarget.targetFunction);
|
||||
case knn_search -> new KnnSearchOpDispenser(adapter,op, typeAndTarget.targetFunction);
|
||||
case bulk -> new BulkOpDispenser(adapter, op, typeAndTarget.targetFunction);
|
||||
case create_index -> new AOSCreateIndexOpDispenser(adapter, op, typeAndTarget.targetFunction);
|
||||
case delete_index -> new AOSDeleteIndexOpDispenser(adapter, op, typeAndTarget.targetFunction);
|
||||
case index -> new AOSIndexOpDispenser(adapter,op, typeAndTarget.targetFunction);
|
||||
case update -> new AOSUpdateOpDispenser(adapter,op, typeAndTarget.targetFunction);
|
||||
case delete -> new AOSDeleteOpDispenser(adapter,op, typeAndTarget.targetFunction);
|
||||
case knn_search -> new AOSKnnSearchOpDispenser(adapter,op, typeAndTarget.targetFunction);
|
||||
case bulk -> new AOSBulkOpDispenser(adapter, op, typeAndTarget.targetFunction);
|
||||
default -> throw new RuntimeException("Unrecognized op type '" + typeAndTarget.enumId.name() + "' while " +
|
||||
"mapping parsed op " + op);
|
||||
};
|
@ -16,7 +16,7 @@
|
||||
|
||||
package io.nosqlbench.adapter.opensearch;
|
||||
|
||||
public enum OpenSearchOpTypes {
|
||||
public enum AOSOpTypes {
|
||||
create_index,
|
||||
delete_index,
|
||||
index,
|
@ -16,7 +16,7 @@
|
||||
|
||||
package io.nosqlbench.adapter.opensearch;
|
||||
|
||||
public enum AwsOsServiceType {
|
||||
public enum AOSServiceType {
|
||||
aoss,
|
||||
es
|
||||
}
|
@ -17,10 +17,6 @@
|
||||
package io.nosqlbench.adapter.opensearch;
|
||||
|
||||
|
||||
import com.amazonaws.auth.BasicAWSCredentials;
|
||||
import com.amazonaws.auth.profile.internal.BasicProfile;
|
||||
import com.amazonaws.auth.profile.internal.ProfileKeyConstants;
|
||||
import com.amazonaws.auth.profile.internal.ProfileStaticCredentialsProvider;
|
||||
import io.nosqlbench.nb.api.config.standard.ConfigModel;
|
||||
import io.nosqlbench.nb.api.config.standard.NBConfigModel;
|
||||
import io.nosqlbench.nb.api.config.standard.NBConfiguration;
|
||||
@ -35,14 +31,13 @@ import software.amazon.awssdk.http.crt.AwsCrtAsyncHttpClient;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
public class OpenSearchSpace implements AutoCloseable {
|
||||
public class AOSSpace implements AutoCloseable {
|
||||
|
||||
private final NBConfiguration cfg;
|
||||
protected OpenSearchClient client;
|
||||
|
||||
public OpenSearchSpace(NBConfiguration cfg) {
|
||||
public AOSSpace(NBConfiguration cfg) {
|
||||
this.cfg = cfg;
|
||||
}
|
||||
|
||||
@ -75,7 +70,7 @@ public class OpenSearchSpace implements AutoCloseable {
|
||||
|
||||
AwsSdk2TransportOptions transportOptions = transportOptionsBuilder.build();
|
||||
|
||||
AwsOsServiceType svctype = AwsOsServiceType.valueOf(cfg.get("svctype"));
|
||||
AOSServiceType svctype = AOSServiceType.valueOf(cfg.get("svctype"));
|
||||
|
||||
AwsSdk2Transport awsSdk2Transport =
|
||||
new AwsSdk2Transport(
|
||||
@ -101,7 +96,7 @@ public class OpenSearchSpace implements AutoCloseable {
|
||||
}
|
||||
|
||||
public static NBConfigModel getConfigModel() {
|
||||
return ConfigModel.of(OpenSearchSpace.class)
|
||||
return ConfigModel.of(AOSSpace.class)
|
||||
.add(Param.required("region", String.class).setDescription("The region to connect to"))
|
||||
.add(Param.required("host", String.class).setDescription("The Open Search API endpoint host"))
|
||||
.add(Param.optional("profile")
|
@ -20,7 +20,7 @@ import io.nosqlbench.adapter.opensearch.pojos.Doc;
|
||||
import org.opensearch.client.opensearch.core.SearchResponse;
|
||||
import org.opensearch.client.opensearch.core.search.Hit;
|
||||
|
||||
public class Utils {
|
||||
public class AOSUtils {
|
||||
|
||||
public static int[] DocHitsToIntIndicesArray(SearchResponse<Doc> response) {
|
||||
int[] indices = response.hits().hits()
|
@ -16,8 +16,8 @@
|
||||
|
||||
package io.nosqlbench.adapter.opensearch.dispensers;
|
||||
|
||||
import io.nosqlbench.adapter.opensearch.OpenSearchAdapter;
|
||||
import io.nosqlbench.adapter.opensearch.OpenSearchSpace;
|
||||
import io.nosqlbench.adapter.opensearch.AOSAdapter;
|
||||
import io.nosqlbench.adapter.opensearch.AOSSpace;
|
||||
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
@ -25,12 +25,12 @@ import org.opensearch.client.opensearch.OpenSearchClient;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public abstract class BaseOpenSearchOpDispenser extends BaseOpDispenser<Op,Object> {
|
||||
protected final LongFunction<OpenSearchSpace> spaceF;
|
||||
public abstract class AOSBaseOpDispenser extends BaseOpDispenser<Op,Object> {
|
||||
protected final LongFunction<AOSSpace> spaceF;
|
||||
protected final LongFunction<OpenSearchClient> clientF;
|
||||
private final LongFunction<? extends Op> opF;
|
||||
|
||||
protected BaseOpenSearchOpDispenser(OpenSearchAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
|
||||
protected AOSBaseOpDispenser(AOSAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
|
||||
super(adapter, op);
|
||||
this.spaceF =adapter.getSpaceFunc(op);
|
||||
this.clientF = (long l) -> this.spaceF.apply(l).getClient();
|
@ -18,34 +18,19 @@ package io.nosqlbench.adapter.opensearch.dispensers;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import io.nosqlbench.adapter.opensearch.OpenSearchAdapter;
|
||||
import io.nosqlbench.adapter.opensearch.ops.BulkOp;
|
||||
import io.nosqlbench.adapter.opensearch.ops.IndexOp;
|
||||
import io.nosqlbench.adapters.api.activityconfig.rawyaml.RawOpDef;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpDef;
|
||||
import io.nosqlbench.adapters.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.adapter.opensearch.AOSAdapter;
|
||||
import io.nosqlbench.adapter.opensearch.ops.AOSBulkOp;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
import io.nosqlbench.engine.api.templating.TypeAndTarget;
|
||||
import io.nosqlbench.nb.api.errors.OpConfigError;
|
||||
import org.opensearch.client.opensearch.OpenSearchClient;
|
||||
import org.opensearch.client.opensearch._types.OpType;
|
||||
import org.opensearch.client.opensearch._types.Refresh;
|
||||
import org.opensearch.client.opensearch._types.VersionType;
|
||||
import org.opensearch.client.opensearch.core.BulkRequest;
|
||||
import org.opensearch.client.opensearch.core.IndexRequest;
|
||||
import org.snakeyaml.engine.v2.api.lowlevel.Parse;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class BulkOpDispenser extends BaseOpenSearchOpDispenser {
|
||||
public class AOSBulkOpDispenser extends AOSBaseOpDispenser {
|
||||
private static Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
public BulkOpDispenser(OpenSearchAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
|
||||
public AOSBulkOpDispenser(AOSAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
|
||||
super(adapter, op, targetF);
|
||||
}
|
||||
|
||||
@ -55,8 +40,8 @@ public class BulkOpDispenser extends BaseOpenSearchOpDispenser {
|
||||
ParsedOp op,
|
||||
LongFunction<String> targetF
|
||||
) {
|
||||
LongFunction<BulkRequest> func = OpenSearchRequests.bulk(op,targetF);
|
||||
return l -> new BulkOp(clientF.apply(l), func.apply(l));
|
||||
LongFunction<BulkRequest> func = AOSRequests.bulk(op,targetF);
|
||||
return l -> new AOSBulkOp(clientF.apply(l), func.apply(l));
|
||||
}
|
||||
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
|
||||
package io.nosqlbench.adapter.opensearch.dispensers;
|
||||
|
||||
public enum BulkOpTypes {
|
||||
public enum AOSBulkOpTypes {
|
||||
create,
|
||||
index,
|
||||
delete,
|
@ -16,26 +16,25 @@
|
||||
|
||||
package io.nosqlbench.adapter.opensearch.dispensers;
|
||||
|
||||
import io.nosqlbench.adapter.opensearch.OpenSearchAdapter;
|
||||
import io.nosqlbench.adapter.opensearch.ops.CreateIndexOp;
|
||||
import io.nosqlbench.adapter.opensearch.AOSAdapter;
|
||||
import io.nosqlbench.adapter.opensearch.ops.AOSCreateIndexOp;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
import org.opensearch.client.json.JsonData;
|
||||
import org.opensearch.client.opensearch.OpenSearchClient;
|
||||
import org.opensearch.client.opensearch._types.mapping.*;
|
||||
import org.opensearch.client.opensearch.indices.CreateIndexRequest;
|
||||
import org.opensearch.client.opensearch.indices.IndexSettings;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class CreateIndexOpDispenser extends BaseOpenSearchOpDispenser {
|
||||
public class AOSCreateIndexOpDispenser extends AOSBaseOpDispenser {
|
||||
|
||||
private final ParsedOp pop;
|
||||
private final int dimensions;
|
||||
private final int ef_construction;
|
||||
private final int m;
|
||||
|
||||
public CreateIndexOpDispenser(OpenSearchAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
|
||||
public AOSCreateIndexOpDispenser(AOSAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
|
||||
super(adapter, op, targetF);
|
||||
this.pop = op;
|
||||
this.dimensions = pop.getStaticValue("dimensions",Integer.class).intValue();
|
||||
@ -44,8 +43,8 @@ public class CreateIndexOpDispenser extends BaseOpenSearchOpDispenser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public LongFunction<CreateIndexOp> createOpFunc(LongFunction<OpenSearchClient> clientF, ParsedOp op,
|
||||
LongFunction<String> targetF) {
|
||||
public LongFunction<AOSCreateIndexOp> createOpFunc(LongFunction<OpenSearchClient> clientF, ParsedOp op,
|
||||
LongFunction<String> targetF) {
|
||||
CreateIndexRequest.Builder eb = new CreateIndexRequest.Builder();
|
||||
LongFunction<CreateIndexRequest.Builder> bfunc =
|
||||
l -> new CreateIndexRequest.Builder()
|
||||
@ -54,7 +53,7 @@ public class CreateIndexOpDispenser extends BaseOpenSearchOpDispenser {
|
||||
bfunc = op.enhanceFunc(bfunc, "mappings", Map.class, this::resolveTypeMapping);
|
||||
|
||||
LongFunction<CreateIndexRequest.Builder> finalBfunc = bfunc;
|
||||
return (long l) -> new CreateIndexOp(clientF.apply(l), finalBfunc.apply(l).build());
|
||||
return (long l) -> new AOSCreateIndexOp(clientF.apply(l), finalBfunc.apply(l).build());
|
||||
}
|
||||
|
||||
// https://opensearch.org/docs/latest/search-plugins/knn/knn-index/
|
@ -16,26 +16,25 @@
|
||||
|
||||
package io.nosqlbench.adapter.opensearch.dispensers;
|
||||
|
||||
import io.nosqlbench.adapter.opensearch.OpenSearchAdapter;
|
||||
import io.nosqlbench.adapter.opensearch.ops.DeleteIndexOp;
|
||||
import io.nosqlbench.adapter.opensearch.AOSAdapter;
|
||||
import io.nosqlbench.adapter.opensearch.ops.AOSDeleteIndexOp;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
import org.opensearch.client.opensearch.OpenSearchClient;
|
||||
import org.opensearch.client.opensearch.indices.DeleteIndexRequest;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class DeleteIndexOpDispenser extends BaseOpenSearchOpDispenser {
|
||||
public class AOSDeleteIndexOpDispenser extends AOSBaseOpDispenser {
|
||||
|
||||
public DeleteIndexOpDispenser(OpenSearchAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
|
||||
public AOSDeleteIndexOpDispenser(AOSAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
|
||||
super(adapter, op, targetF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LongFunction<DeleteIndexOp> createOpFunc(LongFunction<OpenSearchClient> clientF, ParsedOp op, LongFunction<String> targetF) {
|
||||
public LongFunction<AOSDeleteIndexOp> createOpFunc(LongFunction<OpenSearchClient> clientF, ParsedOp op, LongFunction<String> targetF) {
|
||||
DeleteIndexRequest.Builder eb = new DeleteIndexRequest.Builder();
|
||||
LongFunction<DeleteIndexRequest.Builder> f =
|
||||
l -> new DeleteIndexRequest.Builder().index(targetF.apply(l));
|
||||
return l -> new DeleteIndexOp(clientF.apply(l),f.apply(1).build());
|
||||
return l -> new AOSDeleteIndexOp(clientF.apply(l),f.apply(1).build());
|
||||
}
|
||||
}
|
@ -16,30 +16,25 @@
|
||||
|
||||
package io.nosqlbench.adapter.opensearch.dispensers;
|
||||
|
||||
import io.nosqlbench.adapter.opensearch.OpenSearchAdapter;
|
||||
import io.nosqlbench.adapter.opensearch.ops.CreateIndexOp;
|
||||
import io.nosqlbench.adapter.opensearch.ops.DeleteOp;
|
||||
import io.nosqlbench.adapter.opensearch.AOSAdapter;
|
||||
import io.nosqlbench.adapter.opensearch.ops.AOSDeleteOp;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
import org.opensearch.client.json.JsonData;
|
||||
import org.opensearch.client.opensearch.OpenSearchClient;
|
||||
import org.opensearch.client.opensearch._types.mapping.*;
|
||||
import org.opensearch.client.opensearch.core.DeleteRequest;
|
||||
import org.opensearch.client.opensearch.indices.CreateIndexRequest;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class DeleteOpDispenser extends BaseOpenSearchOpDispenser {
|
||||
public class AOSDeleteOpDispenser extends AOSBaseOpDispenser {
|
||||
|
||||
public DeleteOpDispenser(OpenSearchAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
|
||||
public AOSDeleteOpDispenser(AOSAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
|
||||
super(adapter, op, targetF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LongFunction<DeleteOp> createOpFunc(LongFunction<OpenSearchClient> clientF, ParsedOp op, LongFunction<String> targetF) {
|
||||
public LongFunction<AOSDeleteOp> createOpFunc(LongFunction<OpenSearchClient> clientF, ParsedOp op, LongFunction<String> targetF) {
|
||||
DeleteRequest.Builder eb = new DeleteRequest.Builder();
|
||||
LongFunction<DeleteRequest.Builder> bfunc = l -> new DeleteRequest.Builder().index(targetF.apply(l));
|
||||
return (long l) -> new DeleteOp(clientF.apply(l), bfunc.apply(l).build());
|
||||
return (long l) -> new AOSDeleteOp(clientF.apply(l), bfunc.apply(l).build());
|
||||
}
|
||||
|
||||
}
|
@ -18,8 +18,8 @@ package io.nosqlbench.adapter.opensearch.dispensers;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import io.nosqlbench.adapter.opensearch.OpenSearchAdapter;
|
||||
import io.nosqlbench.adapter.opensearch.ops.IndexOp;
|
||||
import io.nosqlbench.adapter.opensearch.AOSAdapter;
|
||||
import io.nosqlbench.adapter.opensearch.ops.AOSIndexOp;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@ -29,20 +29,20 @@ import org.opensearch.client.opensearch.core.IndexRequest;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class IndexOpDispenser extends BaseOpenSearchOpDispenser {
|
||||
private final static Logger logger = LogManager.getLogger(IndexOpDispenser.class);
|
||||
public class AOSIndexOpDispenser extends AOSBaseOpDispenser {
|
||||
private final static Logger logger = LogManager.getLogger(AOSIndexOpDispenser.class);
|
||||
private static Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
private final String diag;
|
||||
|
||||
public IndexOpDispenser(OpenSearchAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
|
||||
public AOSIndexOpDispenser(AOSAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
|
||||
super(adapter, op, targetF);
|
||||
this.diag = op.getStaticConfigOr("daig","false");
|
||||
}
|
||||
|
||||
@Override
|
||||
public LongFunction<? extends Op> createOpFunc(LongFunction<OpenSearchClient> clientF, ParsedOp op, LongFunction<String> targetF) {
|
||||
LongFunction<IndexRequest> irqF = OpenSearchRequests.index(op);
|
||||
return l -> new IndexOp(clientF.apply(l), irqF.apply(l));
|
||||
LongFunction<IndexRequest> irqF = AOSRequests.index(op);
|
||||
return l -> new AOSIndexOp(clientF.apply(l), irqF.apply(l));
|
||||
}
|
||||
|
||||
}
|
@ -16,9 +16,8 @@
|
||||
|
||||
package io.nosqlbench.adapter.opensearch.dispensers;
|
||||
|
||||
import io.nosqlbench.adapter.opensearch.OpenSearchAdapter;
|
||||
import io.nosqlbench.adapter.opensearch.ops.KnnSearchOp;
|
||||
import io.nosqlbench.adapter.opensearch.pojos.Doc;
|
||||
import io.nosqlbench.adapter.opensearch.AOSAdapter;
|
||||
import io.nosqlbench.adapter.opensearch.ops.AOSKnnSearchOp;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
import org.opensearch.client.json.JsonData;
|
||||
import org.opensearch.client.opensearch.OpenSearchClient;
|
||||
@ -32,10 +31,10 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class KnnSearchOpDispenser extends BaseOpenSearchOpDispenser {
|
||||
public class AOSKnnSearchOpDispenser extends AOSBaseOpDispenser {
|
||||
private Class<?> schemaClass;
|
||||
|
||||
public KnnSearchOpDispenser(OpenSearchAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
|
||||
public AOSKnnSearchOpDispenser(AOSAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
|
||||
super(adapter, op, targetF);
|
||||
String schemaClassStr = op.getStaticConfigOr("schema", "io.nosqlbench.adapter.opensearch.pojos.Doc");
|
||||
try {
|
||||
@ -46,7 +45,7 @@ public class KnnSearchOpDispenser extends BaseOpenSearchOpDispenser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public LongFunction<KnnSearchOp> createOpFunc(LongFunction<OpenSearchClient> clientF, ParsedOp op,LongFunction<String> targetF) {
|
||||
public LongFunction<AOSKnnSearchOp> createOpFunc(LongFunction<OpenSearchClient> clientF, ParsedOp op, LongFunction<String> targetF) {
|
||||
LongFunction<KnnQuery.Builder> knnfunc = l -> new KnnQuery.Builder();
|
||||
knnfunc = op.enhanceFuncOptionally(knnfunc, "k",Integer.class, KnnQuery.Builder::k);
|
||||
knnfunc = op.enhanceFuncOptionally(knnfunc, "vector", List.class, this::convertVector);
|
||||
@ -64,7 +63,7 @@ public class KnnSearchOpDispenser extends BaseOpenSearchOpDispenser {
|
||||
.index(targetF.apply(l))
|
||||
.query(new Query.Builder().knn(finalKnnfunc.apply(l).build()).build());
|
||||
|
||||
return (long l) -> new KnnSearchOp(clientF.apply(l), bfunc.apply(l).build(), schemaClass);
|
||||
return (long l) -> new AOSKnnSearchOp(clientF.apply(l), bfunc.apply(l).build(), schemaClass);
|
||||
}
|
||||
|
||||
private LongFunction<Query> buildFilterQuery(LongFunction<Map> mapLongFunction) {
|
@ -35,13 +35,11 @@ import org.opensearch.client.opensearch.core.bulk.IndexOperation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class OpenSearchRequests {
|
||||
public class AOSRequests {
|
||||
|
||||
private final static Logger logger = LogManager.getLogger(IndexOpDispenser.class);
|
||||
private final static Logger logger = LogManager.getLogger(AOSIndexOpDispenser.class);
|
||||
private static Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
public static <T> LongFunction<BulkRequest> bulk(ParsedOp op, LongFunction<String> targetF) {
|
||||
@ -57,12 +55,12 @@ public class OpenSearchRequests {
|
||||
ParsedOp subop = op.getAsSubOp("op_template");
|
||||
int repeat = subop.getStaticConfigOr("repeat", 1);
|
||||
|
||||
TypeAndTarget<BulkOpTypes, String> typeinfo =
|
||||
subop.getTypeAndTarget(BulkOpTypes.class, String.class);
|
||||
TypeAndTarget<AOSBulkOpTypes, String> typeinfo =
|
||||
subop.getTypeAndTarget(AOSBulkOpTypes.class, String.class);
|
||||
|
||||
LongFunction<BulkOperationVariant> bop = switch (typeinfo.enumId) {
|
||||
case create -> OpenSearchRequests.createOperation(subop);
|
||||
case index -> OpenSearchRequests.indexOperation(subop);
|
||||
case create -> AOSRequests.createOperation(subop);
|
||||
case index -> AOSRequests.indexOperation(subop);
|
||||
default -> throw new OpConfigError("Unsupported type in bulk operation: '" + typeinfo.enumId + "'");
|
||||
};
|
||||
|
||||
@ -116,7 +114,7 @@ public class OpenSearchRequests {
|
||||
func = op.enhanceFuncOptionally(func, "version", long.class, IndexRequest.Builder::version);
|
||||
func = op.enhanceEnumOptionally(func, "opType", OpType.class, IndexRequest.Builder::opType);
|
||||
func = op.enhanceEnumOptionally(func, "versionType", VersionType.class, IndexRequest.Builder::versionType);
|
||||
func = op.enhanceFuncPivot(func, "document", Object.class, OpenSearchRequests::bindDocument);
|
||||
func = op.enhanceFuncPivot(func, "document", Object.class, AOSRequests::bindDocument);
|
||||
LongFunction<IndexRequest.Builder> finalFunc1 = func;
|
||||
return l -> finalFunc1.apply(l).build();
|
||||
}
|
@ -16,30 +16,25 @@
|
||||
|
||||
package io.nosqlbench.adapter.opensearch.dispensers;
|
||||
|
||||
import io.nosqlbench.adapter.opensearch.OpenSearchAdapter;
|
||||
import io.nosqlbench.adapter.opensearch.ops.CreateIndexOp;
|
||||
import io.nosqlbench.adapter.opensearch.ops.UpdateOp;
|
||||
import io.nosqlbench.adapter.opensearch.AOSAdapter;
|
||||
import io.nosqlbench.adapter.opensearch.ops.AOSUpdateOp;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
import org.opensearch.client.json.JsonData;
|
||||
import org.opensearch.client.opensearch.OpenSearchClient;
|
||||
import org.opensearch.client.opensearch._types.mapping.*;
|
||||
import org.opensearch.client.opensearch.core.UpdateRequest;
|
||||
import org.opensearch.client.opensearch.indices.CreateIndexRequest;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
public class UpdateOpDispenser extends BaseOpenSearchOpDispenser {
|
||||
public class AOSUpdateOpDispenser extends AOSBaseOpDispenser {
|
||||
|
||||
public UpdateOpDispenser(OpenSearchAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
|
||||
public AOSUpdateOpDispenser(AOSAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
|
||||
super(adapter, op, targetF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LongFunction<UpdateOp> createOpFunc(LongFunction<OpenSearchClient> clientF, ParsedOp op, LongFunction<String> targetF) {
|
||||
public LongFunction<AOSUpdateOp> createOpFunc(LongFunction<OpenSearchClient> clientF, ParsedOp op, LongFunction<String> targetF) {
|
||||
LongFunction<UpdateRequest.Builder> bfunc = l -> new UpdateRequest.Builder().index(targetF.apply(l));
|
||||
// TODO: add details here
|
||||
return l -> new UpdateOp(clientF.apply(l),bfunc.apply(l).build(),Object.class);
|
||||
return l -> new AOSUpdateOp(clientF.apply(l),bfunc.apply(l).build(),Object.class);
|
||||
}
|
||||
|
||||
}
|
@ -19,10 +19,10 @@ package io.nosqlbench.adapter.opensearch.ops;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
|
||||
import org.opensearch.client.opensearch.OpenSearchClient;
|
||||
|
||||
public abstract class BaseOpenSearchOp implements CycleOp<Object> {
|
||||
public abstract class AOSBaseOp implements CycleOp<Object> {
|
||||
protected final OpenSearchClient client;
|
||||
|
||||
public BaseOpenSearchOp(OpenSearchClient client) {
|
||||
public AOSBaseOp(OpenSearchClient client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
@ -20,17 +20,14 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.opensearch.client.opensearch.OpenSearchClient;
|
||||
import org.opensearch.client.opensearch.core.BulkRequest;
|
||||
import org.opensearch.client.opensearch.core.BulkResponse;
|
||||
import org.opensearch.client.opensearch.core.IndexRequest;
|
||||
import org.opensearch.client.opensearch.core.IndexResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class BulkOp extends BaseOpenSearchOp {
|
||||
private final static Logger logger = LogManager.getLogger(BulkOp.class);
|
||||
public class AOSBulkOp extends AOSBaseOp {
|
||||
private final static Logger logger = LogManager.getLogger(AOSBulkOp.class);
|
||||
private final BulkRequest rq;
|
||||
|
||||
public BulkOp(OpenSearchClient client, BulkRequest rq) {
|
||||
public AOSBulkOp(OpenSearchClient client, BulkRequest rq) {
|
||||
super(client);
|
||||
this.rq = rq;
|
||||
}
|
@ -20,10 +20,10 @@ import org.opensearch.client.opensearch.OpenSearchClient;
|
||||
import org.opensearch.client.opensearch.indices.CreateIndexRequest;
|
||||
import org.opensearch.client.opensearch.indices.CreateIndexResponse;
|
||||
|
||||
public class CreateIndexOp extends BaseOpenSearchOp {
|
||||
public class AOSCreateIndexOp extends AOSBaseOp {
|
||||
private final CreateIndexRequest rq;
|
||||
|
||||
public CreateIndexOp(OpenSearchClient client, CreateIndexRequest rq) {
|
||||
public AOSCreateIndexOp(OpenSearchClient client, CreateIndexRequest rq) {
|
||||
super(client);
|
||||
this.rq = rq;
|
||||
}
|
@ -17,15 +17,14 @@
|
||||
package io.nosqlbench.adapter.opensearch.ops;
|
||||
|
||||
import org.opensearch.client.opensearch.OpenSearchClient;
|
||||
import org.opensearch.client.opensearch.indices.CreateIndexRequest;
|
||||
import org.opensearch.client.opensearch.indices.DeleteIndexRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class DeleteIndexOp extends BaseOpenSearchOp {
|
||||
public class AOSDeleteIndexOp extends AOSBaseOp {
|
||||
private final DeleteIndexRequest rq;
|
||||
|
||||
public DeleteIndexOp(OpenSearchClient client, DeleteIndexRequest rq) {
|
||||
public AOSDeleteIndexOp(OpenSearchClient client, DeleteIndexRequest rq) {
|
||||
super(client);
|
||||
this.rq = rq;
|
||||
}
|
@ -18,14 +18,13 @@ package io.nosqlbench.adapter.opensearch.ops;
|
||||
|
||||
import org.opensearch.client.opensearch.OpenSearchClient;
|
||||
import org.opensearch.client.opensearch.core.DeleteRequest;
|
||||
import org.opensearch.client.opensearch.core.IndexRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class DeleteOp extends BaseOpenSearchOp {
|
||||
public class AOSDeleteOp extends AOSBaseOp {
|
||||
private final DeleteRequest rq;
|
||||
|
||||
public DeleteOp(OpenSearchClient client, DeleteRequest rq) {
|
||||
public AOSDeleteOp(OpenSearchClient client, DeleteRequest rq) {
|
||||
super(client);
|
||||
this.rq = rq;
|
||||
}
|
@ -21,15 +21,14 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.opensearch.client.opensearch.OpenSearchClient;
|
||||
import org.opensearch.client.opensearch.core.IndexRequest;
|
||||
import org.opensearch.client.opensearch.core.IndexResponse;
|
||||
import org.opensearch.client.opensearch.core.UpdateRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class IndexOp extends BaseOpenSearchOp {
|
||||
private final static Logger logger = LogManager.getLogger(IndexOp.class);
|
||||
public class AOSIndexOp extends AOSBaseOp {
|
||||
private final static Logger logger = LogManager.getLogger(AOSIndexOp.class);
|
||||
private final IndexRequest<?> rq;
|
||||
|
||||
public IndexOp(OpenSearchClient client, IndexRequest<?> rq) {
|
||||
public AOSIndexOp(OpenSearchClient client, IndexRequest<?> rq) {
|
||||
super(client);
|
||||
this.rq = rq;
|
||||
}
|
@ -19,14 +19,12 @@ package io.nosqlbench.adapter.opensearch.ops;
|
||||
import org.opensearch.client.opensearch.OpenSearchClient;
|
||||
import org.opensearch.client.opensearch.core.SearchRequest;
|
||||
import org.opensearch.client.opensearch.core.SearchResponse;
|
||||
import org.opensearch.client.opensearch.indices.GetIndexRequest;
|
||||
import org.opensearch.client.opensearch.indices.GetIndexResponse;
|
||||
|
||||
public class KnnSearchOp extends BaseOpenSearchOp {
|
||||
public class AOSKnnSearchOp extends AOSBaseOp {
|
||||
private final SearchRequest rq;
|
||||
private final Class<?> doctype;
|
||||
|
||||
public KnnSearchOp(OpenSearchClient client, SearchRequest rq, Class<?> doctype) {
|
||||
public AOSKnnSearchOp(OpenSearchClient client, SearchRequest rq, Class<?> doctype) {
|
||||
super(client);
|
||||
this.rq = rq;
|
||||
this.doctype = doctype;
|
@ -21,11 +21,11 @@ import org.opensearch.client.opensearch.core.UpdateRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class UpdateOp extends BaseOpenSearchOp {
|
||||
public class AOSUpdateOp extends AOSBaseOp {
|
||||
private final UpdateRequest rq;
|
||||
private final Class<?> doctype;
|
||||
|
||||
public UpdateOp(OpenSearchClient client, UpdateRequest rq, Class<?> doctype) {
|
||||
public AOSUpdateOp(OpenSearchClient client, UpdateRequest rq, Class<?> doctype) {
|
||||
super(client);
|
||||
this.rq = rq;
|
||||
this.doctype = doctype;
|
Loading…
Reference in New Issue
Block a user