Search in sources :

Example 1 with TimestampType

use of com.facebook.presto.spi.type.TimestampType in project carbondata by apache.

the class CarbondataRecordCursor method getLong.

@Override
public long getLong(int field) {
    Object obj = getFieldValue(field);
    Long timeStr = 0L;
    if (obj instanceof Integer) {
        timeStr = ((Integer) obj).longValue();
    } else if (obj instanceof Long) {
        timeStr = (Long) obj;
    } else {
        timeStr = Math.round(Double.parseDouble(obj.toString()));
    }
    Type actual = getType(field);
    if (actual instanceof TimestampType) {
        return new Timestamp(timeStr).getTime() / 1000;
    } else if (isShortDecimal(actual)) {
        return shortDecimalPartitionKey(obj.toString(), (DecimalType) actual, columnHandles.get(field).getColumnName());
    }
    // suppose the
    return timeStr;
}
Also used : BigInteger(java.math.BigInteger) DataType(org.apache.carbondata.core.metadata.datatype.DataType) DecimalType(com.facebook.presto.spi.type.DecimalType) Type(com.facebook.presto.spi.type.Type) TimestampType(com.facebook.presto.spi.type.TimestampType) TimestampType(com.facebook.presto.spi.type.TimestampType) DecimalType(com.facebook.presto.spi.type.DecimalType) Timestamp(java.sql.Timestamp)

Aggregations

DecimalType (com.facebook.presto.spi.type.DecimalType)1 TimestampType (com.facebook.presto.spi.type.TimestampType)1 Type (com.facebook.presto.spi.type.Type)1 BigInteger (java.math.BigInteger)1 Timestamp (java.sql.Timestamp)1 DataType (org.apache.carbondata.core.metadata.datatype.DataType)1