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

com.yandex.ydb.table.settings.AlterTableSettings Maven / Gradle / Ivy

package com.yandex.ydb.table.settings;

import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

import javax.annotation.Nullable;

import com.yandex.ydb.table.values.Type;


/**
 * @author Sergey Polovko
 */
public class AlterTableSettings extends RequestSettings {

    private LinkedHashMap addColumns = new LinkedHashMap<>();
    private HashSet dropColumns = new HashSet<>();
    @Nullable
    private TtlSettings ttlSettings;
    @Nullable
    private PartitioningSettings partitioningSettings;

    public AlterTableSettings() {
    }

    public AlterTableSettings addColumn(String name, Type type) {
        addColumns.put(name, type);
        return this;
    }

    public AlterTableSettings dropColumn(String name) {
        dropColumns.add(name);
        return this;
    }

    public void forEachAddColumn(BiConsumer fn) {
        for (Map.Entry e : addColumns.entrySet()) {
            fn.accept(e.getKey(), e.getValue());
        }
    }

    public void forEachDropColumn(Consumer fn) {
        dropColumns.forEach(fn);
    }

    @Nullable
    public TtlSettings getTtlSettings() {
        return ttlSettings;
    }

    @Nullable
    public PartitioningSettings getPartitioningSettings() {
        return partitioningSettings;
    }

    public void setTtlSettings(@Nullable TtlSettings ttlSettings) {
        this.ttlSettings = ttlSettings;
    }

    public void setPartitioningSettings(@Nullable PartitioningSettings partitioningSettings) {
        this.partitioningSettings = partitioningSettings;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy