CopyBuffer

com.netflix.atlas.postgres.CopyBuffer
trait CopyBuffer

Buffer for storing data in memory in a format that can be passed to the Postgres COPY operation. The caller is responsible for knowing the table format and putting values in the expected order. Typical usage:

val buffer = ...
rows.foreach { row =>
 buffer.putString(row.column(1)).putInt(row.column(2))
 if (!buffer.nextRow()) {
   buffer.copyIn(copyManager, tableName)
   buffer.putString(row.column(1)).putInt(row.column(2)).nextRow()
 }
}
buffer.copyIn(copyManager, tableName)

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def clear(): Unit

Clear the contents of the buffer so it can be reused.

Clear the contents of the buffer so it can be reused.

Attributes

def copyIn(copyManager: CopyManager, table: String): Unit

Copy the data in this buffer into the specified table.

Copy the data in this buffer into the specified table.

Attributes

def hasRemaining: Boolean

Returns true if there is space remaining in the buffer.

Returns true if there is space remaining in the buffer.

Attributes

def nextRow(): Boolean

Indicate the end of the row and prepare for the next. Returns true if the row was able to fit in the buffer. Otherwise the buffer should be copied to Postgres and cleared before re-adding the row.

Indicate the end of the row and prepare for the next. Returns true if the row was able to fit in the buffer. Otherwise the buffer should be copied to Postgres and cleared before re-adding the row.

If a single row is too big to fit in the buffer, then an IllegalStateException will be thrown to avoid an endless loop.

Attributes

def putDouble(value: Double): CopyBuffer

Put an 8-byte floating point column value into the buffer.

Put an 8-byte floating point column value into the buffer.

Attributes

def putDoubleArray(values: Array[Double]): CopyBuffer

Put an array of 8-byte floating point column value into the buffer.

Put an array of 8-byte floating point column value into the buffer.

Attributes

def putId(id: ItemId): CopyBuffer

Put an id column value into the buffer.

Put an id column value into the buffer.

Attributes

def putInt(value: Int): CopyBuffer

Put a signed 4-byte integer column value into the buffer.

Put a signed 4-byte integer column value into the buffer.

Attributes

def putLong(value: Long): CopyBuffer

Put a signed 8-byte integer column value into the buffer.

Put a signed 8-byte integer column value into the buffer.

Attributes

def putShort(value: Short): CopyBuffer

Put a signed 2-byte integer column value into the buffer.

Put a signed 2-byte integer column value into the buffer.

Attributes

def putString(str: String): CopyBuffer

Put a string column value into the buffer.

Put a string column value into the buffer.

Attributes

def putTagsHstore(tags: SortedTagMap): CopyBuffer

Put an HSTORE column value into the buffer.

Put an HSTORE column value into the buffer.

Attributes

def putTagsJson(tags: SortedTagMap): CopyBuffer

Put a JSON column value into the buffer.

Put a JSON column value into the buffer.

Attributes

def putTagsJsonb(tags: SortedTagMap): CopyBuffer

Put a JSONB column value into the buffer.

Put a JSONB column value into the buffer.

Attributes

def putTagsText(tags: SortedTagMap): CopyBuffer

Put a JSON string column value as text into the buffer.

Put a JSON string column value as text into the buffer.

Attributes

def remaining: Int

Returns the number of bytes remaining in the buffer.

Returns the number of bytes remaining in the buffer.

Attributes

def rows: Int

Returns the number of completed rows that are in the buffer.

Returns the number of completed rows that are in the buffer.

Attributes