/** Returns the number of settings that have values assigned. */ int size() { return Integer.bitCount(set); }
@Override public int size() { return Integer.bitCount(mask); }
private static int bitCount(byte data) { return Integer.bitCount(data & 0xFF); } }
@Override public boolean isValid(Integer value, ConstraintValidatorContext context) { return value == null || Integer.bitCount(value) == 1; } }
@Override public int size() { return Integer.bitCount(mask); }
/** Returns the number of settings that have values assigned. */ int size() { return Integer.bitCount(set); }
private static int stripeMask( int count ) { assert Integer.bitCount( count ) == 1; return count - 1; }
public LocalPartitionGenerator(HashGenerator hashGenerator, int partitionCount) { this.hashGenerator = hashGenerator; checkArgument(Integer.bitCount(partitionCount) == 1, "partitionCount must be a power of 2"); this.partitionCount = partitionCount; hashMask = partitionCount - 1; }
private static int countContinuationBytes(long i64) { // Count the number of bytes that match 0b10xx_xxxx as follows: // 1. Mask off the 8th bit of every byte and shift it into the 7th position. // 2. Then invert the bytes, which turns the 0 in the 7th bit to a one. // 3. And together the restults of step 1 and 2, giving us a one in the 7th // position if the byte matched. // 4. Count the number of bits in the result, which is the number of bytes // that matched. i64 = ((i64 & TOP_MASK64) >>> 1) & (~i64); return Long.bitCount(i64); } }
public PartitionedLookupSourceFactory(List<Type> types, List<Type> outputTypes, List<Type> hashChannelTypes, int partitionCount, Map<Symbol, Integer> layout, boolean outer) { checkArgument(Integer.bitCount(partitionCount) == 1, "partitionCount must be a power of 2"); this.types = ImmutableList.copyOf(requireNonNull(types, "types is null")); this.outputTypes = ImmutableList.copyOf(requireNonNull(outputTypes, "outputTypes is null")); this.hashChannelTypes = ImmutableList.copyOf(hashChannelTypes); this.layout = ImmutableMap.copyOf(layout); checkArgument(partitionCount > 0); this.partitions = (Supplier<LookupSource>[]) new Supplier<?>[partitionCount]; this.outer = outer; spilledLookupSource = new SpilledLookupSource(outputTypes.size()); }
private static int validateValueIsPowerOfTwo(Object value, String property) { int intValue = ((Number) requireNonNull(value, "value is null")).intValue(); if (Integer.bitCount(intValue) != 1) { throw new PrestoException( INVALID_SESSION_PROPERTY, format("%s must be a power of 2: %s", property, intValue)); } return intValue; }
/** * Gets the number of set bits within the literal word * * @param word literal word * * @return the number of set bits within the literal word */ public static int getLiteralBitCount(int word) { return Integer.bitCount(getLiteralBits(word)); }
/** * Gets the number of set bits within the literal word * * @param word literal word * * @return the number of set bits within the literal word */ private static int getLiteralBitCount(int word) { return Integer.bitCount(getLiteralBits(word)); }
public void start() throws CanalStoreException { super.start(); if (Integer.bitCount(bufferSize) != 1) { throw new IllegalArgumentException("bufferSize must be a power of 2"); } indexMask = bufferSize - 1; entries = new Event[bufferSize]; }
public void start() throws CanalStoreException { super.start(); if (Integer.bitCount(bufferSize) != 1) { throw new IllegalArgumentException("bufferSize must be a power of 2"); } Assert.notNull(flushCallback, "flush callback is null!"); indexMask = bufferSize - 1; entries = new CanalEntry.Entry[bufferSize]; }
public static boolean isLiteralWithSingleOneBit(int word) { return isLiteral(word) && (Integer.bitCount(word) == 2); }
public static boolean isLiteralWithSingleZeroBit(int word) { return isLiteral(word) && Integer.bitCount(word) == 31; }
private void allocateMemory( int newCapacity ) { checkArgument( newCapacity > 1 && bitCount( newCapacity ) == 1, "Capacity must be power of 2" ); capacity = newCapacity; resizeOccupancyThreshold = (int) (newCapacity * LOAD_FACTOR); resizeRemovalsThreshold = (int) (newCapacity * REMOVALS_FACTOR); memory = allocator.allocate( newCapacity * ENTRY_SIZE, true ); }
@OutputFunction(StandardTypes.BIGINT) public static void evaluateFinal(BooleanDistinctState state, BlockBuilder out) { BIGINT.writeLong(out, Integer.bitCount(state.getByte())); } }