don't call toLowerCase on each bulk item
This commit is contained in:
parent
32bf7607c7
commit
36fd76b826
|
@ -56,7 +56,6 @@ import org.elasticsearch.transport.TransportRequestOptions;
|
|||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -184,7 +183,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation
|
|||
}
|
||||
|
||||
// add the response
|
||||
responses[i] = new BulkItemResponse(item.id(), indexRequest.opType().toString().toLowerCase(Locale.ENGLISH),
|
||||
responses[i] = new BulkItemResponse(item.id(), indexRequest.opType().lowercase(),
|
||||
new IndexResponse(indexRequest.index(), indexRequest.type(), indexRequest.id(), version));
|
||||
} catch (Exception e) {
|
||||
// rethrow the failure if we are going to retry on primary and let parent failure to handle it
|
||||
|
@ -196,7 +195,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation
|
|||
} else {
|
||||
logger.debug("[{}][{}] failed to execute bulk item (index) {}", e, shardRequest.request.index(), shardRequest.shardId, indexRequest);
|
||||
}
|
||||
responses[i] = new BulkItemResponse(item.id(), indexRequest.opType().toString().toLowerCase(Locale.ENGLISH),
|
||||
responses[i] = new BulkItemResponse(item.id(), indexRequest.opType().lowercase(),
|
||||
new BulkItemResponse.Failure(indexRequest.index(), indexRequest.type(), indexRequest.id(), ExceptionsHelper.detailedMessage(e)));
|
||||
// nullify the request so it won't execute on the replicas
|
||||
request.items()[i] = null;
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.elasticsearch.index.VersionType;
|
|||
import org.elasticsearch.index.mapper.internal.TimestampFieldMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.action.ValidateActions.addValidationError;
|
||||
|
@ -80,10 +81,12 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
|
|||
*/
|
||||
CREATE((byte) 1);
|
||||
|
||||
private byte id;
|
||||
private final byte id;
|
||||
private final String lowercase;
|
||||
|
||||
OpType(byte id) {
|
||||
this.id = id;
|
||||
this.lowercase = this.toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,6 +96,10 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
|
|||
return id;
|
||||
}
|
||||
|
||||
public String lowercase() {
|
||||
return this.lowercase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the operation type from its internal representation.
|
||||
*/
|
||||
|
@ -134,20 +141,20 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
|
|||
|
||||
/**
|
||||
* Constructs a new index request against the specific index. The {@link #type(String)}
|
||||
* {@link #source(byte[])} must be set.
|
||||
* {@link #source(byte[])} must be set.
|
||||
*/
|
||||
public IndexRequest(String index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new index request against the specific index and type. The
|
||||
* Constructs a new index request against the specific index and type. The
|
||||
* {@link #source(byte[])} must be set.
|
||||
*/
|
||||
public IndexRequest(String index, String type) {
|
||||
this.index = index;
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new index request against the index, type, id and using the source.
|
||||
|
|
|
@ -62,7 +62,8 @@ public class SingleThreadBulkStress {
|
|||
nodes[i] = nodeBuilder().settings(settingsBuilder().put(settings).put("name", "node" + i)).node();
|
||||
}
|
||||
|
||||
Node client = nodeBuilder().settings(settingsBuilder().put(settings).put("name", "client")).client(true).node();
|
||||
//Node client = nodeBuilder().settings(settingsBuilder().put(settings).put("name", "client")).client(true).node();
|
||||
Node client = nodes[0];
|
||||
|
||||
Client client1 = client.client();
|
||||
|
||||
|
|
Loading…
Reference in New Issue