mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 06:25:07 +00:00
builder based search source is safe now
This commit is contained in:
parent
184a38439f
commit
b113eb18fe
@ -100,7 +100,7 @@ public class CountRequest extends BroadcastOperationRequest {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected void beforeLocalFork() {
|
@Override protected void beforeStart() {
|
||||||
if (querySourceUnsafe) {
|
if (querySourceUnsafe) {
|
||||||
querySource = Arrays.copyOfRange(querySource, querySourceOffset, querySourceOffset + querySourceLength);
|
querySource = Arrays.copyOfRange(querySource, querySourceOffset, querySourceOffset + querySourceLength);
|
||||||
querySourceOffset = 0;
|
querySourceOffset = 0;
|
||||||
|
@ -325,7 +325,7 @@ public class MoreLikeThisRequest implements ActionRequest {
|
|||||||
* more like this documents.
|
* more like this documents.
|
||||||
*/
|
*/
|
||||||
public MoreLikeThisRequest searchSource(SearchSourceBuilder sourceBuilder) {
|
public MoreLikeThisRequest searchSource(SearchSourceBuilder sourceBuilder) {
|
||||||
BytesStream bos = sourceBuilder.buildAsUnsafeBytes(Requests.CONTENT_TYPE);
|
BytesStream bos = sourceBuilder.buildAsBytesStream(Requests.CONTENT_TYPE);
|
||||||
this.searchSource = bos.underlyingBytes();
|
this.searchSource = bos.underlyingBytes();
|
||||||
this.searchSourceOffset = 0;
|
this.searchSourceOffset = 0;
|
||||||
this.searchSourceLength = bos.size();
|
this.searchSourceLength = bos.size();
|
||||||
|
@ -261,11 +261,11 @@ public class SearchRequest implements ActionRequest {
|
|||||||
* The source of the search request.
|
* The source of the search request.
|
||||||
*/
|
*/
|
||||||
public SearchRequest source(SearchSourceBuilder sourceBuilder) {
|
public SearchRequest source(SearchSourceBuilder sourceBuilder) {
|
||||||
BytesStream bos = sourceBuilder.buildAsUnsafeBytes(Requests.CONTENT_TYPE);
|
BytesStream bos = sourceBuilder.buildAsBytesStream(Requests.CONTENT_TYPE);
|
||||||
this.source = bos.underlyingBytes();
|
this.source = bos.underlyingBytes();
|
||||||
this.sourceOffset = 0;
|
this.sourceOffset = 0;
|
||||||
this.sourceLength = bos.size();
|
this.sourceLength = bos.size();
|
||||||
this.sourceUnsafe = true;
|
this.sourceUnsafe = false;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,11 +356,11 @@ public class SearchRequest implements ActionRequest {
|
|||||||
extraSource = null;
|
extraSource = null;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
BytesStream bos = sourceBuilder.buildAsUnsafeBytes(Requests.CONTENT_TYPE);
|
BytesStream bos = sourceBuilder.buildAsBytesStream(Requests.CONTENT_TYPE);
|
||||||
this.extraSource = bos.underlyingBytes();
|
this.extraSource = bos.underlyingBytes();
|
||||||
this.extraSourceOffset = 0;
|
this.extraSourceOffset = 0;
|
||||||
this.extraSourceLength = bos.size();
|
this.extraSourceLength = bos.size();
|
||||||
this.extraSourceUnsafe = true;
|
this.extraSourceUnsafe = false;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,10 @@ public abstract class BroadcastOperationRequest implements ActionRequest {
|
|||||||
return operationThreading(BroadcastOperationThreading.fromString(operationThreading, this.operationThreading));
|
return operationThreading(BroadcastOperationThreading.fromString(operationThreading, this.operationThreading));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void beforeStart() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected void beforeLocalFork() {
|
protected void beforeLocalFork() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -156,6 +156,7 @@ public abstract class TransportBroadcastOperationAction<Request extends Broadcas
|
|||||||
// no shards
|
// no shards
|
||||||
listener.onResponse(newResponse(request, new AtomicReferenceArray(0), clusterState));
|
listener.onResponse(newResponse(request, new AtomicReferenceArray(0), clusterState));
|
||||||
}
|
}
|
||||||
|
request.beforeStart();
|
||||||
// count the local operations, and perform the non local ones
|
// count the local operations, and perform the non local ones
|
||||||
int localOperations = 0;
|
int localOperations = 0;
|
||||||
for (final ShardIterator shardIt : shardsIts) {
|
for (final ShardIterator shardIt : shardsIts) {
|
||||||
|
@ -495,7 +495,7 @@ public class SearchSourceBuilder implements ToXContent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BytesStream buildAsUnsafeBytes(XContentType contentType) throws SearchSourceBuilderException {
|
public BytesStream buildAsBytesStream(XContentType contentType) throws SearchSourceBuilderException {
|
||||||
try {
|
try {
|
||||||
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
|
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
|
||||||
toXContent(builder, ToXContent.EMPTY_PARAMS);
|
toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user