Skip to content

Commit

Permalink
[Type removal] Remove _type support in bulk indexing from client benc…
Browse files Browse the repository at this point in the history
…hmark

Signed-off-by: Suraj Singh <surajrider@gmail.com>
  • Loading branch information
dreamer-89 committed Apr 25, 2022
1 parent 03fbca3 commit 81d7038
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public abstract class AbstractBenchmark<T extends Closeable> {

protected abstract T client(String benchmarkTargetHost) throws Exception;

protected abstract BulkRequestExecutor bulkRequestExecutor(T client, String indexName, String typeName);
protected abstract BulkRequestExecutor bulkRequestExecutor(T client, String indexName);

protected abstract SearchRequestExecutor searchRequestExecutor(T client, String indexName);

Expand All @@ -76,16 +76,15 @@ public final void run(String[] args) throws Exception {

@SuppressForbidden(reason = "system out is ok for a command line tool")
private void runBulkIndexBenchmark(String[] args) throws Exception {
if (args.length != 7) {
System.err.println("usage: 'bulk' benchmarkTargetHostIp indexFilePath indexName typeName numberOfDocuments bulkSize");
if (args.length != 6) {
System.err.println("usage: 'bulk' benchmarkTargetHostIp indexFilePath indexName numberOfDocuments bulkSize");
System.exit(1);
}
String benchmarkTargetHost = args[1];
String indexFilePath = args[2];
String indexName = args[3];
String typeName = args[4];
int totalDocs = Integer.valueOf(args[5]);
int bulkSize = Integer.valueOf(args[6]);
int totalDocs = Integer.valueOf(args[4]);
int bulkSize = Integer.valueOf(args[5]);

int totalIterationCount = (int) Math.floor(totalDocs / bulkSize);
// consider 40% of all iterations as warmup iterations
Expand All @@ -97,7 +96,7 @@ private void runBulkIndexBenchmark(String[] args) throws Exception {
BenchmarkRunner benchmark = new BenchmarkRunner(
warmupIterations,
iterations,
new BulkBenchmarkTask(bulkRequestExecutor(client, indexName, typeName), indexFilePath, warmupIterations, iterations, bulkSize)
new BulkBenchmarkTask(bulkRequestExecutor(client, indexName), indexFilePath, warmupIterations, iterations, bulkSize)
);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ protected RestClient client(String benchmarkTargetHost) {
}

@Override
protected BulkRequestExecutor bulkRequestExecutor(RestClient client, String indexName, String typeName) {
return new RestBulkRequestExecutor(client, indexName, typeName);
protected BulkRequestExecutor bulkRequestExecutor(RestClient client, String indexName) {
return new RestBulkRequestExecutor(client, indexName);
}

@Override
Expand All @@ -78,9 +78,9 @@ private static final class RestBulkRequestExecutor implements BulkRequestExecuto
private final RestClient client;
private final String actionMetadata;

RestBulkRequestExecutor(RestClient client, String index, String type) {
RestBulkRequestExecutor(RestClient client, String index) {
this.client = client;
this.actionMetadata = String.format(Locale.ROOT, "{ \"index\" : { \"_index\" : \"%s\", \"_type\" : \"%s\" } }%n", index, type);
this.actionMetadata = String.format(Locale.ROOT, "{ \"index\" : { \"_index\" : \"%s\" } }%n", index);
}

@Override
Expand All @@ -91,7 +91,7 @@ public boolean bulkIndex(List<String> bulkData) {
bulkRequestBody.append(bulkItem);
bulkRequestBody.append("\n");
}
Request request = new Request("POST", "/geonames/type/_noop_bulk");
Request request = new Request("POST", "/geonames/_noop_bulk");
request.setJsonEntity(bulkRequestBody.toString());
try {
Response response = client.performRequest(request);
Expand Down

0 comments on commit 81d7038

Please sign in to comment.