Skip to content

Commit

Permalink
Update versions in SearchSortValues transport serialization
Browse files Browse the repository at this point in the history
Now that #36617 is backported to 6.x, the version in the transport serialization conditionals for the search sort values can be updated to 6.6.0
  • Loading branch information
javanna committed Dec 18, 2018
1 parent 1aad08c commit bd12e00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public SearchSortValues(Object[] rawSortValues, DocValueFormat[] sortValueFormat

SearchSortValues(StreamInput in) throws IOException {
this.formattedSortValues = in.readArray(Lucene::readSortValue, Object[]::new);
if (in.getVersion().onOrAfter(Version.V_7_0_0)) {
if (in.getVersion().onOrAfter(Version.V_6_6_0)) {
this.rawSortValues = in.readArray(Lucene::readSortValue, Object[]::new);
} else {
this.rawSortValues = EMPTY_ARRAY;
Expand All @@ -77,7 +77,7 @@ public SearchSortValues(Object[] rawSortValues, DocValueFormat[] sortValueFormat
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeArray(Lucene::writeSortValue, this.formattedSortValues);
if (out.getVersion().onOrAfter(Version.V_7_0_0)) {
if (out.getVersion().onOrAfter(Version.V_6_6_0)) {
out.writeArray(Lucene::writeSortValue, this.rawSortValues);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,17 @@ protected SearchSortValues mutateInstance(SearchSortValues instance) {
return new SearchSortValues(values);
}

//TODO rename and update version after backport
public void testSerializationPre70() throws IOException {
Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0));
public void testSerializationPre6_6_0() throws IOException {
Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_6_6_0));
SearchSortValues original = createTestInstance();
SearchSortValues deserialized = copyInstance(original, version);
assertArrayEquals(original.getFormattedSortValues(), deserialized.getFormattedSortValues());
assertEquals(0, deserialized.getRawSortValues().length);
}

//TODO rename method and adapt versions after backport
public void testReadFromPre70() throws IOException {
public void testReadFromPre6_6_0() throws IOException {
try (StreamInput in = StreamInput.wrap(Base64.getDecoder().decode("AwIAAAABAQEyBUAIAAAAAAAAAAAAAAAA"))) {
in.setVersion(VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0)));
in.setVersion(VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_6_6_0)));
SearchSortValues deserialized = new SearchSortValues(in);
SearchSortValues expected = new SearchSortValues(new Object[]{1, "2", 3d});
assertEquals(expected, deserialized);
Expand Down

0 comments on commit bd12e00

Please sign in to comment.