Blob files

group Blob files

Discover, fetch, and read row-addressable blobs.

Functions

LanceDBError lancedb_table_blob_columns(const LanceDBTable *table, char ***columns_out, size_t *count_out, char **error_message)

List row-addressable Blob v1 and v2 columns in declaration order.

Struct-nested blobs use dotted paths such as info.blob. Blobs inside lists are omitted because a row id cannot identify an individual list element. On entry, both outputs and the error message are cleared. An empty list succeeds with *columns_out NULL and *count_out zero. The caller owns the strings and array and frees them with lancedb_free_blob_columns(). If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • table – - pointer to LanceDBTable

  • columns_out – - pointer to receive the array of column-name strings

  • count_out – - pointer to receive the number of names

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

void lancedb_free_blob_columns(char **columns, size_t count)

Free the blob column-name array returned by lancedb_table_blob_columns.

Parameters:
  • columns – - array of string pointers returned by lancedb_table_blob_columns

  • count – - number of strings in the array

LanceDBError lancedb_table_fetch_blobs(const LanceDBTable *table, const char *column, const uint64_t *row_ids, size_t num_row_ids, FFI_ArrowArray **array_out, FFI_ArrowSchema **schema_out, char **error_message)

Materialize blob bytes for borrowed row ids.

The result follows row_ids in length, order and duplicates. NULL blobs stay NULL and valid empty blobs are empty byte strings. With a valid blob column, an empty input returns an empty array without reading blob bytes. One missing or deleted row id rejects the whole request without partial results. On entry, both outputs and the error message are cleared. On success the array and schema are independent of the table and of each other; the caller frees the array with lancedb_free_arrow_array() and the schema with lancedb_free_arrow_schema(). On failure both outputs stay clear. Blob availability and errors on remote tables are returned unchanged from the SDK. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • table – - pointer to LanceDBTable

  • column – - NUL-terminated UTF-8 blob column name, borrowed for the call

  • row_ids – - borrowed row id array; NULL is allowed only when num_row_ids is 0

  • num_row_ids – - number of row ids

  • array_out – - pointer to receive one Arrow C Data LargeBinary array

  • schema_out – - pointer to receive its Arrow C Data schema

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_table_fetch_blob_ranges(const LanceDBTable *table, const char *column, const LanceDBBlobRangeRequest *requests, size_t num_requests, FFI_ArrowArray **array_out, FFI_ArrowSchema **schema_out, char **error_message)

Materialize borrowed blob-local byte ranges.

The result follows the request order exactly, including duplicate and reordered requests. NULL blobs stay NULL, empty ranges on non-NULL blobs are empty byte strings. With a valid blob column, an empty request list returns an empty array without reading blob bytes. One missing row id or invalid range rejects the whole request without partial results. On entry, both outputs and the error message are cleared. On success the array and schema are independent of the table and of each other; the caller frees the array with lancedb_free_arrow_array() and the schema with lancedb_free_arrow_schema(). On failure both outputs stay clear. Blob availability and errors on remote tables are returned unchanged from the SDK. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • table – - pointer to LanceDBTable

  • column – - NUL-terminated UTF-8 blob column name, borrowed for the call

  • requests – - borrowed request array; NULL is allowed only when num_requests is 0

  • num_requests – - number of requests

  • array_out – - pointer to receive one Arrow C Data LargeBinary array

  • schema_out – - pointer to receive its Arrow C Data schema

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_table_fetch_blob_files(const LanceDBTable *table, const char *column, const uint64_t *row_ids, size_t num_row_ids, LanceDBBlobFile ***files_out, size_t *count_out, char **error_message)

Open lazy blob file handles for borrowed row ids.

The array follows row_ids in length, order and duplicates. A NULL blob leaves the matching entry NULL; a valid empty blob yields a non-NULL handle whose size is zero. With a valid blob column, an empty input returns *files_out NULL and *count_out zero without opening handles. One missing or deleted row id rejects the whole request without partial handles.

Fetching opens handles without materializing a blob, but it is not always free of I/O. An embedded External blob stored without a size queries its object size during fetch. A remote External blob in that state may issue a byte-range size probe (HTTP 206 for bytes=0-0). Access and response errors can therefore fail the fetch before any handle is returned.

Each handle keeps its own cursor and buffers and does not depend on the C table handle; it stays usable after lancedb_table_free(). An embedded handle captures the SDK’s selected storage and offset, and a remote handle captures the selected version and branch. No BlobFile retention lease is acquired for a handle, so dataset cleanup can remove old data and external storage controls its content. A remote row-ID handle also carries no descriptor source-commit identity, so it does not detect same-name recreation; reads can fail after any of these changes. On entry, both outputs and the error message are cleared. On success the caller frees the handles and array with lancedb_free_blob_files(). On failure both outputs stay clear. Blob availability and errors on remote tables are returned unchanged from the SDK. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • table – - pointer to LanceDBTable

  • column – - NUL-terminated UTF-8 blob column name, borrowed for the call

  • row_ids – - borrowed row id array; NULL is allowed only when num_row_ids is 0

  • num_row_ids – - number of row ids

  • files_out – - pointer to receive the array of optional handles

  • count_out – - pointer to receive the number of array entries

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

void lancedb_free_blob_files(LanceDBBlobFile **files, size_t count)

Free handles and the array returned by lancedb_table_fetch_blob_files.

Frees every non-NULL handle and the array. Passing NULL is a no-op. A handle freed earlier with lancedb_blob_file_free() must have been set to NULL in the array before this call.

Parameters:
  • files – - array of optional handles returned by lancedb_table_fetch_blob_files

  • count – - number of entries in the array

LanceDBError lancedb_table_open_blob_file(const LanceDBTable *table, const FFI_ArrowArray *descriptors, const FFI_ArrowSchema *descriptor_schema, int64_t row_index, LanceDBBlobFile **file_out, char **error_message)

Open one lazy blob file from a borrowed Arrow descriptor row.

The input is the struct column produced by the SDK SQL blob_descriptor function. Fields are identified by name and must have these exact Arrow types: kind UInt8, position UInt64, size UInt64, blob_id UInt32, blob_uri Utf8, and source Struct{uri Utf8, version UInt64, committed_at_micros UInt64, branch Utf8, column Utf8, row_reference UInt64, row_is_address Boolean}. Field order does not matter and extra fields are ignored. A consumer may pass a column produced by another SDK or received through Arrow Flight.

descriptors and descriptor_schema are borrowed only for this call and remain owned by the caller. This function does not consume them and does not call their Arrow C Data release callbacks; the caller releases them normally after the call returns. row_index addresses the logical array, so it accounts for Arrow slices and offsets. A top-level NULL descriptor succeeds with *file_out NULL. A valid empty blob succeeds with a non-NULL handle whose size is zero. For a non-NULL row, source and all required fields except branch must be non-NULL; branch NULL identifies the main branch.

The SDK verifies the descriptor’s pinned source identity and opens the exact source version and row; the binding does not reinterpret or repair the source. On native tables the check happens during open: the branch URI, source version, commit microseconds, column and row reference are validated, and the caller’s table checkout is not changed. Remote tables require a server with blob-file support (0.5.0 or newer) and send the source URI, branch, version, commit microseconds and row reference to the server for validation. A mismatch can surface at open or on a later read. When the server advertises direct Blob V2 reads, eligible reads can use short-lived URLs and require access to the object-store endpoint. An External descriptor with a zero stored size can issue an object metadata/HEAD request during open, so access or response errors can fail before a handle is returned.

As with lancedb_table_fetch_blob_files(), no BlobFile retention lease is acquired: dataset cleanup or external object changes can make later reads fail. On success the returned handle owns its SDK BlobFile and stays usable after this table and the Arrow input are released; free it with lancedb_blob_file_free().

On entry, *file_out and the error message are cleared. On failure *file_out stays NULL. NULL required pointers, a negative or out-of-range row_index, missing fields, wrong struct field types and NULL required values return LANCEDB_INVALID_ARGUMENT. A valid non-struct top-level Arrow type, or any Arrow C Data import failure, returns LANCEDB_ARROW. Non-NULL Arrow inputs must conform to the Arrow C Data Interface. SDK failures keep the existing error mapping. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • table – - table whose source opened the descriptor

  • descriptors – - one Arrow C Data struct array of descriptor rows, borrowed for the call

  • descriptor_schema – - Arrow C Data schema for descriptors, borrowed for the call

  • row_index – - zero-based logical row to open

  • file_out – - pointer to receive the optional handle

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

void lancedb_blob_file_free(LanceDBBlobFile *file)

Free one blob file handle.

The handle must not be used after this call. Freeing NULL is a no-op.

Parameters:

file – - handle returned by lancedb_table_fetch_blob_files or lancedb_table_open_blob_file, or NULL

LanceDBError lancedb_blob_file_size(const LanceDBBlobFile *file, uint64_t *size_out, char **error_message)

Return the blob length in bytes.

The size stays available after the handle is closed. Zero is a valid size for an empty blob. On entry, the error message is cleared. On failure size_out is left unchanged. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • file – - blob file handle returned by lancedb_table_fetch_blob_files or lancedb_table_open_blob_file

  • size_out – - pointer to receive the length in bytes

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_blob_file_position(const LanceDBBlobFile *file, LanceDBBlobFilePosition *position_out, char **error_message)

