Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.ReleasableBytesStreamOutput;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.Tuple;
Expand Down Expand Up @@ -282,15 +281,13 @@ public String toString() {
* Returns the merged {@link SearchApplication} from the current state and the provided {@param update}.
* This function returns the current instance if the update is a noop.
*
* @param update The source of the update represented in bytes.
* @param update The source of the update represented in bytes.
* @param xContentType The format of the bytes.
* @param bigArrays The {@link BigArrays} to use to recycle bytes array.
*
* @return The merged {@link SearchApplication}.
*/
SearchApplication merge(BytesReference update, XContentType xContentType, BigArrays bigArrays) throws IOException {
SearchApplication merge(BytesReference update, XContentType xContentType) throws IOException {
final Tuple<XContentType, Map<String, Object>> sourceAndContent;
try (ReleasableBytesStreamOutput sourceBuffer = new ReleasableBytesStreamOutput(0, bigArrays.withCircuitBreaking())) {
try (BytesStreamOutput sourceBuffer = new BytesStreamOutput()) {
try (XContentBuilder builder = XContentFactory.jsonBuilder(sourceBuffer)) {
toXContent(builder, EMPTY_PARAMS);
}
Expand All @@ -305,7 +302,7 @@ SearchApplication merge(BytesReference update, XContentType xContentType, BigArr
return this;
}

try (ReleasableBytesStreamOutput newSourceBuffer = new ReleasableBytesStreamOutput(0, bigArrays.withCircuitBreaking())) {
try (BytesStreamOutput newSourceBuffer = new BytesStreamOutput()) {
try (XContentBuilder builder = XContentFactory.jsonBuilder(newSourceBuffer)) {
builder.value(newSourceAsMap);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.search.SearchModule;
import org.elasticsearch.test.ESTestCase;
Expand Down Expand Up @@ -111,7 +110,7 @@ public void testMerge() throws IOException {
"updated_at_millis": 12345
}""";
SearchApplication app = SearchApplication.fromXContentBytes("my_search_app", new BytesArray(content), XContentType.JSON);
SearchApplication updatedApp = app.merge(new BytesArray(update), XContentType.JSON, BigArrays.NON_RECYCLING_INSTANCE);
SearchApplication updatedApp = app.merge(new BytesArray(update), XContentType.JSON);
assertNotSame(app, updatedApp);
assertThat(updatedApp.indices(), equalTo(new String[] { "my_index", "my_index_2" }));
assertThat(updatedApp.analyticsCollectionName(), equalTo("my_search_app_analytics"));
Expand Down