Search in sources :

Example 1 with StarRocksSinkOptions

use of com.starrocks.connector.flink.table.StarRocksSinkOptions in project plugins by qlangtech.

the class StarRocksSinkFactory method createRocksSinkOptions.

private StarRocksSinkOptions createRocksSinkOptions(String dbName, String targetTabName, String jdbcUrl, DorisSourceFactory dsFactory, BasicDorisStarRocksWriter.Separator separator) {
    StarRocksSinkOptions.Builder builder = StarRocksSinkOptions.builder().withProperty(JDBC_URL.key(), jdbcUrl).withProperty(LOAD_URL.key(), dsFactory.getLoadUrls().stream().collect(Collectors.joining(";"))).withProperty(TABLE_NAME.key(), targetTabName).withProperty(DATABASE_NAME.key(), dbName).withProperty(SINK_PROPERTIES_PREFIX + "column_separator", separator.getColumnSeparator()).withProperty(SINK_PROPERTIES_PREFIX + "row_delimiter", separator.getRowDelimiter()).withProperty(SINK_SEMANTIC.key(), StarRocksSinkSemantic.fromName(this.sinkSemantic).getName()).withProperty(USERNAME.key(), dsFactory.getUserName());
    if (this.sinkConnectTimeout != null) {
        builder.withProperty(SINK_CONNECT_TIMEOUT.key(), String.valueOf(this.sinkConnectTimeout));
    }
    if (this.sinkBatchMaxSize != null) {
        builder.withProperty(SINK_BATCH_MAX_SIZE.key(), String.valueOf(this.sinkBatchMaxSize));
    }
    if (this.sinkBatchMaxRows != null) {
        builder.withProperty(SINK_BATCH_MAX_ROWS.key(), String.valueOf(this.sinkBatchMaxRows));
    }
    if (this.sinkBatchFlushInterval != null) {
        builder.withProperty(SINK_BATCH_FLUSH_INTERVAL.key(), String.valueOf(this.sinkBatchFlushInterval));
    }
    if (this.sinkMaxRetries != null) {
        builder.withProperty(SINK_MAX_RETRIES.key(), String.valueOf(this.sinkMaxRetries));
    }
    // if (StringUtils.isNotEmpty(dsFactory.getPassword())) {
    builder.withProperty(PASSWORD.key(), StringUtils.trimToEmpty(dsFactory.getPassword()));
    // }
    StarRocksSinkOptions sinkOptions = builder.build();
    sinkOptions.enableUpsertDelete();
    return sinkOptions;
}
Also used : StarRocksSinkOptions(com.starrocks.connector.flink.table.StarRocksSinkOptions)

Aggregations

StarRocksSinkOptions (com.starrocks.connector.flink.table.StarRocksSinkOptions)1