view src/main/java/nl/cwi/monetdb/embedded/tables/RowUpdater.java @ 41:3a19ebf83af6 embedded

Arranged code in packages and starting tables integration.
author Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
date Mon, 07 Nov 2016 23:31:02 +0100 (2016-11-07)
parents
children dfea8468cd1a
line wrap: on
line source
package nl.cwi.monetdb.embedded.tables;

import java.util.Arrays;

/**
 * Created by ferreira on 11/7/16.
 */
public class RowUpdater extends RowIterator {

    private final boolean[] updatedIndexes;

    public RowUpdater(MonetDBTable table, int firstIndex, int lastIndex) {
        super(table, firstIndex, lastIndex);
        this.updatedIndexes = new boolean[table.getNumberOfColumns()];
    }

    public <T> void setColumn(int index, T value) {
        this.columns[index] = value;
        this.updatedIndexes[index] = true;
    }

    public <T> void setColumn(int index, Class<T> javaClass, T value) {
        this.columns[index] = value;
        this.updatedIndexes[index] = true;
    }

    public void setAllColumns(Object[] values) {
        this.columns = values;
        Arrays.fill(this.updatedIndexes, true);
    }

    public boolean toUpdate() {
        for (boolean bol : updatedIndexes) {
            if(bol) {
                return true;
            }
        }
        return false;
    }

    @Override
    protected void setNextIteration(Object[] columns, int rowNumber) {
        super.setNextIteration(columns, rowNumber);
        Arrays.fill(this.updatedIndexes, false);
    }
}