Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 28 additions & 50 deletions server/src/main/java/org/opensearch/common/lucene/Lucene.java
Original file line number Diff line number Diff line change
Expand Up @@ -358,62 +358,40 @@
Comparable[] cFields = new Comparable[in.readVInt()];
for (int j = 0; j < cFields.length; j++) {
byte type = in.readByte();
if (type == 0) {
cFields[j] = null;
} else if (type == 1) {
cFields[j] = in.readString();
} else if (type == 2) {
cFields[j] = in.readInt();
} else if (type == 3) {
cFields[j] = in.readLong();
} else if (type == 4) {
cFields[j] = in.readFloat();
} else if (type == 5) {
cFields[j] = in.readDouble();
} else if (type == 6) {
cFields[j] = in.readByte();
} else if (type == 7) {
cFields[j] = in.readShort();
} else if (type == 8) {
cFields[j] = in.readBoolean();
} else if (type == 9) {
cFields[j] = in.readBytesRef();
} else if (type == 10) {
cFields[j] = new BigInteger(in.readString());
} else {
throw new IOException("Can't match type [" + type + "]");
}
cFields[j] = switch (type) {
case 0 -> null;
case 1 -> in.readString();

Check warning on line 363 in server/src/main/java/org/opensearch/common/lucene/Lucene.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/common/lucene/Lucene.java#L362-L363

Added lines #L362 - L363 were not covered by tests
case 2 -> in.readInt();
case 3 -> in.readLong();
case 4 -> in.readFloat();
case 5 -> in.readDouble();
case 6 -> in.readByte();
case 7 -> in.readShort();
case 8 -> in.readBoolean();

Check warning on line 370 in server/src/main/java/org/opensearch/common/lucene/Lucene.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/common/lucene/Lucene.java#L368-L370

Added lines #L368 - L370 were not covered by tests
case 9 -> in.readBytesRef();
case 10 -> new BigInteger(in.readString());
default -> throw new IOException("Can't match type [" + type + "]");

Check warning on line 373 in server/src/main/java/org/opensearch/common/lucene/Lucene.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/common/lucene/Lucene.java#L372-L373

Added lines #L372 - L373 were not covered by tests
};
}
return new FieldDoc(in.readVInt(), in.readFloat(), cFields);
}

public static Comparable readSortValue(StreamInput in) throws IOException {
byte type = in.readByte();
if (type == 0) {
return null;
} else if (type == 1) {
return in.readString();
} else if (type == 2) {
return in.readInt();
} else if (type == 3) {
return in.readLong();
} else if (type == 4) {
return in.readFloat();
} else if (type == 5) {
return in.readDouble();
} else if (type == 6) {
return in.readByte();
} else if (type == 7) {
return in.readShort();
} else if (type == 8) {
return in.readBoolean();
} else if (type == 9) {
return in.readBytesRef();
} else if (type == 10) {
return new BigInteger(in.readString());
} else {
throw new IOException("Can't match type [" + type + "]");
}
return switch (type) {
case 0 -> null;
case 1 -> in.readString();
case 2 -> in.readInt();
case 3 -> in.readLong();
case 4 -> in.readFloat();
case 5 -> in.readDouble();
case 6 -> in.readByte();
case 7 -> in.readShort();
case 8 -> in.readBoolean();
case 9 -> in.readBytesRef();
case 10 -> new BigInteger(in.readString());
default -> throw new IOException("Can't match type [" + type + "]");

Check warning on line 393 in server/src/main/java/org/opensearch/common/lucene/Lucene.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/common/lucene/Lucene.java#L392-L393

Added lines #L392 - L393 were not covered by tests
};
}

public static ScoreDoc readScoreDoc(StreamInput in) throws IOException {
Expand Down
Loading