Sha256: 5b9a7f2b76b612f657c355433fc990673a24d79f1546cc29939d2a1172621aaa

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

package org.embulk.parser.avro.getter;

import org.embulk.spi.Column;
import org.embulk.spi.PageBuilder;
import org.embulk.spi.time.Timestamp;
import org.embulk.spi.time.TimestampParser;

public class FloatColumnGetter extends BaseColumnGetter {
    protected Float value;

    public FloatColumnGetter(PageBuilder pageBuilder, TimestampParser[] timestampParsers) {
        super(pageBuilder, timestampParsers);
    }

    @Override
    public void setValue(Object value)
    {
        this.value = (Float) value;
    }

    @Override
    public void longColumn(Column column) {
        if (value == null) {
            pageBuilder.setNull(column);
        } else {
            pageBuilder.setLong(column, value.longValue());
        }
    }

    @Override
    public void doubleColumn(Column column) {
        if (value == null) {
            pageBuilder.setNull(column);
        } else {
            pageBuilder.setDouble(column, value.doubleValue());
        }
    }

    @Override
    public void stringColumn(Column column) {
        if (value == null) {
            pageBuilder.setNull(column);
        } else {
            pageBuilder.setString(column, value.toString());
        }
    }

    @Override
    public void timestampColumn(Column column) {
        if (this.value == null) {
            pageBuilder.setNull(column);
        }
        else {
            long milliSec = (long) (value * 1000);
            pageBuilder.setTimestamp(column, Timestamp.ofEpochMilli(milliSec));
        }
    }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
embulk-parser-avro-0.2.0 src/main/java/org/embulk/parser/avro/getter/FloatColumnGetter.java
embulk-parser-avro-0.1.0 src/main/java/org/embulk/parser/avro/getter/FloatColumnGetter.java