Java Code Examples for org.apache.kudu.client.RowResult#getDecimal()

The following examples show how to use org.apache.kudu.client.RowResult#getDecimal() . 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: TypeHelper.java    From presto with Apache License 2.0 5 votes vote down vote up
public static Object getObject(Type type, RowResult row, int field)
{
    if (row.isNull(field)) {
        return null;
    }
    if (type instanceof VarcharType) {
        return row.getString(field);
    }
    if (type.equals(TimestampType.TIMESTAMP)) {
        return row.getLong(field) / 1000;
    }
    if (type == BigintType.BIGINT) {
        return row.getLong(field);
    }
    if (type == IntegerType.INTEGER) {
        return row.getInt(field);
    }
    if (type == SmallintType.SMALLINT) {
        return row.getShort(field);
    }
    if (type == TinyintType.TINYINT) {
        return row.getByte(field);
    }
    if (type == DoubleType.DOUBLE) {
        return row.getDouble(field);
    }
    if (type == RealType.REAL) {
        return row.getFloat(field);
    }
    if (type == BooleanType.BOOLEAN) {
        return row.getBoolean(field);
    }
    if (type instanceof VarbinaryType) {
        return Slices.wrappedBuffer(row.getBinary(field));
    }
    if (type instanceof DecimalType) {
        return row.getDecimal(field);
    }
    throw new IllegalStateException("getObject not implemented for " + type);
}
 
Example 2
Source File: TypeHelper.java    From presto with Apache License 2.0 5 votes vote down vote up
public static Slice getSlice(Type type, RowResult row, int field)
{
    if (type instanceof VarcharType) {
        return Slices.utf8Slice(row.getString(field));
    }
    if (type instanceof VarbinaryType) {
        return Slices.wrappedBuffer(row.getBinary(field));
    }
    if (type instanceof DecimalType) {
        BigDecimal dec = row.getDecimal(field);
        return Decimals.encodeScaledValue(dec);
    }
    throw new IllegalStateException("getSlice not implemented for " + type);
}
 
Example 3
Source File: TypeHelper.java    From presto-kudu with Apache License 2.0 5 votes vote down vote up
public static Object getObject(Type type, RowResult row, int field) {
    if (row.isNull(field)) {
        return null;
    } else {
        if (type instanceof VarcharType) {
            return row.getString(field);
        } else if (type == TimestampType.TIMESTAMP) {
            return row.getLong(field) / 1000;
        } else if (type == BigintType.BIGINT) {
            return row.getLong(field);
        } else if (type == IntegerType.INTEGER) {
            return row.getInt(field);
        } else if (type == SmallintType.SMALLINT) {
            return row.getShort(field);
        } else if (type == TinyintType.TINYINT) {
            return row.getByte(field);
        } else if (type == DoubleType.DOUBLE) {
            return row.getDouble(field);
        } else if (type == RealType.REAL) {
            return row.getFloat(field);
        } else if (type == BooleanType.BOOLEAN) {
            return row.getBoolean(field);
        } else if (type instanceof VarbinaryType) {
            return Slices.wrappedBuffer(row.getBinary(field));
        } else if (type instanceof DecimalType) {
            return row.getDecimal(field);
        } else {
            throw new IllegalStateException("getObject not implemented for " + type);
        }
    }
}
 
Example 4
Source File: TypeHelper.java    From presto-kudu with Apache License 2.0 5 votes vote down vote up
public static Slice getSlice(Type type, RowResult row, int field) {
    if (type instanceof VarcharType) {
        return Slices.utf8Slice(row.getString(field));
    } else if (type instanceof VarbinaryType) {
        return Slices.wrappedBuffer(row.getBinary(field));
    } else if (type instanceof DecimalType) {
        BigDecimal dec = row.getDecimal(field);
        return Decimals.encodeScaledValue(dec);
    } else {
        throw new IllegalStateException("getSlice not implemented for " + type);
    }
}