Skip to content

Commit

Permalink
Accept slots as String using CLUSTER SHARDS #2325
Browse files Browse the repository at this point in the history
  • Loading branch information
mp911de committed Jul 25, 2023
1 parent f43581c commit 20e6720
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,21 +297,30 @@ private static BitSet readSlots(List<String> slotStrings) {
return slots;
}

private static BitSet readSlotRanges(List<Integer> slotRanges) {
private static BitSet readSlotRanges(List<?> slotRanges) {

BitSet slots = new BitSet(SlotHash.SLOT_COUNT);

for (int i = 0; i < slotRanges.size(); i += 2) {

Number from = slotRanges.get(i);
Number to = slotRanges.get(i + 1);
Number from = getAsNumber(slotRanges.get(i));
Number to = getAsNumber(slotRanges.get(i + 1));

addSlots(slots, from.intValue(), to.intValue());
}

return slots;
}

private static Number getAsNumber(Object stringOrNumber) {

if (stringOrNumber instanceof Number) {
return (Number) stringOrNumber;
}

return Integer.parseInt(stringOrNumber.toString());
}

private static void addSlots(BitSet slots, int from, int to) {
for (int slot = from; slot <= to; slot++) {
slots.set(slot);
Expand Down

0 comments on commit 20e6720

Please sign in to comment.