Migrate (read|write)Query to (read|write)NamedWriteable

Now there aren't any more specialized methods to read or write
NamedWriteables! Now StreamInput and StreamOutput don't need to know
about large chunks of the application!
This commit is contained in:
Nik Everett 2016-04-18 21:21:31 -04:00
parent 339d927ee4
commit 133cec602c
28 changed files with 66 additions and 86 deletions

View File

@ -84,7 +84,7 @@ public class ShardValidateQueryRequest extends BroadcastShardRequest {
@Override @Override
public void readFrom(StreamInput in) throws IOException { public void readFrom(StreamInput in) throws IOException {
super.readFrom(in); super.readFrom(in);
query = in.readQuery(); query = in.readNamedWriteable(QueryBuilder.class);
int typesSize = in.readVInt(); int typesSize = in.readVInt();
if (typesSize > 0) { if (typesSize > 0) {
@ -109,7 +109,7 @@ public class ShardValidateQueryRequest extends BroadcastShardRequest {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
out.writeQuery(query); out.writeNamedWriteable(query);
out.writeVInt(types.length); out.writeVInt(types.length);
for (String type : types) { for (String type : types) {

View File

@ -128,7 +128,7 @@ public class ValidateQueryRequest extends BroadcastRequest<ValidateQueryRequest>
@Override @Override
public void readFrom(StreamInput in) throws IOException { public void readFrom(StreamInput in) throws IOException {
super.readFrom(in); super.readFrom(in);
query = in.readQuery(); query = in.readNamedWriteable(QueryBuilder.class);
int typesSize = in.readVInt(); int typesSize = in.readVInt();
if (typesSize > 0) { if (typesSize > 0) {
types = new String[typesSize]; types = new String[typesSize];
@ -143,7 +143,7 @@ public class ValidateQueryRequest extends BroadcastRequest<ValidateQueryRequest>
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
out.writeQuery(query); out.writeNamedWriteable(query);
out.writeVInt(types.length); out.writeVInt(types.length);
for (String type : types) { for (String type : types) {
out.writeString(type); out.writeString(type);

View File

@ -165,7 +165,7 @@ public class ExplainRequest extends SingleShardRequest<ExplainRequest> {
id = in.readString(); id = in.readString();
routing = in.readOptionalString(); routing = in.readOptionalString();
preference = in.readOptionalString(); preference = in.readOptionalString();
query = in.readQuery(); query = in.readNamedWriteable(QueryBuilder.class);
filteringAlias = in.readStringArray(); filteringAlias = in.readStringArray();
fields = in.readOptionalStringArray(); fields = in.readOptionalStringArray();
fetchSourceContext = in.readOptionalStreamable(FetchSourceContext::new); fetchSourceContext = in.readOptionalStreamable(FetchSourceContext::new);
@ -179,7 +179,7 @@ public class ExplainRequest extends SingleShardRequest<ExplainRequest> {
out.writeString(id); out.writeString(id);
out.writeOptionalString(routing); out.writeOptionalString(routing);
out.writeOptionalString(preference); out.writeOptionalString(preference);
out.writeQuery(query); out.writeNamedWriteable(query);
out.writeStringArray(filteringAlias); out.writeStringArray(filteringAlias);
out.writeOptionalStringArray(fields); out.writeOptionalStringArray(fields);
out.writeOptionalStreamable(fetchSourceContext); out.writeOptionalStreamable(fetchSourceContext);

View File

@ -34,7 +34,6 @@ import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.text.Text; import org.elasticsearch.common.text.Text;
import org.elasticsearch.index.query.QueryBuilder;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.DateTimeZone; import org.joda.time.DateTimeZone;
@ -729,15 +728,6 @@ public abstract class StreamInput extends InputStream {
return null; return null;
} }
/**
* Reads a {@link QueryBuilder} from the current stream
* @deprecated prefer {@link #readNamedWriteable(Class)} passing {@link QueryBuilder}.
*/
@Deprecated
public QueryBuilder<?> readQuery() throws IOException {
return readNamedWriteable(QueryBuilder.class);
}
/** /**
* Reads a list of objects * Reads a list of objects
*/ */

View File

@ -33,7 +33,6 @@ import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.text.Text; import org.elasticsearch.common.text.Text;
import org.elasticsearch.index.query.QueryBuilder;
import org.joda.time.DateTimeZone; import org.joda.time.DateTimeZone;
import org.joda.time.ReadableInstant; import org.joda.time.ReadableInstant;
@ -693,15 +692,6 @@ public abstract class StreamOutput extends OutputStream {
} }
} }
/**
* Writes a {@link QueryBuilder} to the current stream
* @deprecated prefer {@link #writeNamedWriteable(NamedWriteable)}
*/
@Deprecated
public void writeQuery(QueryBuilder<?> queryBuilder) throws IOException {
writeNamedWriteable(queryBuilder);
}
/** /**
* Writes the given {@link GeoPoint} to the stream * Writes the given {@link GeoPoint} to the stream
*/ */

View File

@ -241,7 +241,7 @@ public abstract class AbstractQueryBuilder<QB extends AbstractQueryBuilder<QB>>
protected final void writeQueries(StreamOutput out, List<? extends QueryBuilder<?>> queries) throws IOException { protected final void writeQueries(StreamOutput out, List<? extends QueryBuilder<?>> queries) throws IOException {
out.writeVInt(queries.size()); out.writeVInt(queries.size());
for (QueryBuilder<?> query : queries) { for (QueryBuilder<?> query : queries) {
out.writeQuery(query); out.writeNamedWriteable(query);
} }
} }
@ -249,7 +249,7 @@ public abstract class AbstractQueryBuilder<QB extends AbstractQueryBuilder<QB>>
List<QueryBuilder<?>> queries = new ArrayList<>(); List<QueryBuilder<?>> queries = new ArrayList<>();
int size = in.readVInt(); int size = in.readVInt();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
queries.add(in.readQuery()); queries.add(in.readNamedWriteable(QueryBuilder.class));
} }
return queries; return queries;
} }

View File

@ -81,15 +81,15 @@ public class BoostingQueryBuilder extends AbstractQueryBuilder<BoostingQueryBuil
*/ */
public BoostingQueryBuilder(StreamInput in) throws IOException { public BoostingQueryBuilder(StreamInput in) throws IOException {
super(in); super(in);
positiveQuery = in.readQuery(); positiveQuery = in.readNamedWriteable(QueryBuilder.class);
negativeQuery = in.readQuery(); negativeQuery = in.readNamedWriteable(QueryBuilder.class);
negativeBoost = in.readFloat(); negativeBoost = in.readFloat();
} }
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeQuery(positiveQuery); out.writeNamedWriteable(positiveQuery);
out.writeQuery(negativeQuery); out.writeNamedWriteable(negativeQuery);
out.writeFloat(negativeBoost); out.writeFloat(negativeBoost);
} }

View File

@ -62,12 +62,12 @@ public class ConstantScoreQueryBuilder extends AbstractQueryBuilder<ConstantScor
*/ */
public ConstantScoreQueryBuilder(StreamInput in) throws IOException { public ConstantScoreQueryBuilder(StreamInput in) throws IOException {
super(in); super(in);
filterBuilder = in.readQuery(); filterBuilder = in.readNamedWriteable(QueryBuilder.class);
} }
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeQuery(filterBuilder); out.writeNamedWriteable(filterBuilder);
} }
/** /**

View File

@ -69,13 +69,13 @@ public class FieldMaskingSpanQueryBuilder extends AbstractQueryBuilder<FieldMask
*/ */
public FieldMaskingSpanQueryBuilder(StreamInput in) throws IOException { public FieldMaskingSpanQueryBuilder(StreamInput in) throws IOException {
super(in); super(in);
queryBuilder = (SpanQueryBuilder<?>) in.readQuery(); queryBuilder = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
fieldName = in.readString(); fieldName = in.readString();
} }
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeQuery(queryBuilder); out.writeNamedWriteable(queryBuilder);
out.writeString(fieldName); out.writeString(fieldName);
} }

View File

@ -108,7 +108,7 @@ public class HasChildQueryBuilder extends AbstractQueryBuilder<HasChildQueryBuil
minChildren = in.readInt(); minChildren = in.readInt();
maxChildren = in.readInt(); maxChildren = in.readInt();
scoreMode = ScoreMode.values()[in.readVInt()]; scoreMode = ScoreMode.values()[in.readVInt()];
query = in.readQuery(); query = in.readNamedWriteable(QueryBuilder.class);
innerHitBuilder = in.readOptionalWriteable(InnerHitBuilder::new); innerHitBuilder = in.readOptionalWriteable(InnerHitBuilder::new);
ignoreUnmapped = in.readBoolean(); ignoreUnmapped = in.readBoolean();
} }
@ -119,7 +119,7 @@ public class HasChildQueryBuilder extends AbstractQueryBuilder<HasChildQueryBuil
out.writeInt(minChildren); out.writeInt(minChildren);
out.writeInt(maxChildren); out.writeInt(maxChildren);
out.writeVInt(scoreMode.ordinal()); out.writeVInt(scoreMode.ordinal());
out.writeQuery(query); out.writeNamedWriteable(query);
out.writeOptionalWriteable(innerHitBuilder); out.writeOptionalWriteable(innerHitBuilder);
out.writeBoolean(ignoreUnmapped); out.writeBoolean(ignoreUnmapped);
} }

