QuestDB JavaScript Client - v5.0.0
    Preparing search index...

    Buffer implementation for protocol version 2.
    Sends floating point numbers in binary form, and provides support for arrays.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    buffer: Buffer
    log: Logger
    position: number

    Methods

    • Write an array column with its values into the buffer using v2 format.

      Parameters

      • name: string

        Column name

      • value: unknown[]

        Array values to write (currently supports double arrays). A null or undefined value omits the column entirely, storing NULL.

      Returns SenderBuffer

      Returns with a reference to this buffer.

      Error if array validation fails:

      • value is not an array
      • or the shape of the array is irregular: the length of sub-arrays are different
      • or the array is not homogeneous: its elements are not all the same type
    • Closes the row after writing the designated timestamp into the buffer.

      Precision rules:

      • Protocol v2 and higher: Timestamps passed with unit 'ns' (nanoseconds) are sent with full nanosecond precision. All other timestamps are sent with microsecond precision.
      • Protocol v1: Always uses microsecond precision, even if the timestamp is specified in nanoseconds.

      Parameters

      • timestamp: number | bigint

        Designated epoch timestamp. Must be an integer or a BigInt.

      • Optionalunit: TimestampUnit = "us"

        The time unit of the timestamp. Supported values:

        • 'ns' — nanoseconds (requires BigInt)
        • 'us' — microseconds (default)
        • 'ms' — milliseconds

      Returns void

      Returns with a reference to this buffer.

      If timestamp is not an integer or BigInt.

      If unit is 'ns' but timestamp is not a BigInt.

      If unit is not one of 'ns', 'us', or 'ms'. Argument validation -- the unit and the timestamp alike -- runs before the close touches the row, so it leaves the open row unchanged and the call can be retried with a corrected argument.

      If the row has no symbol or column set. Such a row can never be closed by any argument, so it is discarded ahead of the argument checks and the next row starts from table().

      If the row cannot be closed within max_buf_size. The partial close is rewound, so the same call succeeds once a flush() frees space.

    • Closes the row without writing designated timestamp into the buffer.
      Designated timestamp will be populated by the server on this record.

      Returns void

    • Writes a boolean column with its value into the buffer.
      Use it to insert into BOOLEAN columns.

      Parameters

      • name: string

        Column name.

      • value: boolean

        Column value, accepts only boolean values. A null or undefined value omits the column entirely (stored as NULL).

      Returns SenderBuffer

      Returns with a reference to this buffer.

    • Checks if the buffer has sufficient capacity for additional data and resizes if needed.

      Parameters

      • data: string[]

        Array of strings to calculate the required capacity for

      • base: number = 0

        Base number of bytes to add to the calculation

      Returns void

    • Returns the current position of the buffer.
      New data will be written into the buffer starting from this position.

      Returns number

    • Writes a decimal value into the buffer using its binary format.

      Use it to insert into DECIMAL database columns.

      Decimals are not supported by protocol v1/v2, so this base implementation rejects the call even when the value is null or undefined. Protocol v3 overrides this with a validating implementation.

      Parameters

      • name: string

        Column name.

      • unscaled: bigint | Int8Array<ArrayBufferLike>

        The unscaled integer portion of the decimal value.

      • scale: number

        The number of fractional digits (the scale) of the decimal value.

      Returns SenderBuffer

      Returns with a reference to this buffer.

      If scale is not an integer between 0 and 76. Scale validation runs even when unscaled is null or undefined.

      Indicating decimals are not supported in protocol v1/v2.

    • Writes a decimal value into the buffer using its text format.

      Use it to insert into DECIMAL database columns.

      Decimals are not supported by protocol v1/v2, so this base implementation rejects the call even when the value is null or undefined. Protocol v3 overrides this with a validating implementation.

      Parameters

      • name: string

        Column name.

      • value: string | number

        The decimal value to write.

      Returns SenderBuffer

      Returns with a reference to this buffer.

      Indicating decimals are not supported in protocol v1/v2.

    • Writes a 64-bit floating point value into the buffer using v2 serialization (binary format).
      Use it to insert into DOUBLE or FLOAT database columns.

      Parameters

      • name: string

        Column name.

      • value: number

        Column value, accepts only number values. A null or undefined value omits the column entirely (stored as NULL).

      Returns SenderBuffer

      Returns with a reference to this buffer.

    • Writes a 64-bit signed integer into the buffer.
      Use it to insert into LONG, INT, SHORT and BYTE columns.

      Parameters

      • name: string

        Column name.

      • value: number

        Column value, accepts only number values. A null or undefined value omits the column entirely (stored as NULL).

      Returns SenderBuffer

      Returns with a reference to this buffer.

      Error if the value is not an integer

    • Writes a string column with its value into the buffer.
      Use it to insert into VARCHAR and STRING columns.

      Parameters

      • name: string

        Column name.

      • value: string

        Column value, accepts only string values. A null or undefined value omits the column entirely (stored as NULL).

      Returns SenderBuffer

      Returns with a reference to this buffer.

    • Writes a symbol name and value into the buffer.
      Use it to insert into SYMBOL columns.

      Parameters

      • name: string

        Symbol name.

      • value: unknown

        Symbol value, toString() is called to extract the actual symbol value from the parameter. A null or undefined value omits the symbol entirely (stored as NULL).

      Returns SenderBuffer

      Returns with a reference to this buffer.

    • Writes a timestamp column and its value into the buffer.

      Use this method to insert data into TIMESTAMP or TIMESTAMP_NS columns.

      Precision rules:

      • Protocol v2 and higher: Timestamps passed with unit 'ns' (nanoseconds) are sent with full nanosecond precision. All other timestamps are sent with microsecond precision.
      • Protocol v1: Always uses microsecond precision, even if the timestamp is specified in nanoseconds.

      Parameters

      • name: string

        The column name.

      • value: number | bigint

        The epoch timestamp. Must be an integer or a BigInt. A null or undefined value omits the column entirely (stored as NULL).

      • Optionalunit: TimestampUnit = "us"

        The time unit of the timestamp. Supported values:

        • 'ns' — nanoseconds (requires BigInt)
        • 'us' — microseconds (default)
        • 'ms' — milliseconds

      Returns SenderBuffer

      Returns with a reference to this buffer.

      If unit is not one of 'ns', 'us', or 'ms' (checked even when value is null or undefined).

      If value is not an integer or BigInt.

      If unit is 'ns' but value is not a BigInt.

    • Parameters

      • pos: number = ...

      Returns Buffer

      Returns a cropped buffer ready to send to the server, or null if there is nothing to send.
      The returned buffer is a copy of this buffer. It also compacts the buffer.

    • Parameters

      • pos: number = ...

      Returns Buffer

      Returns a cropped buffer, or null if there is nothing to send.
      The returned buffer is backed by this buffer instance, meaning the view can change as the buffer is mutated. Used only in tests to assert the buffer's content.