Java api: Remove unneeded getTookInMillis method (#23923)
Some response classes in the java api expose both `getTook()` which returns a `TimeValue` and `getTookInMillis` which returns a `long` value. `getTook()` is enough as one can do `getTook().millis()` to obtain the same result as `getTookInMillis()`, which can be removed.
This commit is contained in:
parent
779fb9a1c0
commit
6dea5f14c3
|
@ -580,7 +580,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
|
||||||
|
|
||||||
BulkResponse bulkResponse = execute(bulkRequest, highLevelClient()::bulk, highLevelClient()::bulkAsync);
|
BulkResponse bulkResponse = execute(bulkRequest, highLevelClient()::bulk, highLevelClient()::bulkAsync);
|
||||||
assertEquals(RestStatus.OK, bulkResponse.status());
|
assertEquals(RestStatus.OK, bulkResponse.status());
|
||||||
assertTrue(bulkResponse.getTookInMillis() > 0);
|
assertTrue(bulkResponse.getTook().getMillis() > 0);
|
||||||
assertEquals(nbItems, bulkResponse.getItems().length);
|
assertEquals(nbItems, bulkResponse.getItems().length);
|
||||||
|
|
||||||
validateBulkResponses(nbItems, errors, bulkResponse, bulkRequest);
|
validateBulkResponses(nbItems, errors, bulkResponse, bulkRequest);
|
||||||
|
@ -671,7 +671,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
|
||||||
BulkRequest bulkRequest = requestRef.get();
|
BulkRequest bulkRequest = requestRef.get();
|
||||||
|
|
||||||
assertEquals(RestStatus.OK, bulkResponse.status());
|
assertEquals(RestStatus.OK, bulkResponse.status());
|
||||||
assertTrue(bulkResponse.getTookInMillis() > 0);
|
assertTrue(bulkResponse.getTook().getMillis() > 0);
|
||||||
assertEquals(nbItems, bulkResponse.getItems().length);
|
assertEquals(nbItems, bulkResponse.getItems().length);
|
||||||
assertNull(error.get());
|
assertNull(error.get());
|
||||||
|
|
||||||
|
|
|
@ -76,13 +76,6 @@ public class BulkResponse extends ActionResponse implements Iterable<BulkItemRes
|
||||||
return new TimeValue(tookInMillis);
|
return new TimeValue(tookInMillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* How long the bulk execution took in milliseconds. Excluding ingest preprocessing.
|
|
||||||
*/
|
|
||||||
public long getTookInMillis() {
|
|
||||||
return tookInMillis;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If ingest is enabled returns the bulk ingest preprocessing time, otherwise 0 is returned.
|
* If ingest is enabled returns the bulk ingest preprocessing time, otherwise 0 is returned.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -569,8 +569,8 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||||
ActionListener<BulkResponse> wrapActionListenerIfNeeded(long ingestTookInMillis, ActionListener<BulkResponse> actionListener) {
|
ActionListener<BulkResponse> wrapActionListenerIfNeeded(long ingestTookInMillis, ActionListener<BulkResponse> actionListener) {
|
||||||
if (itemResponses.isEmpty()) {
|
if (itemResponses.isEmpty()) {
|
||||||
return ActionListener.wrap(
|
return ActionListener.wrap(
|
||||||
response -> actionListener.onResponse(
|
response -> actionListener.onResponse(new BulkResponse(response.getItems(),
|
||||||
new BulkResponse(response.getItems(), response.getTookInMillis(), ingestTookInMillis)),
|
response.getTook().getMillis(), ingestTookInMillis)),
|
||||||
actionListener::onFailure);
|
actionListener::onFailure);
|
||||||
} else {
|
} else {
|
||||||
return new IngestBulkResponseListener(ingestTookInMillis, originalSlots, itemResponses, actionListener);
|
return new IngestBulkResponseListener(ingestTookInMillis, originalSlots, itemResponses, actionListener);
|
||||||
|
@ -610,7 +610,9 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
itemResponses.add(originalSlots[i], response.getItems()[i]);
|
itemResponses.add(originalSlots[i], response.getItems()[i]);
|
||||||
}
|
}
|
||||||
actionListener.onResponse(new BulkResponse(itemResponses.toArray(new BulkItemResponse[itemResponses.size()]), response.getTookInMillis(), ingestTookInMillis));
|
actionListener.onResponse(new BulkResponse(
|
||||||
|
itemResponses.toArray(new BulkItemResponse[itemResponses.size()]),
|
||||||
|
response.getTook().getMillis(), ingestTookInMillis));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -135,13 +135,6 @@ public class SearchResponse extends ActionResponse implements StatusToXContentOb
|
||||||
return new TimeValue(tookInMillis);
|
return new TimeValue(tookInMillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* How long the search took in milliseconds.
|
|
||||||
*/
|
|
||||||
public long getTookInMillis() {
|
|
||||||
return tookInMillis;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The total number of shards the search was executed on.
|
* The total number of shards the search was executed on.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -334,10 +334,6 @@ public class TermVectorsResponse extends ActionResponse implements ToXContentObj
|
||||||
return new TimeValue(tookInMillis);
|
return new TimeValue(tookInMillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTookInMillis() {
|
|
||||||
return tookInMillis;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildScore(XContentBuilder builder, BoostAttribute boostAtt) throws IOException {
|
private void buildScore(XContentBuilder builder, BoostAttribute boostAtt) throws IOException {
|
||||||
if (hasScores) {
|
if (hasScores) {
|
||||||
builder.field(FieldStrings.SCORE, boostAtt.getBoost());
|
builder.field(FieldStrings.SCORE, boostAtt.getBoost());
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class BulkResponseTests extends ESTestCase {
|
||||||
assertNull(parser.nextToken());
|
assertNull(parser.nextToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(took, parsedBulkResponse.getTookInMillis());
|
assertEquals(took, parsedBulkResponse.getTook().getMillis());
|
||||||
assertEquals(ingestTook, parsedBulkResponse.getIngestTookInMillis());
|
assertEquals(ingestTook, parsedBulkResponse.getIngestTookInMillis());
|
||||||
assertEquals(expectedBulkItems.length, parsedBulkResponse.getItems().length);
|
assertEquals(expectedBulkItems.length, parsedBulkResponse.getItems().length);
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,8 @@ public class TermVectorsServiceTests extends ESSingleNodeTestCase {
|
||||||
TermVectorsResponse response = TermVectorsService.getTermVectors(shard, request, longs.iterator()::next);
|
TermVectorsResponse response = TermVectorsService.getTermVectors(shard, request, longs.iterator()::next);
|
||||||
|
|
||||||
assertThat(response, notNullValue());
|
assertThat(response, notNullValue());
|
||||||
assertThat(response.getTookInMillis(), equalTo(TimeUnit.NANOSECONDS.toMillis(longs.get(1) - longs.get(0))));
|
assertThat(response.getTook().getMillis(),
|
||||||
|
equalTo(TimeUnit.NANOSECONDS.toMillis(longs.get(1) - longs.get(0))));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDocFreqs() throws IOException {
|
public void testDocFreqs() throws IOException {
|
||||||
|
|
|
@ -802,7 +802,8 @@ public class HighlighterSearchIT extends ESIntegTestCase {
|
||||||
* in the neighborhood of 300ms and the large phrase limit is in the
|
* in the neighborhood of 300ms and the large phrase limit is in the
|
||||||
* neighborhood of 8 seconds.
|
* neighborhood of 8 seconds.
|
||||||
*/
|
*/
|
||||||
assertThat(defaultPhraseLimit.getTookInMillis(), lessThan(largePhraseLimit.getTookInMillis()));
|
assertThat(defaultPhraseLimit.getTook().getMillis(),
|
||||||
|
lessThan(largePhraseLimit.getTook().getMillis()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,3 +35,9 @@ code for ordering buckets. The `BucketOrder` class must be used instead of `Term
|
||||||
`Histogram.Order`. The `static` methods in the `BucketOrder` class must be called instead of directly
|
`Histogram.Order`. The `static` methods in the `BucketOrder` class must be called instead of directly
|
||||||
accessing internal order instances, e.g. `BucketOrder.count(boolean)` and `BucketOrder.aggregation(String, boolean)`.
|
accessing internal order instances, e.g. `BucketOrder.count(boolean)` and `BucketOrder.aggregation(String, boolean)`.
|
||||||
Use `BucketOrder.key(boolean)` to order the `terms` aggregation buckets by `_term`.
|
Use `BucketOrder.key(boolean)` to order the `terms` aggregation buckets by `_term`.
|
||||||
|
|
||||||
|
=== `getTookInMillis()` removed in `BulkResponse`, `SearchResponse` and `TermVectorsResponse`
|
||||||
|
|
||||||
|
In `BulkResponse`, `SearchResponse` and `TermVectorsResponse` `getTookInMiilis()` method
|
||||||
|
has been removed in favor of `getTook` method. `getTookInMiilis()` is easily replaced by
|
||||||
|
`getTook().getMillis()`.
|
||||||
|
|
Loading…
Reference in New Issue