View File

@ -84,7 +84,7 @@ public class HasParentQueryBuilder extends AbstractQueryBuilder<HasParentQueryBu
super(in); super(in);
type = in.readString(); type = in.readString();
score = in.readBoolean(); score = in.readBoolean();
query = in.readQuery(); query = in.readNamedWriteable(QueryBuilder.class);
innerHit = in.readOptionalWriteable(InnerHitBuilder::new); innerHit = in.readOptionalWriteable(InnerHitBuilder::new);
ignoreUnmapped = in.readBoolean(); ignoreUnmapped = in.readBoolean();
} }
@ -93,7 +93,7 @@ public class HasParentQueryBuilder extends AbstractQueryBuilder<HasParentQueryBu
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeString(type); out.writeString(type);
out.writeBoolean(score); out.writeBoolean(score);
out.writeQuery(query); out.writeNamedWriteable(query);
out.writeOptionalWriteable(innerHit); out.writeOptionalWriteable(innerHit);
out.writeBoolean(ignoreUnmapped); out.writeBoolean(ignoreUnmapped);
} }

View File

@ -82,16 +82,16 @@ public class IndicesQueryBuilder extends AbstractQueryBuilder<IndicesQueryBuilde
*/ */
public IndicesQueryBuilder(StreamInput in) throws IOException { public IndicesQueryBuilder(StreamInput in) throws IOException {
super(in); super(in);
innerQuery = in.readQuery(); innerQuery = in.readNamedWriteable(QueryBuilder.class);
indices = in.readStringArray(); indices = in.readStringArray();
noMatchQuery = in.readQuery(); noMatchQuery = in.readNamedWriteable(QueryBuilder.class);
} }
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeQuery(innerQuery); out.writeNamedWriteable(innerQuery);
out.writeStringArray(indices); out.writeStringArray(indices);
out.writeQuery(noMatchQuery); out.writeNamedWriteable(noMatchQuery);
} }
public QueryBuilder<?> innerQuery() { public QueryBuilder<?> innerQuery() {

View File

@ -79,7 +79,7 @@ public class NestedQueryBuilder extends AbstractQueryBuilder<NestedQueryBuilder>
super(in); super(in);
path = in.readString(); path = in.readString();
scoreMode = ScoreMode.values()[in.readVInt()]; scoreMode = ScoreMode.values()[in.readVInt()];
query = in.readQuery(); query = in.readNamedWriteable(QueryBuilder.class);
innerHitBuilder = in.readOptionalWriteable(InnerHitBuilder::new); innerHitBuilder = in.readOptionalWriteable(InnerHitBuilder::new);
ignoreUnmapped = in.readBoolean(); ignoreUnmapped = in.readBoolean();
} }
@ -88,7 +88,7 @@ public class NestedQueryBuilder extends AbstractQueryBuilder<NestedQueryBuilder>
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeString(path); out.writeString(path);
out.writeVInt(scoreMode.ordinal()); out.writeVInt(scoreMode.ordinal());
out.writeQuery(query); out.writeNamedWriteable(query);
out.writeOptionalWriteable(innerHitBuilder); out.writeOptionalWriteable(innerHitBuilder);
out.writeBoolean(ignoreUnmapped); out.writeBoolean(ignoreUnmapped);
} }

