Sha256: 9290bf0e1fcbb0a1612a6a7a59e7275e65a460a315131c0b8dcf963b15a1ee5e

Contents?: true

Size: 1.73 KB

Versions: 78

Compression:

Stored size: 1.73 KB

Contents

package org.embulk.spi.util.dynamic;

import org.embulk.spi.PageBuilder;
import org.embulk.spi.Column;
import org.embulk.spi.time.Timestamp;
import org.embulk.spi.time.TimestampParser;
import org.embulk.spi.time.TimestampParseException;
import org.msgpack.value.Value;

public class TimestampColumnSetter
        extends AbstractDynamicColumnSetter
{
    private final TimestampParser timestampParser;

    public TimestampColumnSetter(PageBuilder pageBuilder, Column column,
            DefaultValueSetter defaultValue,
            TimestampParser timestampParser)
    {
        super(pageBuilder, column, defaultValue);
        this.timestampParser = timestampParser;
    }

    @Override
    public void setNull()
    {
        pageBuilder.setNull(column);
    }

    @Override
    public void set(boolean v)
    {
        defaultValue.setTimestamp(pageBuilder, column);
    }

    @Override
    public void set(long v)
    {
        pageBuilder.setTimestamp(column, Timestamp.ofEpochSecond(v));
    }

    @Override
    public void set(double v)
    {
        long sec = (long) v;
        int nsec = (int) ((v - (double) sec) * 1000000000);
        pageBuilder.setTimestamp(column, Timestamp.ofEpochSecond(sec, nsec));
        defaultValue.setTimestamp(pageBuilder, column);
    }

    @Override
    public void set(String v)
    {
        try {
            pageBuilder.setTimestamp(column, timestampParser.parse(v));
        }
        catch (TimestampParseException e) {
            defaultValue.setTimestamp(pageBuilder, column);
        }
    }

    @Override
    public void set(Timestamp v)
    {
        pageBuilder.setTimestamp(column, v);
    }

    @Override
    public void set(Value v)
    {
        defaultValue.setTimestamp(pageBuilder, column);
    }
}

Version data entries

78 entries across 78 versions & 1 rubygems

Version Path
embulk-0.8.9 embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.9-java embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.8 embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.8-java embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.7 embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.7-java embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.6 embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.6-java embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.5 embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.5-java embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.4 embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.4-java embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.3 embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.3-java embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.2 embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.2-java embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.1 embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java
embulk-0.8.1-java embulk-core/src/main/java/org/embulk/spi/util/dynamic/TimestampColumnSetter.java