RollUpBitMask { public static RollUpBitMask fromTagPositions(final List<Integer> tagPositions) { return fromTagPositions(new TreeSet<>(tagPositions)); } private  RollUpBitMask(final short mask); static RollUpBitMask fromShort(final short maskValue); static RollUpBitMask fromMask(final short[] mask); static RollUpBitMask fromRolledupTagList(final String allTags, final String rolledUpTags); static byte[] byteValueFromTagList(final String allTags, final String rolledUpTags); static int intValueFromTagList(final String allTags, final String rolledUpTags); static RollUpBitMask fromTagPositions(final List<Integer> tagPositions); static RollUpBitMask fromTagPositions(final SortedSet<Integer> tagPositions); static RollUpBitMask fromBytes(final byte[] bytes); static Set<RollUpBitMask> getRollUpBitMasks(final int tagCount); static Set<List<Boolean>> getRollUpPermutationsAsBooleans(final int tagCount); static Set<List<Integer>> getRollUpPermutationsAsPositions(final int tagCount); SortedSet<Integer> getTagPositions(); List<Integer> getTagPositionsAsList(); List<Boolean> getBooleanMask(final int tagCount); boolean isTagPositionRolledUp(final int tagPosition); RollUpBitMask convert(final Map<Integer, Integer> newToOldFieldPositionMap); short asShort(); byte[] asBytes(); String asHexString(); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj); static final short MASK_LENGTH; static final RollUpBitMask ZERO_MASK; static final String ROLL_UP_TAG_VALUE; }
@Test void testFromTagPositions() { final RollUpBitMask rowKeyBitMap1 = RollUpBitMask.fromTagPositions(Arrays.asList(1, 4, 14)); final RollUpBitMask rowKeyBitMap2 = RollUpBitMask .fromMask(new short[]{0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}); assertThat(rowKeyBitMap2).isEqualTo(rowKeyBitMap1); }
@Test void testFromTagPositionsNotInOrder() { final RollUpBitMask rowKeyBitMap1 = RollUpBitMask.fromTagPositions(Arrays.asList(1, 0)); final RollUpBitMask rowKeyBitMap2 = RollUpBitMask.fromTagPositions(Arrays.asList(0, 1)); assertThat(rowKeyBitMap2).isEqualTo(rowKeyBitMap1); }
@Test void testFromTagPositionsInvalidPosition() { assertThatThrownBy(() -> { RollUpBitMask.fromTagPositions(Arrays.asList(1, 4, 22)); }).isInstanceOf(RuntimeException.class); }