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

com.clickzetta.client.MultiStream Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package com.clickzetta.client;

import com.clickzetta.platform.client.RowCreate;
import com.clickzetta.platform.client.api.Options;
import com.clickzetta.platform.client.api.Row;
import com.clickzetta.platform.client.api.multi.MultiTablesOptions;
import cz.proto.ingestion.v2.IngestionV2;

import java.io.IOException;

public class MultiStream {
    com.clickzetta.platform.client.api.multi.MultiStream multiStream;

    public MultiStream(ClickZettaClient client, Options options, MultiTablesOptions multiTablesOptions)
            throws IOException {
        this.multiStream = client.getIgsClient().createMultiStream(multiTablesOptions, options);
    }

    public Row createRow(RowCreate.Operator operationType, String schemaName, String tableName) {
        switch (operationType) {
            case INSERT:
                return multiStream.createInsertRow(schemaName, tableName);
            case INSERT_IGNORE:
                return multiStream.createInsertIgnoreRow(schemaName, tableName);
            case UPDATE:
                return multiStream.createUpdateRow(schemaName, tableName);
            case UPSERT:
                return multiStream.createUpsertRow(schemaName, tableName);
            case DELETE:
                return multiStream.createDeleteRow(schemaName, tableName);
            case DELETE_IGNORE:
                return multiStream.createDeleteIgnoreRow(schemaName, tableName);
            default:
                throw new IllegalArgumentException("operationType is not support");
        }
    }

    public void appendStream(String schemaName, String tableName) throws IOException {
        multiStream.dynamicAppendStream(schemaName, tableName);
    }

    public void removeStream(String schemaName, String tableName) throws IOException {
        multiStream.dynamicRemoveStream(schemaName, tableName);
    }

    public void apply(Row... rows) throws IOException {
        multiStream.apply(rows);
    }

    public void flush() throws IOException {
        multiStream.flush();
    }

    public void close() throws IOException {
        multiStream.close();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy