List of usage examples for com.google.common.primitives Ints BYTES
int BYTES
To view the source code for com.google.common.primitives Ints BYTES.
Click Source Link
From source file:io.druid.segment.data.ByteBufferSerializer.java
public static <T> void writeToChannel(T obj, ObjectStrategy<T> strategy, WritableByteChannel channel) throws IOException { byte[] toWrite = strategy.toBytes(obj); channel.write(ByteBuffer.allocate(Ints.BYTES).putInt(0, toWrite.length)); channel.write(ByteBuffer.wrap(toWrite)); }
From source file:com.metamx.druid.kv.IntBufferIndexedInts.java
public static IntBufferIndexedInts fromArray(int[] array) { final ByteBuffer buffer = ByteBuffer.allocate(array.length * Ints.BYTES); buffer.asIntBuffer().put(array);//from ww w . ja va2s . com return new IntBufferIndexedInts(buffer.asReadOnlyBuffer()); }
From source file:com.eightkdata.mongowp.server.util.EnumInt32FlagsUtil.java
private static <T extends Enum<T> & EnumBitFlags> int getInt32FlagsArray(@Nullable Collection<T> flags) { if (null == flags || flags.isEmpty()) { return 0; }//w ww . j a va 2s . c o m BitSet bitSet = new BitSet(Ints.BYTES); for (T t : flags) { bitSet.set(t.getFlagBitPosition()); } return convert(bitSet); }
From source file:com.metamx.druid.kv.IntBufferIndexedInts.java
public static IntBufferIndexedInts fromIntList(IntList intList) { final ByteBuffer buffer = ByteBuffer.allocate(intList.length() * Ints.BYTES); final IntBuffer intBuf = buffer.asIntBuffer(); for (int i = 0; i < intList.length(); ++i) { intBuf.put(intList.get(i));/* www . j av a 2 s .c o m*/ } return new IntBufferIndexedInts(buffer.asReadOnlyBuffer()); }
From source file:com.metamx.collections.spatial.ImmutableRTree.java
private static int calcNumBytes(RTree tree) { int total = 1 + Ints.BYTES; // VERSION and numDims total += calcNodeBytes(tree.getRoot()); return total; }
From source file:com.yandex.yoctodb.util.UnsignedByteArrays.java
public static int toInt(@NotNull final UnsignedByteArray bytes) { if (bytes.length() != Ints.BYTES) throw new IllegalArgumentException("Wrong length"); return Ints.fromByteArray(bytes.data) ^ Integer.MIN_VALUE; }
From source file:io.druid.query.groupby.epinephelinae.column.StringGroupByColumnSelectorStrategy.java
@Override public int getGroupingKeySize() { return Ints.BYTES; }
From source file:io.druid.query.groupby.epinephelinae.ByteBufferIntList.java
public ByteBufferIntList(ByteBuffer buffer, int maxElements) { this.buffer = buffer; this.maxElements = maxElements; this.numElements = 0; if (buffer.capacity() < (maxElements * Ints.BYTES)) { throw new IAE("buffer for list is too small, was [%s] bytes, but need [%s] bytes.", buffer.capacity(), maxElements * Ints.BYTES); }//from w ww . jav a 2 s.c o m }
From source file:org.apache.drill.exec.store.parquet.decimal.Int32DecimalParquetValueWriter.java
@Override public void writeValue(RecordConsumer consumer, DrillBuf buffer, int start, int end, int precision) { byte[] output; int startPos; int length = end - start; startPos = Ints.BYTES - length; output = new byte[Ints.BYTES]; if (startPos >= 0) { buffer.getBytes(start, output, startPos, length); } else {/*from w ww . j a v a 2 s.co m*/ // in this case value from FIXED_LEN_BYTE_ARRAY or BINARY field was taken, ignore leading bytes buffer.getBytes(start - startPos, output, 0, length + startPos); startPos = 0; } if (output[startPos] < 0) { Arrays.fill(output, 0, output.length - length, (byte) -1); } consumer.addInteger(Ints.fromByteArray(output)); }
From source file:io.druid.query.groupby.epinephelinae.IntKeySerde.java
@Override public int keySize() { return Ints.BYTES; }