private static short setMaskValueAtPosition(final int position, final short existingMask) {
        // shift 1 to the left by the position in the mask
        // e.g. if you have '1' at position 2 you get 100
        final short maskForThisPos = (short) (1 << position);

        // OR the mask for this array position with the mask built up so far
        return (short) (existingMask | maskForThisPos);

        // byte[] bytes = Bytes.toBytes(maskForThisPos);
        // System.out.println(ByteArrayUtils.byteArrayToHex(bytes));
        // System.out.println(String.format("%15s",
        // Integer.toBinaryString(maskForThisPos)).replace(' ',
        // '0'));
        // System.out.println(String.format("%15s",
        // Integer.toBinaryString(tempMask)).replace(' ', '0'));

    }
Generates a {@link RollUpBitMask} from the passed set of rolled up tag
positions. It uses a cache of tag positions to save it having to build
the objects each time. For that reason the passed set must be sorted to
ensure it can be compared to ones in the cache, i.e. [0,1] == [1,0]

@param tagPositions A sorted set of the array position values at which a tag is
                    rolled up. E.g. if you have Tag1, Tag2 & Tag3 and only Tag2 is
                    rolled up then [1] would be passed as only tag at position 1
                    is rolled up.
@return The {@link RollUpBitMask} object representing the rolled up tag
positions.
stroom-statistics/stroom-statistics-impl-sql/src/main/java/stroom/statistics/impl/sql/rollup/RollUpBitMask.java