View File

@ -67,14 +67,14 @@ public class SpanContainingQueryBuilder extends AbstractQueryBuilder<SpanContain
*/ */
public SpanContainingQueryBuilder(StreamInput in) throws IOException { public SpanContainingQueryBuilder(StreamInput in) throws IOException {
super(in); super(in);
big = (SpanQueryBuilder<?>) in.readQuery(); big = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
little = (SpanQueryBuilder<?>) in.readQuery(); little = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
} }
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeQuery(big); out.writeNamedWriteable(big);
out.writeQuery(little); out.writeNamedWriteable(little);
} }
/** /**

View File

@ -67,13 +67,13 @@ public class SpanFirstQueryBuilder extends AbstractQueryBuilder<SpanFirstQueryBu
*/ */
public SpanFirstQueryBuilder(StreamInput in) throws IOException { public SpanFirstQueryBuilder(StreamInput in) throws IOException {
super(in); super(in);
matchBuilder = (SpanQueryBuilder<?>)in.readQuery(); matchBuilder = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
end = in.readInt(); end = in.readInt();
} }
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeQuery(matchBuilder); out.writeNamedWriteable(matchBuilder);
out.writeInt(end); out.writeInt(end);
} }

View File

@ -60,12 +60,12 @@ public class SpanMultiTermQueryBuilder extends AbstractQueryBuilder<SpanMultiTer
*/ */
public SpanMultiTermQueryBuilder(StreamInput in) throws IOException { public SpanMultiTermQueryBuilder(StreamInput in) throws IOException {
super(in); super(in);
multiTermQueryBuilder = (MultiTermQueryBuilder<?>) in.readQuery(); multiTermQueryBuilder = (MultiTermQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
} }
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeQuery(multiTermQueryBuilder); out.writeNamedWriteable(multiTermQueryBuilder);
} }
public MultiTermQueryBuilder<?> innerQuery() { public MultiTermQueryBuilder<?> innerQuery() {

View File

@ -78,16 +78,16 @@ public class SpanNotQueryBuilder extends AbstractQueryBuilder<SpanNotQueryBuilde
*/ */
public SpanNotQueryBuilder(StreamInput in) throws IOException { public SpanNotQueryBuilder(StreamInput in) throws IOException {
super(in); super(in);
include = (SpanQueryBuilder<?>) in.readQuery(); include = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
exclude = (SpanQueryBuilder<?>) in.readQuery(); exclude = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
pre = in.readVInt(); pre = in.readVInt();
post = in.readVInt(); post = in.readVInt();
} }
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeQuery(include); out.writeNamedWriteable(include);
out.writeQuery(exclude); out.writeNamedWriteable(exclude);
out.writeVInt(pre); out.writeVInt(pre);
out.writeVInt(post); out.writeVInt(post);
} }

