Skip to content

Commit

Permalink
iter
Browse files Browse the repository at this point in the history
  • Loading branch information
iverase committed Nov 6, 2024
1 parent 4c96a5f commit c042130
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@
import org.apache.lucene.tests.store.MockDirectoryWrapper;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.core.IOUtils;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.index.fielddata.IndexFieldData;
Expand Down Expand Up @@ -571,6 +576,23 @@ public void testSortValueSerialization() throws IOException {
assertEquals(sortValue, deserialized);
}

private static <T> T copyInstance(
T original,
NamedWriteableRegistry namedWriteableRegistry,
Writeable.Writer<T> writer,
Writeable.Reader<T> reader,
TransportVersion version
) throws IOException {
try (BytesStreamOutput output = new BytesStreamOutput()) {
output.setTransportVersion(version);
writer.write(output, original);
try (StreamInput in = new NamedWriteableAwareStreamInput(output.bytes().streamInput(), namedWriteableRegistry)) {
in.setTransportVersion(version);
return reader.read(in);
}
}
}

public static Object randomSortValue() {
return switch (randomIntBetween(0, 9)) {
case 0 -> null;
Expand Down

0 comments on commit c042130

Please sign in to comment.