Return the physical byte offset of the blob inside its data file.

Embedded handles set has_position; remote handles do not expose their storage layout and report it as zero with position zeroed. This is not the read cursor: seek and read move the cursor, while read_range leaves it unchanged. On entry, the error message is cleared. On failure position_out is left unchanged. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • file – - blob file handle returned by lancedb_table_fetch_blob_files or lancedb_table_open_blob_file

  • position_out – - pointer to receive the position

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_blob_file_seek(const LanceDBBlobFile *file, uint64_t position, char **error_message)

Move the read cursor to a byte offset inside the blob.

The SDK accepts an offset past the blob end; a later read then returns no bytes. Seeking a closed handle fails with LANCEDB_INVALID_INPUT. On entry, the error message is cleared. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • file – - blob file handle returned by lancedb_table_fetch_blob_files or lancedb_table_open_blob_file

  • position – - new byte offset from the beginning of the blob

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_blob_file_read(const LanceDBBlobFile *file, LanceDBBlobBuffer *buffer_out, char **error_message)

Read from the current cursor to the end of the blob.

A successful read advances the cursor to the blob size. Reading at or past the end succeeds with an empty buffer. Reading a closed handle fails with LANCEDB_INVALID_INPUT. On entry, the buffer and error message are cleared. On success the caller owns the bytes and frees them with lancedb_blob_buffer_free(); they stay valid after the handle and table are freed. On failure the buffer stays clear. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • file – - blob file handle returned by lancedb_table_fetch_blob_files or lancedb_table_open_blob_file

  • buffer_out – - pointer to receive the owned bytes

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

LanceDBError lancedb_blob_file_read_range(const LanceDBBlobFile *file, uint64_t offset, uint64_t length, LanceDBBlobBuffer *buffer_out, char **error_message)

Read a blob-local byte range without moving the cursor.

Empty ranges are allowed at or before the blob size. An end past the blob size, or an offset and length whose sum overflows uint64_t, is rejected. Reading a closed handle fails with LANCEDB_INVALID_INPUT. On entry, the buffer and error message are cleared. On success the caller owns the bytes and frees them with lancedb_blob_buffer_free(); they stay valid after the handle and table are freed. On failure the buffer stays clear. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • file – - blob file handle returned by lancedb_table_fetch_blob_files or lancedb_table_open_blob_file

  • offset – - byte offset from the beginning of the blob value

  • length – - number of bytes to read

  • buffer_out – - pointer to receive the owned bytes

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

void lancedb_blob_buffer_free(LanceDBBlobBuffer *buffer)

Free the bytes of one blob read and reset the buffer.

Freeing an already freed or empty buffer is a no-op. The caller keeps the struct until the call; both fields are zeroed.

Parameters:

buffer – - buffer returned by lancedb_blob_file_read or lancedb_blob_file_read_range, or NULL

LanceDBError lancedb_blob_file_close(const LanceDBBlobFile *file, char **error_message)

Close the blob file and release its resources.

Closing is idempotent. After a close, reads, range reads and seeks fail with LANCEDB_INVALID_INPUT, while size and position remain available. Reads already in flight may still complete. On entry, the error message is cleared. If error_message is provided and an error occurs, the caller must free the error message with lancedb_free_string().

Parameters:
  • file – - blob file handle returned by lancedb_table_fetch_blob_files or lancedb_table_open_blob_file

  • error_message – - optional pointer to receive detailed error message (NULL to ignore)

Returns:

Error code indicating success or failure

struct LanceDBBlobRangeRequest
#include <lancedb.h>

One borrowed request for lancedb_table_fetch_blob_ranges.

row_id selects the row, offset is the byte offset from the beginning of that row’s blob value, and length is the number of bytes to read. The request array is borrowed for the duration of the call.

struct LanceDBBlobBuffer
#include <lancedb.h>

Bytes of one blob read owned by LanceDB.

A read that returned no bytes leaves both fields zeroed; a successful read of non-empty bytes sets data to the first byte and len to the byte count. data stays valid until lancedb_blob_buffer_free() is called, independently of the handle and of the table. The caller must not write to or free it, and keeps both fields unchanged until then.

struct LanceDBBlobFilePosition
#include <lancedb.h>

Physical location of one blob inside its data file.

has_position is non-zero for embedded handles. Remote handles do not expose their storage layout and report it as zero with position zeroed. This is not the read cursor: seek and read move the cursor, while read_range leaves it unchanged.