View File

@ -68,14 +68,14 @@ public class SpanWithinQueryBuilder extends AbstractQueryBuilder<SpanWithinQuery
*/ */
public SpanWithinQueryBuilder(StreamInput in) throws IOException { public SpanWithinQueryBuilder(StreamInput in) throws IOException {
super(in); super(in);
big = (SpanQueryBuilder<?>) in.readQuery(); big = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
little = (SpanQueryBuilder<?>) in.readQuery(); little = (SpanQueryBuilder<?>) in.readNamedWriteable(QueryBuilder.class);
} }
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeQuery(big); out.writeNamedWriteable(big);
out.writeQuery(little); out.writeNamedWriteable(little);
} }
/** /**

View File

@ -149,7 +149,7 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder<FunctionScor
*/ */
public FunctionScoreQueryBuilder(StreamInput in) throws IOException { public FunctionScoreQueryBuilder(StreamInput in) throws IOException {
super(in); super(in);
query = in.readQuery(); query = in.readNamedWriteable(QueryBuilder.class);
filterFunctionBuilders = in.readList(FilterFunctionBuilder::new).toArray(new FilterFunctionBuilder[0]); filterFunctionBuilders = in.readList(FilterFunctionBuilder::new).toArray(new FilterFunctionBuilder[0]);
maxBoost = in.readFloat(); maxBoost = in.readFloat();
minScore = in.readOptionalFloat(); minScore = in.readOptionalFloat();
@ -159,7 +159,7 @@ public class FunctionScoreQueryBuilder extends AbstractQueryBuilder<FunctionScor
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeQuery(query); out.writeNamedWriteable(query);
out.writeList(Arrays.asList(filterFunctionBuilders)); out.writeList(Arrays.asList(filterFunctionBuilders));
out.writeFloat(maxBoost); out.writeFloat(maxBoost);
out.writeOptionalFloat(minScore); out.writeOptionalFloat(minScore);

View File

@ -164,7 +164,7 @@ public final class InnerHitBuilder extends ToXContentToBytes implements Writeabl
} }
} }
highlightBuilder = in.readOptionalWriteable(HighlightBuilder::new); highlightBuilder = in.readOptionalWriteable(HighlightBuilder::new);
query = in.readQuery(); query = in.readNamedWriteable(QueryBuilder.class);
innerHitsBuilder = in.readOptionalWriteable(InnerHitsBuilder::new); innerHitsBuilder = in.readOptionalWriteable(InnerHitsBuilder::new);
} }
@ -195,7 +195,7 @@ public final class InnerHitBuilder extends ToXContentToBytes implements Writeabl
} }
} }
out.writeOptionalWriteable(highlightBuilder); out.writeOptionalWriteable(highlightBuilder);
out.writeQuery(query); out.writeNamedWriteable(query);
out.writeOptionalWriteable(innerHitsBuilder); out.writeOptionalWriteable(innerHitsBuilder);
} }

