Class WriterConfig.Builder

java.lang.Object
dev.hardwood.writer.WriterConfig.Builder
Enclosing class:
WriterConfig

public static final class WriterConfig.Builder extends Object
Builder for WriterConfig.
  • Method Details

    • pageTargetBytes

      public WriterConfig.Builder pageTargetBytes(int pageTargetBytes)
      Sets the page target; must be at least one INT32 (4 bytes).
    • pageTargetRows

      public WriterConfig.Builder pageTargetRows(int pageTargetRows)

      Sets the record count at which a data page is cut; must be positive.

      A page is cut at this count or at pageTargetBytes, whichever is reached first. Each page's bounds are recorded in the file's page index, so the count sets how finely a reader can skip within a column chunk. It binds on columns whose values encode small, such as dictionary-encoded ones, which would otherwise hold a whole row group in a few pages. A page holds whole records, so on a repeated column it counts records rather than values.

    • rowGroupBufferTargetBytes

      public WriterConfig.Builder rowGroupBufferTargetBytes(long rowGroupBufferTargetBytes)

      Sets the byte threshold at which a row group is cut; must be positive.

      The bytes counted are the bytes the writer holds for the open row group: the level streams, the dictionary indices, the value stores and the dictionaries. This is the writer's memory control, and peak heap follows it. Two things sit on top: the buffers hold more than they are charged for while they grow — the value stores by half again, the level streams and packed content and every dictionary's arrays by double — and a schema with enough columns that each one's share falls below the floor under a column's buffers opens at a multiple of the target. Neither grows with how much is written.

      It is not the size the row group takes on disk. That is smaller by whatever the encoding and the codec win, which is a property of the data rather than of this setting. A row group passes this threshold by at most one record, a record not being divisible across row groups.

    • rowGroupTargetRows

      public WriterConfig.Builder rowGroupTargetRows(long rowGroupTargetRows)

      Sets the record count at which a row group is cut; must be positive.

      This is the control over how a file is banded, and the row groups it produces hold exactly this many records apart from the last. A row group is cut at this count or at rowGroupBufferTargetBytes, whichever is reached first, so a row target set above what the buffer target allows has no effect beyond it.

      A structural ceiling sits under both: a chunk accumulates into int-indexed buffers, so a row group holds at most Integer.MAX_VALUE - 9 records however many are asked for. A target above that is that ceiling, which is what makes Long.MAX_VALUE the way to say "no row limit, cut on bytes alone".

    • encoding

      public WriterConfig.Builder encoding(ColumnEncoding encoding)

      Sets the encoding policy for every column without an override of its own; must be non-null. Defaults to ColumnEncoding.AUTO.

      A default that no column of the schema can carry is rejected when the writer is created, so a file-wide BYTE_STREAM_SPLIT over a schema holding a BYTE_ARRAY column fails rather than quietly resolving that column to something else.

    • encoding

      public WriterConfig.Builder encoding(String columnPath, ColumnEncoding encoding)

      Sets the encoding policy for one leaf column, overriding the file-wide default; both arguments must be non-null.

      The column is named by its dotted leaf path as the schema spells it, synthetic list.element and key_value.key segments included — readings.list.element, not readings. A path matching no leaf column of the schema, or a policy its physical type cannot carry, is rejected when the writer is created.

    • bloomFilter

      public WriterConfig.Builder bloomFilter(String columnPath)
      Writes a Bloom filter for one leaf column, at WriterConfig.DEFAULT_BLOOM_FILTER_FPP; must be non-null. See bloomFilter(String, double).
    • bloomFilter

      public WriterConfig.Builder bloomFilter(String columnPath, double fpp)

      Writes a Bloom filter for one leaf column, with the given false-positive probability; the path must be non-null and the probability strictly between 0 and 1.

      Every row group gets a filter for the column, holding each distinct value its chunk holds. The filter is sized from the values the chunk turns out to hold, so a lower probability costs bytes in proportion to the chunk's distinct values. Naming the column again replaces the probability.

      The column is named by its dotted leaf path, as for encoding(String, ColumnEncoding). A path matching no leaf column of the schema, or naming a BOOLEAN column, is rejected when the writer is created.

    • statisticsTruncationLength

      public WriterConfig.Builder statisticsTruncationLength(int statisticsTruncationLength)
      Sets the maximum BYTE_ARRAY min / max statistics bound length; must be positive. A bound longer than this is truncated and flagged inexact.
    • compression

      public WriterConfig.Builder compression(Compression compression)

      Sets how each page body is compressed; must be non-null. See Compression for the codecs and their levels.

      A codec's library is required when the writer is created rather than here.

    • dataPageVersion

      public WriterConfig.Builder dataPageVersion(DataPageVersion dataPageVersion)
      Sets the header and layout every data page is written with; must be non-null. Defaults to DataPageVersion.V1.
    • precisionLossPolicy

      public WriterConfig.Builder precisionLossPolicy(PrecisionLossPolicy precisionLossPolicy)
      Sets what RowWriter does with a value carrying more precision than its column can hold — an Instant with microseconds written to a TIMESTAMP(MILLIS) column, say; must be non-null. Defaults to PrecisionLossPolicy.REJECT.
    • sortingColumns

      public WriterConfig.Builder sortingColumns(SortingColumn... sortingColumns)
      Declares the order every row group's rows are sorted in; a second call replaces the first, and no columns declares none. See sortingColumns(List).
    • sortingColumns

      public WriterConfig.Builder sortingColumns(List<SortingColumn> sortingColumns)

      Declares the order every row group's rows are sorted in: by the first column, rows equal there by the second, and so on. A second call replaces the first, and an empty list declares none. The list must be non-null, hold no null and name each column once.

      Each row group's metadata records the order. The writer checks it as rows arrive, within each row group: the first row that sorts before the row ahead of it fails the write with an IllegalArgumentException. SortingColumn defines how each column's values compare.

      A column is named by its dotted leaf path, as for encoding(String, ColumnEncoding). A path matching no leaf column, a column that is repeated or sits inside a list or map, and a column whose type has no defined order (INTERVAL, GEOMETRY, GEOGRAPHY, UNKNOWN) are rejected when the writer is created.

    • build

      public WriterConfig build()
      Builds the immutable configuration.