LargeObject

class LargeObject(session: OctaviusSession, val oid: Int, val fd: Int) : AutoCloseable

Represents an open descriptor to a PostgreSQL Large Object. Implements AutoCloseable for convenient usage within .use { } blocks.

Constructors

Link copied to clipboard
internal constructor(session: OctaviusSession, oid: Int, fd: Int)

Properties

Link copied to clipboard
val fd: Int

The File Descriptor (FD) assigned by PostgreSQL for this open object.

Link copied to clipboard
val oid: Int

The Object ID (OID) of this Large Object.

Functions

Link copied to clipboard
open override fun close()

Closes the Large Object descriptor, freeing server-side resources. It is safe to call this method multiple times; subsequent calls are ignored.

Link copied to clipboard

Returns an InputStream for reading from this Large Object. Closing the stream will close this Large Object.

Link copied to clipboard

Returns an OutputStream for writing to this Large Object. Closing the stream will close this Large Object.

Link copied to clipboard
fun read(length: Int): ByteArray

Reads up to length bytes from the Large Object.

fun read(buffer: ByteArray, offset: Int = 0, length: Int = buffer.size - offset): Int

Reads up to length bytes from the Large Object into the given buffer.

Link copied to clipboard
fun seek(position: Long, ref: Int = SeekWhence.SET): Long

Sets the current position of the Large Object.

Link copied to clipboard
fun tell(): Long

Retrieves the current position of the Large Object.

Link copied to clipboard
fun truncate(length: Long)

Truncates the Large Object to the given length. If the object was previously larger, the extra data is lost. If the object was previously shorter, it is extended with null bytes.

Link copied to clipboard
fun write(data: ByteArray, offset: Int = 0, length: Int = data.size - offset)

Writes length bytes from the specified data byte array starting at offset to this Large Object.