View File

@ -68,12 +68,12 @@ public class FilterAggregatorBuilder extends AggregatorBuilder<FilterAggregatorB
*/ */
public FilterAggregatorBuilder(StreamInput in) throws IOException { public FilterAggregatorBuilder(StreamInput in) throws IOException {
super(in, InternalFilter.TYPE); super(in, InternalFilter.TYPE);
filter = in.readQuery(); filter = in.readNamedWriteable(QueryBuilder.class);
} }
@Override @Override
protected void doWriteTo(StreamOutput out) throws IOException { protected void doWriteTo(StreamOutput out) throws IOException {
out.writeQuery(filter); out.writeNamedWriteable(filter);
} }
@Override @Override

View File

@ -81,13 +81,13 @@ public class FiltersAggregator extends BucketsAggregator {
*/ */
public KeyedFilter(StreamInput in) throws IOException { public KeyedFilter(StreamInput in) throws IOException {
key = in.readString(); key = in.readString();
filter = in.readQuery(); filter = in.readNamedWriteable(QueryBuilder.class);
} }
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeString(key); out.writeString(key);
out.writeQuery(filter); out.writeNamedWriteable(filter);
} }
public String key() { public String key() {

View File

@ -104,7 +104,7 @@ public class FiltersAggregatorBuilder extends AggregatorBuilder<FiltersAggregato
} }
} else { } else {
for (int i = 0; i < filtersSize; i++) { for (int i = 0; i < filtersSize; i++) {
filters.add(new KeyedFilter(String.valueOf(i), in.readQuery())); filters.add(new KeyedFilter(String.valueOf(i), in.readNamedWriteable(QueryBuilder.class)));
} }
} }
otherBucket = in.readBoolean(); otherBucket = in.readBoolean();
@ -121,7 +121,7 @@ public class FiltersAggregatorBuilder extends AggregatorBuilder<FiltersAggregato
} }
} else { } else {
for (KeyedFilter keyedFilter : filters) { for (KeyedFilter keyedFilter : filters) {
out.writeQuery(keyedFilter.filter()); out.writeNamedWriteable(keyedFilter.filter());
} }
} }
out.writeBoolean(otherBucket); out.writeBoolean(otherBucket);

