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

com.clickzetta.platform.client.api.BulkLoadOptions Maven / Gradle / Ivy

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

import java.util.Collections;
import java.util.List;
import java.util.Optional;

/**
 * Options to create BulkLoadStream for bulk load.
 */
public class BulkLoadOptions {

  private BulkLoadOperation operation;
  private Optional partitionSpecs;
  private List recordKeys;
  private boolean preferInternalEndpoint;

  BulkLoadOptions(BulkLoadOperation operation,
                  Optional partitionSpecs,
                  List recordKeys,
                  boolean preferInternalEndpoint) {
    this.operation = operation;
    this.partitionSpecs = partitionSpecs;
    this.recordKeys = recordKeys;
    this.preferInternalEndpoint = preferInternalEndpoint;
  }

  public static Builder newBuilder() {
    return new Builder();
  }

  /**
   * Supported operations: APPEND, UPSERT, OVERWRITE.
   */
  public BulkLoadOperation getOperation() {
    return operation;
  }

  /**
   * Static partition specs.
   * 

* e.g. "ds=20230101" or "ds=20230101,hh=9,mm=30" * If not provided, dynamic partition is applied. */ public Optional getPartitionSpecs() { return partitionSpecs; } /** * Names of field that uniquely identify a record. * Used by COPY command for UPSERT. */ public List getRecordKeys() { return recordKeys; } /** * Whether to use internal endpoint to write data on the cloud object store. *

* If true, the bulk load will be sent to internal endpoint. * If false, the bulk load will be sent to external endpoint. *

* Default value is false. */ public boolean isPreferInternalEndpoint() { return preferInternalEndpoint; } public static class Builder { private BulkLoadOperation operation = BulkLoadOperation.APPEND; private Optional partitionSpecs = Optional.empty(); private List recordKeys = Collections.emptyList(); private boolean preferInternalEndpoint = false; public Builder withOperation(BulkLoadOperation operation) { this.operation = operation; return this; } public Builder withPartitionSpecs(Optional partitionSpecs) { this.partitionSpecs = partitionSpecs; return this; } public Builder withRecordKeys(List recordKeys) { this.recordKeys = recordKeys; return this; } public Builder withPreferInternalEndpoint(boolean preferInternalEndpoint) { this.preferInternalEndpoint = preferInternalEndpoint; return this; } private void validate() { if (operation == BulkLoadOperation.UPSERT && recordKeys.isEmpty()) { throw new IllegalArgumentException("recordKeys must be provided for UPSERT operation"); } } public BulkLoadOptions build() { validate(); return new BulkLoadOptions(operation, partitionSpecs, recordKeys, preferInternalEndpoint); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy