org.apache.trevni

## Class ColumnFileWriter

- java.lang.Object
- - org.apache.trevni.ColumnFileWriter

-     public class ColumnFileWriter
      extends Object

  Writes data to a column file. All data is buffered until `writeTo(File)` is called.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ColumnFileWriter(ColumnFileMetaData fileMeta, ColumnMetaData... columnMeta)` Construct given metadata for each column in the file.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `endRow()` Expert: Called after all values are written to a row.
    `int` | `getColumnCount()` Return the number of columns in the file.
    `ColumnFileMetaData` | `getMetaData()` Return this file's metadata.
    `long` | `sizeEstimate()` Return the approximate size of the file that will be written.
    `void` | `startRow()` Expert: Called before any values are written to a row.
    `void` | `writeLength(int length, int column)` Expert: Declare a count of items to be written to an array column or a column whose parent is an array.
    `void` | `writeRow(Object... row)` Add a row to the file.
    `void` | `writeTo(File file)` Write all rows added to the named file.
    `void` | `writeTo(OutputStream out)` Write all rows added to the named output stream.
    `void` | `writeValue(Object value, int column)` Expert: Add a value to a row.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ColumnFileWriter

          public ColumnFileWriter(ColumnFileMetaData fileMeta,
                                  ColumnMetaData... columnMeta)
                           throws IOException

      Construct given metadata for each column in the file.
      Throws:
        `IOException`

  - ### Method Detail

    - #### sizeEstimate

          public long sizeEstimate()

      Return the approximate size of the file that will be written. Tries to slightly over-estimate. Indicates both the size in memory of the buffered data as well as the size of the file that will be written by `writeTo(OutputStream)`.

    - #### getMetaData

          public ColumnFileMetaData getMetaData()

      Return this file's metadata.

    - #### getColumnCount

          public int getColumnCount()

      Return the number of columns in the file.

    - #### writeRow

          public void writeRow(Object... row)
                        throws IOException

      Add a row to the file.
      Throws:
        `IOException`

    - #### startRow

          public void startRow()
                        throws IOException

      Expert: Called before any values are written to a row.
      Throws:
        `IOException`

    - #### writeLength

          public void writeLength(int length,
                                  int column)
                           throws IOException

      Expert: Declare a count of items to be written to an array column or a column whose parent is an array.
      Throws:
        `IOException`

    - #### writeValue

          public void writeValue(Object value,
                                 int column)
                          throws IOException

      Expert: Add a value to a row. For values in array columns or whose parents are array columns, this must be preceded by a call to `writeLength(int, int)` and must be called that many times. For normal columns this is called once for each row in the column.
      Throws:
        `IOException`

    - #### endRow

          public void endRow()
                      throws IOException

      Expert: Called after all values are written to a row.
      Throws:
        `IOException`

    - #### writeTo

          public void writeTo(File file)
                       throws IOException

      Write all rows added to the named file.
      Throws:
        `IOException`

    - #### writeTo

          public void writeTo(OutputStream out)
                       throws IOException

      Write all rows added to the named output stream.
      Throws:
        `IOException`

Copyright © 2009–2024 The Apache Software Foundation. All rights reserved.