|
@@ -34,8 +34,6 @@ import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.stream.IntStream;
|
|
|
|
|
|
-import static org.elasticsearch.index.shard.ShardLongFieldRange.LONG_FIELD_RANGE_VERSION_INTRODUCED;
|
|
|
-
|
|
|
/**
|
|
|
* Class representing an (inclusive) range of {@code long} values in a field in an index which may comprise multiple shards. This
|
|
|
* information is accumulated shard-by-shard, and we keep track of which shards are represented in this value. Only once all shards are
|
|
@@ -120,33 +118,26 @@ public class IndexLongFieldRange implements Writeable, ToXContentFragment {
|
|
|
|
|
|
@Override
|
|
|
public void writeTo(StreamOutput out) throws IOException {
|
|
|
- if (out.getVersion().onOrAfter(LONG_FIELD_RANGE_VERSION_INTRODUCED)) {
|
|
|
- if (this == NO_SHARDS) {
|
|
|
- out.writeByte(WIRE_TYPE_NO_SHARDS);
|
|
|
- } else if (this == UNKNOWN) {
|
|
|
- out.writeByte(WIRE_TYPE_UNKNOWN);
|
|
|
- } else if (this == EMPTY) {
|
|
|
- out.writeByte(WIRE_TYPE_EMPTY);
|
|
|
+ if (this == NO_SHARDS) {
|
|
|
+ out.writeByte(WIRE_TYPE_NO_SHARDS);
|
|
|
+ } else if (this == UNKNOWN) {
|
|
|
+ out.writeByte(WIRE_TYPE_UNKNOWN);
|
|
|
+ } else if (this == EMPTY) {
|
|
|
+ out.writeByte(WIRE_TYPE_EMPTY);
|
|
|
+ } else {
|
|
|
+ out.writeByte(WIRE_TYPE_OTHER);
|
|
|
+ if (shards == null) {
|
|
|
+ out.writeBoolean(false);
|
|
|
} else {
|
|
|
- out.writeByte(WIRE_TYPE_OTHER);
|
|
|
- if (shards == null) {
|
|
|
- out.writeBoolean(false);
|
|
|
- } else {
|
|
|
- out.writeBoolean(true);
|
|
|
- out.writeVIntArray(shards);
|
|
|
- }
|
|
|
- out.writeZLong(min);
|
|
|
- out.writeZLong(max);
|
|
|
+ out.writeBoolean(true);
|
|
|
+ out.writeVIntArray(shards);
|
|
|
}
|
|
|
+ out.writeZLong(min);
|
|
|
+ out.writeZLong(max);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static IndexLongFieldRange readFrom(StreamInput in) throws IOException {
|
|
|
- if (in.getVersion().before(LONG_FIELD_RANGE_VERSION_INTRODUCED)) {
|
|
|
- // conservative treatment for BWC
|
|
|
- return UNKNOWN;
|
|
|
- }
|
|
|
-
|
|
|
final byte type = in.readByte();
|
|
|
switch (type) {
|
|
|
case WIRE_TYPE_NO_SHARDS:
|