Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused IndicesOptions#fromByte method #50665

Merged
merged 1 commit into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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