Skip to content

Commit

Permalink
Remove unused IndicesOptions#fromByte method (elastic#50665)
Browse files Browse the repository at this point in the history
This change removes a no longer used method, `fromByte`, in
IndicesOptions. This method was necessary for backwards compatibility
with versions prior to 6.4.0 and was used when talking to those
versions. However, the minimum wire compatibility version has changed
and we no longer use this code.
  • Loading branch information
jaymode authored and SivagurunathanV committed Jan 21, 2020
1 parent b1db9f4 commit e951a81
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,42 +118,6 @@ private IndicesOptions(Collection<Option> options, Collection<WildcardStates> ex
expandWildcards.isEmpty() ? WildcardStates.NONE : EnumSet.copyOf(expandWildcards));
}

// Package visible for testing
static IndicesOptions fromByte(final byte id) {
// IGNORE_UNAVAILABLE = 1;
// ALLOW_NO_INDICES = 2;
// EXPAND_WILDCARDS_OPEN = 4;
// EXPAND_WILDCARDS_CLOSED = 8;
// FORBID_ALIASES_TO_MULTIPLE_INDICES = 16;
// FORBID_CLOSED_INDICES = 32;
// IGNORE_ALIASES = 64;

Set<Option> opts = new HashSet<>();
Set<WildcardStates> wildcards = new HashSet<>();
if ((id & 1) != 0) {
opts.add(Option.IGNORE_UNAVAILABLE);
}
if ((id & 2) != 0) {
opts.add(Option.ALLOW_NO_INDICES);
}
if ((id & 4) != 0) {
wildcards.add(WildcardStates.OPEN);
}
if ((id & 8) != 0) {
wildcards.add(WildcardStates.CLOSED);
}
if ((id & 16) != 0) {
opts.add(Option.FORBID_ALIASES_TO_MULTIPLE_INDICES);
}
if ((id & 32) != 0) {
opts.add(Option.FORBID_CLOSED_INDICES);
}
if ((id & 64) != 0) {
opts.add(Option.IGNORE_ALIASES);
}
return new IndicesOptions(opts, wildcards);
}

/**
* @return Whether specified concrete indices should be ignored when unavailable (missing or closed)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,31 +160,6 @@ public void testFromParameters() {
assertEquals(defaultOptions.ignoreAliases(), updatedOptions.ignoreAliases());
}

public void testSimpleByteBWC() {
Map<Byte, IndicesOptions> old = new HashMap<>();
// These correspond to each individual option (bit) in the old byte-based IndicesOptions
old.put((byte) 0, IndicesOptions.fromOptions(false, false, false, false, true, false, false, false));
old.put((byte) 1, IndicesOptions.fromOptions(true, false, false, false, true, false, false, false));
old.put((byte) 2, IndicesOptions.fromOptions(false, true, false, false, true, false, false, false));
old.put((byte) 4, IndicesOptions.fromOptions(false, false, true, false, true, false, false, false));
old.put((byte) 8, IndicesOptions.fromOptions(false, false, false, true, true, false, false, false));
old.put((byte) 16, IndicesOptions.fromOptions(false, false, false, false, false, false, false, false));
old.put((byte) 32, IndicesOptions.fromOptions(false, false, false, false, true, true, false, false));
old.put((byte) 64, IndicesOptions.fromOptions(false, false, false, false, true, false, true, false));
// Test a few multi-selected options
old.put((byte) 13, IndicesOptions.fromOptions(true, false, true, true, true, false, false, false));
old.put((byte) 19, IndicesOptions.fromOptions(true, true, false, false, false, false, false, false));
old.put((byte) 24, IndicesOptions.fromOptions(false, false, false, true, false, false, false, false));
old.put((byte) 123, IndicesOptions.fromOptions(true, true, false, true, false, true, true, false));

for (Map.Entry<Byte, IndicesOptions> entry : old.entrySet()) {
IndicesOptions indicesOptions2 = IndicesOptions.fromByte(entry.getKey());
logger.info("--> 1 {}", entry.getValue().toString());
logger.info("--> 2 {}", indicesOptions2.toString());
assertThat("IndicesOptions for byte " + entry.getKey() + " differ for conversion",indicesOptions2, equalTo(entry.getValue()));
}
}

public void testEqualityAndHashCode() {
IndicesOptions indicesOptions = IndicesOptions.fromOptions(
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(),
Expand Down

0 comments on commit e951a81

Please sign in to comment.