Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczi committed Jun 17, 2024
1 parent 8b800bb commit 2e3fef7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -450,23 +450,20 @@ public boolean hasValue() {
@Override
public void write(XContentBuilder b) throws IOException {
assert (children != null && children.size() > 0);
switch (children.size()) {
case 1 -> {
b.startObject(simpleName());
leafStoredFieldLoader.advanceTo(children.get(0));
leafSourceLoader.write(leafStoredFieldLoader, children.get(0), b);
if (children.size() == 1) {
b.startObject(simpleName());
leafStoredFieldLoader.advanceTo(children.get(0));
leafSourceLoader.write(leafStoredFieldLoader, children.get(0), b);
b.endObject();
} else {
b.startArray(simpleName());
for (int childId : children) {
b.startObject();
leafStoredFieldLoader.advanceTo(childId);
leafSourceLoader.write(leafStoredFieldLoader, childId, b);
b.endObject();
}
default -> {
b.startArray(simpleName());
for (int childId : children) {
b.startObject();
leafStoredFieldLoader.advanceTo(childId);
leafSourceLoader.write(leafStoredFieldLoader, childId, b);
b.endObject();
}
b.endArray();
}
b.endArray();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ private void roundTripSyntheticSource(DocumentMapper mapper, String syntheticSou
try (Directory roundTripDirectory = newDirectory()) {
RandomIndexWriter roundTripIw = indexWriterForSyntheticSource(roundTripDirectory);
ParsedDocument doc = mapper.parse(new SourceToParse("1", new BytesArray(syntheticSource), XContentType.JSON));
// Process root and nested documents in the same way as the normal indexing chain (assuming a single document)
doc.updateSeqID(0, 0);
doc.version().setLongValue(0);
roundTripIw.addDocuments(doc.docs());
Expand Down

0 comments on commit 2e3fef7

Please sign in to comment.