All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.deephaven.engine.table.impl.util.cast.DoubleToDoubleCast Maven / Gradle / Ivy

There is a newer version: 0.37.1
Show newest version
/**
 * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
 */
/*
 * ---------------------------------------------------------------------------------------------------------------------
 * AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY - for any changes edit CharToDoubleCast and regenerate
 * ---------------------------------------------------------------------------------------------------------------------
 */
package io.deephaven.engine.table.impl.util.cast;

import io.deephaven.chunk.*;
import io.deephaven.chunk.attributes.Any;
import io.deephaven.util.QueryConstants;

/**
 * Cast the values in the input chunk to an int.
 */
public class DoubleToDoubleCast implements ToDoubleCast {
    private final WritableDoubleChunk result;

    DoubleToDoubleCast(int size) {
        result = WritableDoubleChunk.makeWritableChunk(size);
    }

    @Override
    public  DoubleChunk cast(Chunk input) {
        return cast(input.asDoubleChunk());
    }

    @SuppressWarnings("unchecked")
    private  DoubleChunk cast(DoubleChunk input) {
        castInto(input, result);
        return result;
    }

    public static  void castInto(DoubleChunk input, WritableDoubleChunk result) {
        final int size = input.size();
        for (int ii = 0; ii < size; ++ii) {
            final double value = input.get(ii);
            if (value == QueryConstants.NULL_DOUBLE) {
                result.set(ii, QueryConstants.NULL_DOUBLE);
            } else {
                result.set(ii, value);
            }
        }
        result.setSize(input.size());
    }

    @Override
    public void close() {
        result.close();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy