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

The following examples show how to use org.apache.spark.unsafe.Platform#getDouble() . 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 binarySearchDoubles(ByteBufferReader reader, int count, double 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);
        double midVal = Platform.getDouble(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: UnsafeRow.java    From indexr with Apache License 2.0 4 votes vote down vote up
@Override
public float getFloat(int ordinal) {
    assertIndexIsValid(ordinal);
    //return Platform.getFloat(baseObject, getFieldOffset(ordinal));
    return (float) Platform.getDouble(baseObject, getFieldOffset(ordinal));
}
 
Example 3
Source File: UnsafeRow.java    From indexr with Apache License 2.0 4 votes vote down vote up
@Override
public double getDouble(int ordinal) {
    assertIndexIsValid(ordinal);
    return Platform.getDouble(baseObject, getFieldOffset(ordinal));
}
 
Example 4
Source File: UnsafeUtil.java    From indexr with Apache License 2.0 4 votes vote down vote up
public static double getDouble(Object base, long addr) {
    return Platform.getDouble(base, addr);
}