Replace (read|write)Query with (read|write)NamedWriteable

(read|write)Query is going away.

Original commit: elastic/x-pack-elasticsearch@5ac3ded68e
This commit is contained in:
Nik Everett 2016-04-19 11:06:39 -04:00
parent e24d09b54e
commit 28bb39955c
1 changed files with 15 additions and 22 deletions

View File

@ -21,22 +21,22 @@ import java.util.List;
* A Hop represents one of potentially many stages in a graph exploration. * A Hop represents one of potentially many stages in a graph exploration.
* Each Hop identifies one or more fields in which it will attempt to find * Each Hop identifies one or more fields in which it will attempt to find
* terms that are significantly connected to the previous Hop. Each field is identified * terms that are significantly connected to the previous Hop. Each field is identified
* using a {@link VertexRequest} * using a {@link VertexRequest}
* *
* <p>An example series of Hops on webserver logs would be: * <p>An example series of Hops on webserver logs would be:
* <ol> * <ol>
* <li>an initial Hop to find * <li>an initial Hop to find
* the top ten IPAddresses trying to access urls containing the word "admin"</li> * the top ten IPAddresses trying to access urls containing the word "admin"</li>
* <li>a secondary Hop to see which other URLs those IPAddresses were trying to access</li> * <li>a secondary Hop to see which other URLs those IPAddresses were trying to access</li>
* </ol> * </ol>
* *
* <p> * <p>
* Optionally, each hop can contain a "guiding query" that further limits the set of documents considered. * Optionally, each hop can contain a "guiding query" that further limits the set of documents considered.
* In our weblog example above we might choose to constrain the second hop to only look at log records that * In our weblog example above we might choose to constrain the second hop to only look at log records that
* had a reponse code of 404. * had a reponse code of 404.
* </p> * </p>
* <p> * <p>
* If absent, the list of {@link VertexRequest}s is inherited from the prior Hop's list to avoid repeating * If absent, the list of {@link VertexRequest}s is inherited from the prior Hop's list to avoid repeating
* the fields that will be examined at each stage. * the fields that will be examined at each stage.
* </p> * </p>
* *
@ -64,12 +64,7 @@ public class Hop {
} }
void writeTo(StreamOutput out) throws IOException { void writeTo(StreamOutput out) throws IOException {
if (guidingQuery == null) { out.writeOptionalNamedWriteable(guidingQuery);
out.writeBoolean(false);
} else {
out.writeBoolean(true);
out.writeQuery(guidingQuery);
}
if (vertices == null) { if (vertices == null) {
out.writeVInt(0); out.writeVInt(0);
} else { } else {
@ -81,9 +76,7 @@ public class Hop {
} }
void readFrom(StreamInput in) throws IOException { void readFrom(StreamInput in) throws IOException {
if (in.readBoolean()) { guidingQuery = in.readOptionalNamedWriteable(QueryBuilder.class);
guidingQuery = in.readQuery();
}
int size = in.readVInt(); int size = in.readVInt();
if (size > 0) { if (size > 0) {
vertices = new ArrayList<>(); vertices = new ArrayList<>();
@ -103,9 +96,9 @@ public class Hop {
} }
/** /**
* Add a field in which this {@link Hop} will look for terms that are highly linked to * Add a field in which this {@link Hop} will look for terms that are highly linked to
* previous hops and optionally the guiding query. * previous hops and optionally the guiding query.
* *
* @param fieldName a field in the chosen index * @param fieldName a field in the chosen index
*/ */
public VertexRequest addVertexRequest(String fieldName) { public VertexRequest addVertexRequest(String fieldName) {
@ -120,8 +113,8 @@ public class Hop {
/** /**
* An optional parameter that focuses the exploration on documents that * An optional parameter that focuses the exploration on documents that
* match the given query. * match the given query.
* *
* @param queryBuilder any query * @param queryBuilder any query
*/ */
public void guidingQuery(QueryBuilder<?> queryBuilder) { public void guidingQuery(QueryBuilder<?> queryBuilder) {
@ -146,4 +139,4 @@ public class Hop {
VertexRequest getVertexRequest(int requestNumber) { VertexRequest getVertexRequest(int requestNumber) {
return getEffectiveVertexRequests().get(requestNumber); return getEffectiveVertexRequests().get(requestNumber);
} }
} }