Serialization improvement
This commit is contained in:
parent
1792bd6b16
commit
6163c7d8e5
|
@ -32,11 +32,12 @@ public enum IndexShardState {
|
||||||
RELOCATED((byte) 4),
|
RELOCATED((byte) 4),
|
||||||
CLOSED((byte) 5);
|
CLOSED((byte) 5);
|
||||||
|
|
||||||
private static final IndexShardState[] ORDS = new IndexShardState[IndexShardState.values().length];
|
private static final IndexShardState[] IDS = new IndexShardState[IndexShardState.values().length];
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (IndexShardState state : IndexShardState.values()) {
|
for (IndexShardState state : IndexShardState.values()) {
|
||||||
ORDS[state.id()] = state;
|
assert state.id() < IDS.length && state.id() >= 0;
|
||||||
|
IDS[state.id()] = state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,9 +52,9 @@ public enum IndexShardState {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IndexShardState fromId(byte id) throws ElasticSearchIllegalArgumentException {
|
public static IndexShardState fromId(byte id) throws ElasticSearchIllegalArgumentException {
|
||||||
if (id < ORDS[0].id && id > ORDS[ORDS.length - 1].id) {
|
if (id < 0 || id >= IDS.length) {
|
||||||
throw new ElasticSearchIllegalArgumentException("No mapping for id [" + id + "]");
|
throw new ElasticSearchIllegalArgumentException("No mapping for id [" + id + "]");
|
||||||
}
|
}
|
||||||
return ORDS[id];
|
return IDS[id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue