Java Code Examples for org.apache.spark.unsafe.Platform#getLong()

The following examples show how to use org.apache.spark.unsafe.Platform#getLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BinarySearch.java    From indexr with Apache License 2.0 6 votes vote down vote up
public static int binarySearchLongs(ByteBufferReader reader, int count, long key) throws IOException {
    int from = 0;
    int to = count;

    --to;

    byte[] valBuffer = new byte[8];

    while (from <= to) {
        int mid = from + to >>> 1;
        reader.read(mid << 3, valBuffer, 0, 8);
        long midVal = Platform.getLong(valBuffer, Platform.BYTE_ARRAY_OFFSET);
        if (midVal < key) {
            from = mid + 1;
        } else if (midVal > key) {
            to = mid - 1;
        } else {
            return mid;
        }
    }

    return -(from + 1);
}
 
Example 2
Source File: ByteBufferReader.java    From indexr with Apache License 2.0 4 votes vote down vote up
default long readLong(long position) throws IOException {
    byte[] valBuffer = new byte[8];
    read(position, valBuffer, 0, 8);
    return Platform.getLong(valBuffer, Platform.BYTE_ARRAY_OFFSET);
}
 
Example 3
Source File: UnsafeRow.java    From indexr with Apache License 2.0 4 votes vote down vote up
@Override
public long getLong(int ordinal) {
    assertIndexIsValid(ordinal);
    return Platform.getLong(baseObject, getFieldOffset(ordinal));
}
 
Example 4
Source File: UnsafeRow.java    From indexr with Apache License 2.0 4 votes vote down vote up
@Override
public long getUniformVal(int ordinal) {
    assertIndexIsValid(ordinal);
    return Platform.getLong(baseObject, getFieldOffset(ordinal));
}
 
Example 5
Source File: UnsafeUtil.java    From indexr with Apache License 2.0 4 votes vote down vote up
public static long getLong(Object base, long addr) {
    return Platform.getLong(base, addr);
}