Class NewPartition.Builder

java.lang.Object
com.here.platform.data.client.javadsl.NewPartition.Builder
Enclosing class:
NewPartition

public static final class NewPartition.Builder extends Object
Build a new partition to be committed
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • addBooleanField

      public NewPartition.Builder addBooleanField(String name, boolean value)
      Add index field with Boolean type to the collection of index fields.

      Parameters:
      name - the name of index field
      value - the value of index field
      Returns:
      this builder
    • addField

      public NewPartition.Builder addField(String name, IndexValue value)
      Add field to the collection of index fields.

      Parameters:
      name - the name of index field
      value - the value of index field
      Returns:
      this builder
    • addHereTileField

      public NewPartition.Builder addHereTileField(String name, long tile)
      Add index field with HereTile type to the collection of index fields.

      Parameters:
      name - the name of index field
      tile - the value of index field
      Returns:
      this builder
    • addIntField

      public NewPartition.Builder addIntField(String name, long value)
      Add index field with Int type to the collection of index fields.

      Parameters:
      name - the name of index field
      value - the value of index field
      Returns:
      this builder
    • addMetadata

      public NewPartition.Builder addMetadata(String name, String value)
      Add metadata name-value pair to index metadata collection.

      Parameters:
      name - name of metadata field
      value - value of metadata field
      Returns:
      this builder
    • addStringField

      public NewPartition.Builder addStringField(String name, String value)
      Add index field with String type to the collection of index fields.

      Parameters:
      name - the name of index field
      value - the value of index field
      Returns:
      this builder
    • addTimeWindowField

      public NewPartition.Builder addTimeWindowField(String name, long time)
      Add index field with TimeWindow type to the collection of index fields.

      Parameters:
      name - the name of index field
      time - the value of index field
      Returns:
      this builder
    • build

      public NewPartition build()
      Builds a new NewPartition.

      Partition id, layer name, and a data source are required.

      DataSize, checksum, crc and compressedDataSize are optional. They are automatically calculated during data upload. additionalMetadata is now deprecated because it is no longer required by OLP services to route messages.

      compressedDataSize is optional. It is calculated if catalog configuration has property to automatically compress data.

      Some properties are tested for validity. If invalid a IllegalArgumentException is thrown. Tested properties include partition id and layer name. An invalid file (unreadable, or not found) results in an exception being thrown.

      Returns:
      the NewPartition object
      Throws:
      IllegalArgumentException - if any properties are not valid
    • withAdditionalMetadata

      public NewPartition.Builder withAdditionalMetadata(Optional<String> additionalMetadata)
      Deprecated.
      This field is not supported anymore. Please use the other available fields instead. Since OLP SDK > 2.1.
      Sets the additional metadata.

      Parameters:
      additionalMetadata - precomputed checksum value
      Returns:
      this builder
    • withChecksum

      public NewPartition.Builder withChecksum(Optional<String> checksum)
      Sets the checksum.

      Parameters:
      checksum - precomputed checksum value
      Returns:
      this builder
    • withCompressedDataSize

      public NewPartition.Builder withCompressedDataSize(OptionalLong compressedDataSize)
      Sets the precomputed compressed data size.

      Parameters:
      compressedDataSize - precomputed compressed data size
      Returns:
      this builder
    • withCrc

      public NewPartition.Builder withCrc(Optional<String> crc)
      Sets the crc.

      Parameters:
      crc - precomputed crc value
      Returns:
      this builder
    • withData

      public NewPartition.Builder withData(org.apache.pekko.stream.javadsl.Source<org.apache.pekko.util.ByteString,org.apache.pekko.NotUsed> data)
      Sets the data source from Source.

      Parameters:
      data - Data for the partition, as Source
      Returns:
      this builder
    • withData

      public NewPartition.Builder withData(InputStream data)
      Sets the data source from InputStream. This is the less preferred method given the synchronous and blocking nature of InputStream.

      Parameters:
      data - Data for the partition, as an input stream
      Returns:
      this builder
    • withData

      public NewPartition.Builder withData(byte[] data)
      Sets the data source to be a byte array.

      Parameters:
      data - Data for the partition, as a byte array
      Returns:
      this builder
    • withData

      public NewPartition.Builder withData(File data)

      Sets the data source from file.

      Parameters:
      data - data for the partition, via a file
      Returns:
      this builder
    • withData

      public NewPartition.Builder withData(com.here.platform.data.client.scaladsl.NewPartition.Blob blob)

      Sets the data source from an existing blob.

      Parameters:
      blob - data for the partition
      Returns:
      this builder
    • withDataSize

      public NewPartition.Builder withDataSize(OptionalLong dataSize)
      Sets the dataSize.

      Parameters:
      dataSize - data size
      Returns:
      this builder
    • withFields

      public NewPartition.Builder withFields(Map<String,IndexValue> fields)
      Set the index fields.

      Parameters:
      fields - the index fields
      Returns:
      this builder
      Note:
      The index fields are collection of name-value pairs that are used to index new partition in Index layer.

      , This method overwrites all fields added before.

    • withLayer

      public NewPartition.Builder withLayer(String layer)
      Sets the layer name.

      Parameters:
      layer - layer name
      Returns:
      this builder
    • withMetadata

      public NewPartition.Builder withMetadata(Map<String,String> metadata)
      Sets the additional metadata.

      Parameters:
      metadata - the index metadata
      Returns:
      this builder
      Note:
      This method overwrites all metadata values added before.

    • withPartition

      public NewPartition.Builder withPartition(String partition)
      Sets the partition id.

      Parameters:
      partition - partition id
      Returns:
      this builder
    • withTimestamp

      public NewPartition.Builder withTimestamp(OptionalLong timestamp)
      Sets the stream record's creation timestamp.

      Parameters:
      timestamp - the timestamp of the record, in milliseconds since epoch. Please check https://developer.here.com/documentation/data-client-library/dev_guide/client/publish-data.html chapter "Publish to a Stream Layer" for the detailed meaning of the timestamp.
      Returns:
      this builder
      Note:
      Setting the timestamp is only effective when publishing to a stream layer using the kafka-connector.