public static long nextHighestPowerOfTwo(long v) {
        v--;
        v |= v >> 1;
        v |= v >> 2;
        v |= v >> 4;
        v |= v >> 8;
        v |= v >> 16;
        v |= v >> 32;
        v++;
        return v;
    }
returns the next highest power of two, or the current value if it's already a power of two or zero
indexr-common/src/main/java/io/indexr/util/BitUtil.java