@Override public double getDouble(int ordinal) { assertIndexIsValid(ordinal); final int offset = getElementOffset(ordinal); if (offset < 0) return 0; return PlatformDependent.UNSAFE.getDouble(baseObject, baseOffset + offset); }
@Override public boolean getBoolean(int ordinal) { assertIndexIsValid(ordinal); final int offset = getElementOffset(ordinal); if (offset < 0) return false; return PlatformDependent.UNSAFE.getBoolean(baseObject, baseOffset + offset); }
@Override public MapData getMap(int ordinal) { assertIndexIsValid(ordinal); final int offset = getElementOffset(ordinal); if (offset < 0) return null; final int size = getElementSize(offset, ordinal); return UnsafeReaders.readMap(baseObject, baseOffset + offset, size); }
@Override public UTF8String getUTF8String(int ordinal) { assertIndexIsValid(ordinal); final int offset = getElementOffset(ordinal); if (offset < 0) return null; final int size = getElementSize(offset, ordinal); return UTF8String.fromAddress(baseObject, baseOffset + offset, size); }
@Override public CalendarInterval getInterval(int ordinal) { assertIndexIsValid(ordinal); final int offset = getElementOffset(ordinal); if (offset < 0) return null; final int months = (int) PlatformDependent.UNSAFE.getLong(baseObject, baseOffset + offset); final long microseconds = PlatformDependent.UNSAFE.getLong(baseObject, baseOffset + offset + 8); return new CalendarInterval(months, microseconds); }
@Override public InternalRow getStruct(int ordinal, int numFields) { assertIndexIsValid(ordinal); final int offset = getElementOffset(ordinal); if (offset < 0) return null; final int size = getElementSize(offset, ordinal); final UnsafeRow row = new UnsafeRow(); row.pointTo(baseObject, baseOffset + offset, numFields, size); return row; }
@Override public byte[] getBinary(int ordinal) { assertIndexIsValid(ordinal); final int offset = getElementOffset(ordinal); if (offset < 0) return null; final int size = getElementSize(offset, ordinal); final byte[] bytes = new byte[size]; PlatformDependent.copyMemory( baseObject, baseOffset + offset, bytes, PlatformDependent.BYTE_ARRAY_OFFSET, size); return bytes; }
@Override public Decimal getDecimal(int ordinal, int precision, int scale) { assertIndexIsValid(ordinal); final int offset = getElementOffset(ordinal); if (offset < 0) return null; if (precision <= Decimal.MAX_LONG_DIGITS()) { final long value = PlatformDependent.UNSAFE.getLong(baseObject, baseOffset + offset); return Decimal.apply(value, precision, scale); } else { final byte[] bytes = getBinary(ordinal); final BigInteger bigInteger = new BigInteger(bytes); final BigDecimal javaDecimal = new BigDecimal(bigInteger, scale); return Decimal.apply(new scala.math.BigDecimal(javaDecimal), precision, scale); } }
@Override public boolean isNullAt(int ordinal) { assertIndexIsValid(ordinal); return getElementOffset(ordinal) < 0; }