Class Writer

java.lang.Object
net.quasardb.qdb.ts.Writer
All Implemented Interfaces:
Flushable, AutoCloseable
Direct Known Subclasses:
AutoFlushWriter

public class Writer extends Object implements AutoCloseable, Flushable
High-performance bulk writer for a QuasarDB timeseries table. Usage of instances of this class is not thread-safe. Use a Writer instance per Thread in multi-threaded situations.
  • Field Details

    • pointsSinceFlush

      protected long pointsSinceFlush
  • Constructor Details

  • Method Details

    • builder

      public static Writer.Builder builder(Session session)
      Create a builder instance.
      Parameters:
      session - Active connection with the QuasarDB cluster.
    • finalize

      protected void finalize() throws Throwable
      Cleans up the internal representation of the batch table.
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • close

      public void close() throws IOException
      Closes the timeseries table and local cache so that memory can be reclaimed. Flushes all remaining output.
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException
    • flush

      public void flush() throws IOException
      Specified by:
      flush in interface Flushable
      Throws:
      IOException
    • flush

      public void flush(TimeRange[] ranges) throws IOException
      Throws:
      IOException
    • prepareFlush

      public void prepareFlush() throws IOException
      Prepare internal data structure for flushing. Will be automatically called if not called explicitly.
      Throws:
      IOException
    • prepareFlush

      public void prepareFlush(TimeRange[] ranges)
      Prepare internal data structure for flushing. Will be automatically called if not called explicitly.
    • trackMinMaxTimestamp

      protected void trackMinMaxTimestamp(Timespec timestamp)
    • append

      public void append(Table table, Timespec timestamp, Value[] values) throws IOException
      Append a new row to the local table cache. Should be periodically flushed, unless an AutoFlushWriter is used. This function automatically looks up a table's offset by its name. For performance reason, you are encouraged to manually invoke and cache the value of #tableIndexByName whenever possible.
      Parameters:
      table - Table to insert into.
      timestamp - Timestamp of the row
      values - Values being inserted, mapped to columns by their relative offset.
      Throws:
      IOException
      See Also:
    • append

      public void append(Table table, WritableRow row) throws IOException
      Append a new row to the local table cache. Should be periodically flushed, unless an AutoFlushWriter is used.
      Parameters:
      table - Table to insert into
      row - Row being inserted.
      Throws:
      IOException
      See Also:
    • append

      public void append(Table table, LocalDateTime timestamp, Value[] values) throws IOException
      Append a new row to the local table cache. Should be periodically flushed, unless an AutoFlushWriter is used.
      Parameters:
      table - Table to insert into
      timestamp - Timestamp of the row
      values - Values being inserted, mapped to columns by their relative offset.
      Throws:
      IOException
      See Also:
    • append

      public void append(Table table, Timestamp timestamp, Value[] values) throws IOException
      Append a new row to the local table cache. Should be periodically flushed, unless an AutoFlushWriter is used.
      Parameters:
      table - Table to insert into
      timestamp - Timestamp of the row
      values - Values being inserted, mapped to columns by their relative offset.
      Throws:
      IOException
      See Also:
    • size

      public long size()
      Returns the amount of values appended to the writer, not yet pushed/flushed.