View File

@ -74,7 +74,7 @@ public class SignificantTermsAggregatorBuilder extends ValuesSourceAggregatorBui
bucketCountThresholds = BucketCountThresholds.readFromStream(in); bucketCountThresholds = BucketCountThresholds.readFromStream(in);
executionHint = in.readOptionalString(); executionHint = in.readOptionalString();
if (in.readBoolean()) { if (in.readBoolean()) {
filterBuilder = in.readQuery(); filterBuilder = in.readNamedWriteable(QueryBuilder.class);
} }
if (in.readBoolean()) { if (in.readBoolean()) {
includeExclude = IncludeExclude.readFromStream(in); includeExclude = IncludeExclude.readFromStream(in);
@ -89,7 +89,7 @@ public class SignificantTermsAggregatorBuilder extends ValuesSourceAggregatorBui
boolean hasfilterBuilder = filterBuilder != null; boolean hasfilterBuilder = filterBuilder != null;
out.writeBoolean(hasfilterBuilder); out.writeBoolean(hasfilterBuilder);
if (hasfilterBuilder) { if (hasfilterBuilder) {
out.writeQuery(filterBuilder); out.writeNamedWriteable(filterBuilder);
} }
boolean hasIncExc = includeExclude != null; boolean hasIncExc = includeExclude != null;
out.writeBoolean(hasIncExc); out.writeBoolean(hasIncExc);

View File

@ -217,10 +217,10 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
minScore = in.readFloat(); minScore = in.readFloat();
} }
if (in.readBoolean()) { if (in.readBoolean()) {
postQueryBuilder = in.readQuery(); postQueryBuilder = in.readNamedWriteable(QueryBuilder.class);
} }
if (in.readBoolean()) { if (in.readBoolean()) {
queryBuilder = in.readQuery(); queryBuilder = in.readNamedWriteable(QueryBuilder.class);
} }
if (in.readBoolean()) { if (in.readBoolean()) {
int size = in.readVInt(); int size = in.readVInt();
@ -316,12 +316,12 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
boolean hasPostQuery = postQueryBuilder != null; boolean hasPostQuery = postQueryBuilder != null;
out.writeBoolean(hasPostQuery); out.writeBoolean(hasPostQuery);
if (hasPostQuery) { if (hasPostQuery) {
out.writeQuery(postQueryBuilder); out.writeNamedWriteable(postQueryBuilder);
} }
boolean hasQuery = queryBuilder != null; boolean hasQuery = queryBuilder != null;
out.writeBoolean(hasQuery); out.writeBoolean(hasQuery);
if (hasQuery) { if (hasQuery) {
out.writeQuery(queryBuilder); out.writeNamedWriteable(queryBuilder);
} }
boolean hasRescoreBuilders = rescoreBuilders != null; boolean hasRescoreBuilders = rescoreBuilders != null;
out.writeBoolean(hasRescoreBuilders); out.writeBoolean(hasRescoreBuilders);

View File

@ -115,7 +115,7 @@ public abstract class AbstractHighlighterBuilder<HB extends AbstractHighlighterB
highlighterType(in.readOptionalString()); highlighterType(in.readOptionalString());
fragmenter(in.readOptionalString()); fragmenter(in.readOptionalString());
if (in.readBoolean()) { if (in.readBoolean()) {
highlightQuery(in.readQuery()); highlightQuery(in.readNamedWriteable(QueryBuilder.class));
} }
order(in.readOptionalWriteable(Order::readFromStream)); order(in.readOptionalWriteable(Order::readFromStream));
highlightFilter(in.readOptionalBoolean()); highlightFilter(in.readOptionalBoolean());
@ -146,7 +146,7 @@ public abstract class AbstractHighlighterBuilder<HB extends AbstractHighlighterB
boolean hasQuery = highlightQuery != null; boolean hasQuery = highlightQuery != null;
out.writeBoolean(hasQuery); out.writeBoolean(hasQuery);
if (hasQuery) { if (hasQuery) {
out.writeQuery(highlightQuery); out.writeNamedWriteable(highlightQuery);
} }
out.writeOptionalWriteable(order); out.writeOptionalWriteable(order);
out.writeOptionalBoolean(highlightFilter); out.writeOptionalBoolean(highlightFilter);

View File

@ -79,7 +79,7 @@ public class QueryRescorerBuilder extends RescoreBuilder<QueryRescorerBuilder> {
*/ */
public QueryRescorerBuilder(StreamInput in) throws IOException { public QueryRescorerBuilder(StreamInput in) throws IOException {
super(in); super(in);
queryBuilder = in.readQuery(); queryBuilder = in.readNamedWriteable(QueryBuilder.class);
scoreMode = QueryRescoreMode.readFromStream(in); scoreMode = QueryRescoreMode.readFromStream(in);
rescoreQueryWeight = in.readFloat(); rescoreQueryWeight = in.readFloat();
queryWeight = in.readFloat(); queryWeight = in.readFloat();
@ -87,7 +87,7 @@ public class QueryRescorerBuilder extends RescoreBuilder<QueryRescorerBuilder> {
@Override @Override
public void doWriteTo(StreamOutput out) throws IOException { public void doWriteTo(StreamOutput out) throws IOException {
out.writeQuery(queryBuilder); out.writeNamedWriteable(queryBuilder);
scoreMode.writeTo(out); scoreMode.writeTo(out);
out.writeFloat(rescoreQueryWeight); out.writeFloat(rescoreQueryWeight);
out.writeFloat(queryWeight); out.writeFloat(queryWeight);

View File

@ -678,9 +678,9 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected <QB extends QueryBuilder> QB assertSerialization(QB testQuery) throws IOException { protected <QB extends QueryBuilder> QB assertSerialization(QB testQuery) throws IOException {
try (BytesStreamOutput output = new BytesStreamOutput()) { try (BytesStreamOutput output = new BytesStreamOutput()) {
output.writeQuery(testQuery); output.writeNamedWriteable(testQuery);
try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(output.bytes()), namedWriteableRegistry)) { try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(output.bytes()), namedWriteableRegistry)) {
QueryBuilder<?> deserializedQuery = in.readQuery(); QueryBuilder<?> deserializedQuery = in.readNamedWriteable(QueryBuilder.class);
assertEquals(testQuery, deserializedQuery); assertEquals(testQuery, deserializedQuery);
assertEquals(testQuery.hashCode(), deserializedQuery.hashCode()); assertEquals(testQuery.hashCode(), deserializedQuery.hashCode());
assertNotSame(testQuery, deserializedQuery); assertNotSame(testQuery, deserializedQuery);
@ -727,9 +727,9 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected QB copyQuery(QB query) throws IOException { protected QB copyQuery(QB query) throws IOException {
try (BytesStreamOutput output = new BytesStreamOutput()) { try (BytesStreamOutput output = new BytesStreamOutput()) {
output.writeQuery(query); output.writeNamedWriteable(query);
try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(output.bytes()), namedWriteableRegistry)) { try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(output.bytes()), namedWriteableRegistry)) {
return (QB) in.readQuery(); return (QB) in.readNamedWriteable(QueryBuilder.class);
} }
} }
} }