Skip to content

Commit

Permalink
more diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
jshook committed Feb 9, 2024
1 parent bc907ab commit a033aa4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import io.nosqlbench.adapter.opensearch.ops.IndexOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.client.opensearch.OpenSearchClient;
import org.opensearch.client.opensearch._types.OpType;
import org.opensearch.client.opensearch._types.VersionType;
Expand All @@ -31,12 +33,15 @@
import java.util.function.LongFunction;

public class IndexOpDispenser extends BaseOpenSearchOpDispenser {
private final static Logger logger = LogManager.getLogger(IndexOpDispenser.class);
private static Gson gson = new GsonBuilder().setPrettyPrinting().create();
private final LongFunction<String> targetF;
private final String diag;

public IndexOpDispenser(OpenSearchAdapter adapter, ParsedOp op, LongFunction<String> targetF) {
super(adapter, op);
this.targetF =targetF;
this.diag = op.getStaticConfigOr("daig","false");
}

@Override
Expand All @@ -61,6 +66,9 @@ public LongFunction<? extends Op> createOpFunc(LongFunction<OpenSearchClient> cl

private IndexRequest.Builder<?> bindDocument(IndexRequest.Builder builder, Object docdata) {
String document = gson.toJson(docdata);
if (diag.equals("true")) {
logger.debug("index_op document:\n----\n" + document + "\n----\n");
}
return builder.document(docdata);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public LongFunction<KnnSearchOp> createOpFunc(LongFunction<OpenSearchClient> cli
LongFunction<KnnQuery.Builder> finalKnnfunc = knnfunc;
LongFunction<SearchRequest.Builder> bfunc =
l -> new SearchRequest.Builder().size(100)
.index(targetF.apply(1))
.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(), Doc.class);
Expand Down

0 comments on commit a033aa4

Please sign in to comment.