Skip to content

Commit

Permalink
Merge pull request elastic#11121 from cbuescher/feature/query-refacto…
Browse files Browse the repository at this point in the history
…ring-boolquery

Query refactoring: BoolQueryBuilder and Parser
  • Loading branch information
cbuescher committed Jun 11, 2015
2 parents 74db0de + 79b0332 commit 61fd57a
Show file tree
Hide file tree
Showing 7 changed files with 496 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,20 @@ public <C> C readNamedWriteable() throws IOException {
return namedWriteable.readFrom(this);
}

/**
* Reads a list of {@link NamedWriteable} from the current stream, by first reading its size and then
* reading the individual objects using {@link #readNamedWriteable()}.
*/
public <C> List<C> readNamedWritableList() throws IOException {
List<C> list = new ArrayList<>();
int size = readInt();
for (int i = 0; i < size; i++) {
C obj = readNamedWriteable();
list.add(obj);
}
return list;
}

public static StreamInput wrap(BytesReference reference) {
if (reference.hasArray() == false) {
reference = reference.toBytesArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,4 +457,15 @@ public void writeNamedWriteable(NamedWriteable namedWriteable) throws IOExceptio
writeString(namedWriteable.getName());
namedWriteable.writeTo(this);
}

/**
* Writes a list of {@link NamedWriteable} to the current stream, by first writing its size and then iterating over the objects
* in the list
*/
public void writeNamedWritableList(List<? extends NamedWriteable> list) throws IOException {
writeInt(list.size());
for (NamedWriteable obj : list) {
writeNamedWriteable(obj);
}
}
}
Loading

0 comments on commit 61fd57a

Please sign in to comment.