public static void setShort(byte[] bytes, int index, short value) { checkIndexLength(bytes.length, index, SIZE_OF_SHORT); unsafe.putShort(bytes, ((long) ARRAY_BYTE_BASE_OFFSET) + index, value); }
private void parseDoubleColumn(int column, byte[] bytes, int start, int length) { if (length == 0) { nulls[column] = true; } else { nulls[column] = false; if (hiveTypes[column].equals(HIVE_FLOAT)) { // the file format uses big endian checkState(length == SIZE_OF_INT, "Float should be 4 bytes"); int intBits = ByteArrays.getInt(bytes, start); doubles[column] = Float.intBitsToFloat(Integer.reverseBytes(intBits)); } else if (hiveTypes[column].equals(HIVE_DOUBLE)) { // the file format uses big endian checkState(length == SIZE_OF_LONG, "Double should be 8 bytes"); long longBits = ByteArrays.getLong(bytes, start); doubles[column] = Double.longBitsToDouble(Long.reverseBytes(longBits)); } else { throw new RuntimeException(format("%s is not a valid DOUBLE type", hiveTypes[column])); } } }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testReadingShortBounds() { ByteArrays.getShort(new byte[3], 2); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testReadingLongBounds() { ByteArrays.getLong(new byte[9], 2); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testReadingIntBounds() { ByteArrays.getInt(new byte[5], 2); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testWritingDoubleBounds() { ByteArrays.setDouble(new byte[9], 2, 123.0); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testReadingFloatBounds() { ByteArrays.getFloat(new byte[5], 2); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testWritingLongBounds() { ByteArrays.setLong(new byte[9], 2, 123); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testWritingIntBounds() { ByteArrays.setInt(new byte[5], 2, 123); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testWritingFloatBounds() { ByteArrays.setFloat(new byte[5], 2, 123.0f); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testReadingDoubleBounds() { ByteArrays.getDouble(new byte[9], 2); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testReadingShortBounds() { ByteArrays.getShort(new byte[3], 2); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testReadingLongBounds() { ByteArrays.getLong(new byte[9], 2); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testReadingIntBounds() { ByteArrays.getInt(new byte[5], 2); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testWritingDoubleBounds() { ByteArrays.setDouble(new byte[9], 2, 123.0); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testReadingFloatBounds() { ByteArrays.getFloat(new byte[5], 2); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testWritingLongBounds() { ByteArrays.setLong(new byte[9], 2, 123); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testWritingIntBounds() { ByteArrays.setInt(new byte[5], 2, 123); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testWritingFloatBounds() { ByteArrays.setFloat(new byte[5], 2, 123.0f); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testReadingDoubleBounds() { ByteArrays.getDouble(new byte[9], 2); }