Search in sources :

Example 1 with TemporalNativeType

use of org.apache.ignite.internal.schema.TemporalNativeType in project ignite-3 by apache.

the class RowAssembler method appendTimestamp.

/**
 * Appends Instant value for the current column to the chunk.
 *
 * @param val Column value.
 * @return {@code this} for chaining.
 * @throws SchemaMismatchException If a value doesn't match the current column type.
 */
public RowAssembler appendTimestamp(Instant val) throws SchemaMismatchException {
    checkType(NativeTypeSpec.TIMESTAMP);
    TemporalNativeType type = (TemporalNativeType) curCols.column(curCol).type();
    long seconds = val.getEpochSecond();
    int nanos = TemporalTypesHelper.normalizeNanos(val.getNano(), type.precision());
    buf.putLong(curOff, seconds);
    if (type.precision() != 0) {
        // Write only meaningful bytes.
        buf.putInt(curOff + 8, nanos);
    }
    shiftColumn(type.sizeInBytes());
    return this;
}
Also used : TemporalNativeType(org.apache.ignite.internal.schema.TemporalNativeType)

Example 2 with TemporalNativeType

use of org.apache.ignite.internal.schema.TemporalNativeType in project ignite-3 by apache.

the class RowAssembler method appendDateTime.

/**
 * Appends LocalDateTime value for the current column to the chunk.
 *
 * @param val Column value.
 * @return {@code this} for chaining.
 * @throws SchemaMismatchException If a value doesn't match the current column type.
 */
public RowAssembler appendDateTime(LocalDateTime val) throws SchemaMismatchException {
    checkType(NativeTypeSpec.DATETIME);
    TemporalNativeType type = (TemporalNativeType) curCols.column(curCol).type();
    int date = TemporalTypesHelper.encodeDate(val.toLocalDate());
    writeDate(curOff, date);
    writeTime(buf, curOff + 3, val.toLocalTime(), type);
    shiftColumn(type.sizeInBytes());
    return this;
}
Also used : TemporalNativeType(org.apache.ignite.internal.schema.TemporalNativeType)

Example 3 with TemporalNativeType

use of org.apache.ignite.internal.schema.TemporalNativeType in project ignite-3 by apache.

the class Row method dateTimeValue.

/**
 * Reads value for specified column.
 *
 * @param col Column index.
 * @return Column value.
 * @throws InvalidTypeException If actual column type does not match the requested column type.
 */
public LocalDateTime dateTimeValue(int col) throws InvalidTypeException {
    long offLen = findColumn(col, NativeTypeSpec.DATETIME);
    if (offLen < 0) {
        return null;
    }
    int off = offset(offLen);
    TemporalNativeType type = (TemporalNativeType) schema.column(col).type();
    return LocalDateTime.of(readDate(off), readTime(off + 3, type));
}
Also used : TemporalNativeType(org.apache.ignite.internal.schema.TemporalNativeType)

Example 4 with TemporalNativeType

use of org.apache.ignite.internal.schema.TemporalNativeType in project ignite-3 by apache.

the class Row method timeValue.

/**
 * Reads value for specified column.
 *
 * @param col Column index.
 * @return Column value.
 * @throws InvalidTypeException If actual column type does not match the requested column type.
 */
public LocalTime timeValue(int col) throws InvalidTypeException {
    long offLen = findColumn(col, NativeTypeSpec.TIME);
    if (offLen < 0) {
        return null;
    }
    int off = offset(offLen);
    TemporalNativeType type = (TemporalNativeType) schema.column(col).type();
    return readTime(off, type);
}
Also used : TemporalNativeType(org.apache.ignite.internal.schema.TemporalNativeType)

Example 5 with TemporalNativeType

use of org.apache.ignite.internal.schema.TemporalNativeType in project ignite-3 by apache.

the class Row method timestampValue.

/**
 * Reads value for specified column.
 *
 * @param col Column index.
 * @return Column value.
 * @throws InvalidTypeException If actual column type does not match the requested column type.
 */
public Instant timestampValue(int col) throws InvalidTypeException {
    long offLen = findColumn(col, NativeTypeSpec.TIMESTAMP);
    if (offLen < 0) {
        return null;
    }
    int off = offset(offLen);
    TemporalNativeType type = (TemporalNativeType) schema.column(col).type();
    long seconds = readLong(off);
    int nanos = 0;
    if (type.precision() != 0) {
        nanos = readInteger(off + 8);
    }
    return Instant.ofEpochSecond(seconds, nanos);
}
Also used : TemporalNativeType(org.apache.ignite.internal.schema.TemporalNativeType)

Aggregations

TemporalNativeType (org.apache.ignite.internal.schema.TemporalNativeType)6