Skip to content

Commit

Permalink
Performance fix. Reduce deprecation calls for the same bulk request (#…
Browse files Browse the repository at this point in the history
…37415)

DeprecationLogger has warning de-duplication logic but it is expensive to run as it involves parsing existing warning headers. This PR changes the upstream bulk indexing code to do its own "event thinning" rather than relying on DeprecationLogger's trimming.
Closes #37411
  • Loading branch information
markharwood authored Jan 14, 2019
1 parent 2ee55a5 commit 92c6c98
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Null
int from = 0;
int length = data.length();
byte marker = xContent.streamSeparator();
boolean typesDeprecationLogged = false;
while (true) {
int nextMarker = findNextMarker(marker, from, data, length);
if (nextMarker == -1) {
Expand Down Expand Up @@ -427,7 +428,10 @@ public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Null
}
index = parser.text();
} else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
deprecationLogger.deprecatedAndMaybeLog("bulk_with_types", RestBulkAction.TYPES_DEPRECATION_MESSAGE);
if (typesDeprecationLogged == false) {
deprecationLogger.deprecatedAndMaybeLog("bulk_with_types", RestBulkAction.TYPES_DEPRECATION_MESSAGE);
typesDeprecationLogged = true;
}
type = parser.text();
} else if (ID.match(currentFieldName, parser.getDeprecationHandler())) {
id = parser.text();
Expand Down

0 comments on commit 92c6c98

Please sign in to comment.