Example usage for com.google.common.primitives Longs BYTES

List of usage examples for com.google.common.primitives Longs BYTES

Introduction

In this page you can find the example usage for com.google.common.primitives Longs BYTES.

Prototype

int BYTES

To view the source code for com.google.common.primitives Longs BYTES.

Click Source Link

Document

The number of bytes required to represent a primitive long value.

Usage

From source file:io.druid.query.aggregation.last.LongLastBufferAggregator.java

@Override
public Object get(ByteBuffer buf, int position) {
    return new SerializablePair<>(buf.getLong(position), buf.getLong(position + Longs.BYTES));
}

From source file:io.druid.granularity.DurationGranularity.java

@Override
public byte[] cacheKey() {
    return ByteBuffer.allocate(2 * Longs.BYTES).putLong(length).putLong(origin).array();
}

From source file:org.kududb.Type.java

/**
 * Gives the size in bytes for a given DataType, as per the pb specification
 * @param type pb type/*from w ww  .j  a  v a2 s.c  om*/
 * @return size in bytes
 */
static int getTypeSize(DataType type) {
    switch (type) {
    case STRING:
    case BINARY:
        return 8 + 8; // offset then string length
    case BOOL:
    case INT8:
        return 1;
    case INT16:
        return Shorts.BYTES;
    case INT32:
    case FLOAT:
        return Ints.BYTES;
    case INT64:
    case DOUBLE:
    case TIMESTAMP:
        return Longs.BYTES;
    default:
        throw new IllegalArgumentException("The provided data type doesn't map" + " to know any known one.");
    }
}

From source file:io.druid.query.aggregation.last.DoubleLastBufferAggregator.java

@Override
public Object get(ByteBuffer buf, int position) {
    return new SerializablePair<>(buf.getLong(position), buf.getDouble(position + Longs.BYTES));
}

From source file:io.druid.query.aggregation.last.LongLastBufferAggregator.java

@Override
public float getFloat(ByteBuffer buf, int position) {
    return (float) buf.getLong(position + Longs.BYTES);
}

From source file:io.druid.query.aggregation.last.DoubleLastBufferAggregator.java

@Override
public float getFloat(ByteBuffer buf, int position) {
    return (float) buf.getDouble(position + Longs.BYTES);
}

From source file:alluxio.network.protocol.RPCFileReadRequest.java

@Override
public int getEncodedLength() {
    // 3 longs (mTempUfsFileId, mOffset, mLength)
    return Longs.BYTES * 3;
}

From source file:edu.mit.streamjit.util.affinity.LinuxAffinityStrategy.java

@Override
public void setThreadAffinity(long mask) {
    Pointer<Long> pmask = null;
    try {/*  w  w  w  .  j  ava  2  s. c o  m*/
        pmask = Pointer.allocateLong();
        pmask.set(mask);
        int ret = sched_setaffinity(0, new SizeT(Longs.BYTES), pmask);
        if (ret != 0)
            throw new RuntimeException();
    } finally {
        if (pmask != null)
            pmask.release();
    }
}

From source file:io.druid.query.aggregation.last.LongLastBufferAggregator.java

@Override
public long getLong(ByteBuffer buf, int position) {
    return buf.getLong(position + Longs.BYTES);
}

From source file:io.druid.query.aggregation.HistogramBufferAggregator.java

@Override
public void aggregate(ByteBuffer buf, int position) {
    final float value = selector.get();
    final int minPos = position + minOffset;
    final int maxPos = position + maxOffset;

    if (value < buf.getFloat(minPos))
        buf.putFloat(minPos, value);//from   www  . j a v  a2 s. c  om
    if (value > buf.getFloat(maxPos))
        buf.putFloat(maxPos, value);

    int index = Arrays.binarySearch(breaks, value);
    index = (index >= 0) ? index : -(index + 1);

    final int offset = position + (index * Longs.BYTES);
    final long count = buf.getLong(offset);
    buf.putLong(offset, count + 1);
}