Lance C/C++ Bindings
C ABI and header-only C++ RAII wrappers for the Lance columnar data format
Loading...
Searching...
No Matches
lance::Scanner Class Reference

#include <lance/detail/declarations.hpp>

Public Member Functions

 Scanner (LanceScanner *s)
 
Scanner & limit (int64_t n)
 Set the row limit.
 
Scanner & offset (int64_t n)
 Set the row offset.
 
Scanner & batch_size (int64_t n)
 Set the batch size.
 
Scanner & batch_size_bytes (uint64_t bytes)
 Set the target output batch size in bytes.
 
Scanner & io_buffer_size (uint64_t bytes)
 Set the scanner I/O buffer size in bytes, in the range [1, INT64_MAX].
 
Scanner & batch_readahead (size_t batches)
 Set the number of batches decoded concurrently.
 
Scanner & fragment_readahead (size_t fragments)
 Set fragment readahead for unordered scans.
 
Scanner & target_parallelism (size_t partitions)
 Set the target number of physical execution partitions.
 
Scanner & scan_in_order (bool ordered=true)
 Configure whether batches are returned in storage order.
 
Scanner & use_scalar_index (bool enable=true)
 
Scanner & strict_batch_size (bool strict_batch_size=true)
 Configure whether row-based output batches are strict.
 
Scanner & use_stats (bool use_stats=true)
 Configure whether file statistics may optimize the scan.
 
Scanner & project (std::nullopt_t)
 Clear the projection and scan all dataset columns (native unset).
 
Scanner & project (const std::vector< ProjectionColumn > &columns)
 
Scanner & disable_scoring_autoprojection ()
 Stop adding _score / _distance to explicit search projections.
 
Scanner & order_by (std::nullopt_t)
 
Scanner & order_by (const std::vector< ColumnOrdering > &orderings)
 
Scanner & blob_handling (LanceBlobHandling handling)
 
Scanner & materialization_style (LanceMaterializationStyle style, const std::vector< std::string > &early_except_columns={})
 
Scanner & with_row_id (bool enable=true)
 Enable/disable row ID in output.
 
Scanner & with_row_address (bool enable=true)
 Include or omit the _rowaddr metadata column.
 
Scanner & include_deleted_rows (bool include_deleted_rows=true)
 
Scanner & scalar_index_segment (const std::array< uint8_t, 16 > &segment_uuid)
 
Scanner & scalar_index_auto_selection (bool enabled=true)
 
Scanner & clear_scalar_index_segment ()
 
Scanner & fragment_ids (const uint64_t *ids, size_t len)
 
Scanner & fragment_ids (const std::vector< uint64_t > &ids)
 Restrict the scan/search domain to specific fragment IDs (vector overload).
 
Scanner & row_addr_allowlist (const uint64_t *row_ids, size_t len)
 
Scanner & row_addr_allowlist (const std::vector< uint64_t > &row_ids)
 Restrict the scan or search to rows whose _rowid is in row_ids (vector overload).
 
Scanner & row_addr_blocklist (const uint64_t *row_ids, size_t len)
 Exclude rows whose _rowid is in row_ids (applied before ranking).
 
Scanner & row_addr_blocklist (const std::vector< uint64_t > &row_ids)
 Exclude rows whose _rowid is in row_ids (vector overload).
 
Scanner & substrait_filter (const uint8_t *bytes, size_t len)
 
Scanner & substrait_filter (const std::vector< uint8_t > &bytes)
 Set a Substrait filter (vector overload).
 
Scanner & substrait_aggregate (const uint8_t *bytes, size_t len)
 
Scanner & substrait_aggregate (const std::vector< uint8_t > &bytes)
 Set a Substrait aggregate Plan (vector overload).
 
Scanner & additional_sql_filter (const std::string &filter)
 Add an SQL filter that is combined with the selected primary filter using AND.
 
Scanner & statistics_callback (LanceScanStatisticsCallback callback, void *callback_ctx)
 
Scanner & index_segments (const uint8_t *uuids, size_t len)
 
Scanner & index_segments (const std::vector< std::array< uint8_t, 16 > > &uuids)
 
void schema (ArrowSchema *out) const
 
std::string explain_plan (bool verbose=false) const
 Explain the configured native plan without executing it.
 
std::string analyze_plan () const
 
uint64_t count_rows () const
 
std::string analyze_count_plan () const
 Execute and format the native COUNT(*) plan, not the ordinary plan.
 
void to_arrow_stream (ArrowArrayStream *out)
 
ArrowStream to_arrow_stream ()
 
void scan_async (LanceCallback callback, void *ctx) const
 
Scanner & nearest (const std::string &column, const float *q, size_t dim, uint32_t k)
 k-NN search (Float32 sugar).
 
Scanner & nearest (const std::string &column, std::span< const float > q, uint32_t k)
 
Scanner & nearest (const std::string &column, const void *q, size_t dim, LanceDataType dtype, uint32_t k)
 k-NN search (typed).
 
Scanner & distance_range (std::optional< float > lower_bound=std::nullopt, std::optional< float > upper_bound=std::nullopt)
 
Scanner & nearest_batch (const std::string &column, const void *query_data, size_t dimension, size_t num_queries, LanceDataType element_type, uint32_t k)
 Independent queries; each returns up to k rows tagged with query_index.
 
Scanner & nearest_batch (const std::string &column, const float *query_data, size_t dimension, size_t num_queries, uint32_t k)
 Float32 batch convenience overload; input values are copied before returning.
 
Scanner & nearest_batch (const std::string &column, std::span< const float > queries, size_t dimension, uint32_t k)
 
Scanner & nearest_multivector (const std::string &column, const void *query_data, size_t dimension, size_t num_vectors, LanceDataType element_type, uint32_t k)
 One multi-vector query, copied from dimension * num_vectors row-major elements.
 
Scanner & nprobes (uint32_t nprobes)
 Replace both minimum and maximum partition-search bounds.
 
Scanner & minimum_nprobes (uint32_t minimum_nprobes)
 Replace only the minimum partition-search bound.
 
Scanner & maximum_nprobes (uint32_t maximum_nprobes)
 Replace only the maximum partition-search bound.
 
Scanner & search_effort (double effort)
 
Scanner & approx_mode (LanceApproxMode approx_mode)
 
Scanner & query_parallelism (int32_t parallelism)
 
Scanner & refine_factor (uint32_t f)
 
Scanner & ef (uint32_t e)
 
Scanner & metric (LanceMetricType m)
 
Scanner & use_index (bool enable)
 
Scanner & fast_search (bool enable=true)
 
Scanner & prefilter (bool enable)
 
Scanner & full_text_search (const std::string &query, const std::vector< std::string > &columns={}, uint32_t max_fuzzy_distance=0)
 
Scanner & full_text_search (const FtsQuery &query)
 
Scanner & minhash_search (const std::string &column, const std::string &text)
 
Scanner & fts_query_context (const FtsQueryContext &context)
 
Scanner & fts_index_segments (const uint8_t *segment_uuids, size_t segment_count)
 Restrict a context-backed FTS query to a segment UUID subset.
 
Scanner & fts_index_segments (const std::vector< std::array< uint8_t, 16 > > &segment_uuids)
 
LanceScanner * c_handle ()
 Access the underlying C handle.
 

Friends

class Fragment
 

Detailed Description

Definition at line 5706 of file declarations.hpp.

Constructor & Destructor Documentation

◆ Scanner()

lance::Scanner::Scanner ( LanceScanner * s)
explicit

Member Function Documentation

◆ additional_sql_filter()

Scanner & lance::Scanner::additional_sql_filter ( const std::string & filter)

Add an SQL filter that is combined with the selected primary filter using AND.

◆ analyze_count_plan()

std::string lance::Scanner::analyze_count_plan ( ) const

Execute and format the native COUNT(*) plan, not the ordinary plan.

◆ analyze_plan()

std::string lance::Scanner::analyze_plan ( ) const

Execute and format the configured native plan with runtime metrics. Does not consume or advance an existing stream.

◆ approx_mode()

Scanner & lance::Scanner::approx_mode ( LanceApproxMode approx_mode)

◆ batch_readahead()

Scanner & lance::Scanner::batch_readahead ( size_t batches)

Set the number of batches decoded concurrently.

◆ batch_size()

Scanner & lance::Scanner::batch_size ( int64_t n)

Set the batch size.

◆ batch_size_bytes()

Scanner & lance::Scanner::batch_size_bytes ( uint64_t bytes)

Set the target output batch size in bytes.

◆ blob_handling()

Scanner & lance::Scanner::blob_handling ( LanceBlobHandling handling)

Choose how blob columns are materialized (default: descriptors for blob columns, bytes for every other binary column).

◆ c_handle()

LanceScanner * lance::Scanner::c_handle ( )

Access the underlying C handle.

◆ clear_scalar_index_segment()

Scanner & lance::Scanner::clear_scalar_index_segment ( )

◆ count_rows()

uint64_t lance::Scanner::count_rows ( ) const

Execute the native COUNT(*) plan for this scanner. Native aggregate planning rejects configured limit/offset/ordering. Throws lance::Error on failure.

◆ disable_scoring_autoprojection()

Scanner & lance::Scanner::disable_scoring_autoprojection ( )

Stop adding _score / _distance to explicit search projections.

◆ distance_range()

Scanner & lance::Scanner::distance_range ( std::optional< float > lower_bound = std::nullopt,
std::optional< float > upper_bound = std::nullopt )

Restrict single-vector nearest results to [lower_bound, upper_bound). Call after nearest() and before scanning. Omitted bounds are unbounded; distance_range() clears both. Bounds must be finite and lower < upper when both are present. Uses metric distance units (squared L2 for L2). The nearest query's k cap and ANN candidate selection still apply.

◆ ef()

Scanner & lance::Scanner::ef ( uint32_t e)

◆ explain_plan()

std::string lance::Scanner::explain_plan ( bool verbose = false) const

Explain the configured native plan without executing it.

◆ fast_search()

Scanner & lance::Scanner::fast_search ( bool enable = true)

Use native indexed-only fast search for vector, scalar-filtered, full-text and MinHash queries. Index-backed paths can omit unindexed data. Ordinary scans and non-indexable expressions follow native planning. Disabled by default. See lance.h.

◆ fragment_ids() [1/2]

Scanner & lance::Scanner::fragment_ids ( const std::vector< uint64_t > & ids)

Restrict the scan/search domain to specific fragment IDs (vector overload).

◆ fragment_ids() [2/2]

Scanner & lance::Scanner::fragment_ids ( const uint64_t * ids,
size_t len )

Restrict the scan/search domain to specific fragment IDs. For nearest queries, they limit candidates before Top-K regardless of prefilter().

◆ fragment_readahead()

Scanner & lance::Scanner::fragment_readahead ( size_t fragments)

Set fragment readahead for unordered scans.

◆ fts_index_segments() [1/2]

Scanner & lance::Scanner::fts_index_segments ( const std::vector< std::array< uint8_t, 16 > > & segment_uuids)

◆ fts_index_segments() [2/2]

Scanner & lance::Scanner::fts_index_segments ( const uint8_t * segment_uuids,
size_t segment_count )

Restrict a context-backed FTS query to a segment UUID subset.

◆ fts_query_context()

Scanner & lance::Scanner::fts_query_context ( const FtsQueryContext & context)

Attach a process-local prepared FTS query context. The scanner retains shared ownership, so the context object may be destroyed after success.

◆ full_text_search() [1/2]

Scanner & lance::Scanner::full_text_search ( const FtsQuery & query)

Attach an immutable typed FTS query. The scanner snapshots the tree, so the query and its source handles may be destroyed after success.

◆ full_text_search() [2/2]

Scanner & lance::Scanner::full_text_search ( const std::string & query,
const std::vector< std::string > & columns = {},
uint32_t max_fuzzy_distance = 0 )

BM25 full-text search. columns empty → search all FTS-indexed columns. max_fuzzy_distance 0 = exact; >0 = MatchQuery::with_fuzziness.

◆ include_deleted_rows()

Scanner & lance::Scanner::include_deleted_rows ( bool include_deleted_rows = true)

Configure whether deleted rows still present in storage are returned. Requires with_row_id(true); use_scalar_index(false) is needed for filtered scans. Incompatible with scalar_index_segment. See lance.h.

◆ index_segments() [1/2]

Scanner & lance::Scanner::index_segments ( const std::vector< std::array< uint8_t, 16 > > & uuids)

Restrict the next k-NN query to a subset of vector index segments (typed vector overload).

◆ index_segments() [2/2]

Scanner & lance::Scanner::index_segments ( const uint8_t * uuids,
size_t len )

Restrict the next k-NN query to a subset of vector index segments. Pass len 16-byte UUIDs concatenated as a single byte buffer (total bytes = len * 16). Pass len=0 (and any pointer) to clear.

◆ io_buffer_size()

Scanner & lance::Scanner::io_buffer_size ( uint64_t bytes)

Set the scanner I/O buffer size in bytes, in the range [1, INT64_MAX].

◆ limit()

Scanner & lance::Scanner::limit ( int64_t n)

Set the row limit.

◆ materialization_style()

Scanner & lance::Scanner::materialization_style ( LanceMaterializationStyle style,
const std::vector< std::string > & early_except_columns = {} )

Configure native materialization for ordinary payload columns. For ALL_EARLY_EXCEPT, names are resolved by Lance, including nested paths. An empty list is an explicit empty exception list. See lance.h.

◆ maximum_nprobes()

Scanner & lance::Scanner::maximum_nprobes ( uint32_t maximum_nprobes)

Replace only the maximum partition-search bound.

◆ metric()

Scanner & lance::Scanner::metric ( LanceMetricType m)

◆ minhash_search()

Scanner & lance::Scanner::minhash_search ( const std::string & column,
const std::string & text )

Native MinHash LSH text-similarity search. column must have a MinHash LSH scalar index and the scanner must have a limit. Results are ordered by native _distance (1 - estimated Jaccard similarity).

◆ minimum_nprobes()

Scanner & lance::Scanner::minimum_nprobes ( uint32_t minimum_nprobes)

Replace only the minimum partition-search bound.

◆ nearest() [1/3]

Scanner & lance::Scanner::nearest ( const std::string & column,
const float * q,
size_t dim,
uint32_t k )

k-NN search (Float32 sugar).

◆ nearest() [2/3]

Scanner & lance::Scanner::nearest ( const std::string & column,
const void * q,
size_t dim,
LanceDataType dtype,
uint32_t k )

k-NN search (typed).

◆ nearest() [3/3]

Scanner & lance::Scanner::nearest ( const std::string & column,
std::span< const float > q,
uint32_t k )

k-NN search over a contiguous Float32 query vector. The span length is used as the query dimension and must match the column.

◆ nearest_batch() [1/3]

Scanner & lance::Scanner::nearest_batch ( const std::string & column,
const float * query_data,
size_t dimension,
size_t num_queries,
uint32_t k )

Float32 batch convenience overload; input values are copied before returning.

◆ nearest_batch() [2/3]

Scanner & lance::Scanner::nearest_batch ( const std::string & column,
const void * query_data,
size_t dimension,
size_t num_queries,
LanceDataType element_type,
uint32_t k )

Independent queries; each returns up to k rows tagged with query_index.

◆ nearest_batch() [3/3]

Scanner & lance::Scanner::nearest_batch ( const std::string & column,
std::span< const float > queries,
size_t dimension,
uint32_t k )

Float32 batch sugar over a contiguous row-major matrix. The number of queries is derived from the span length, which must be a multiple of dimension. Values are copied before returning.

◆ nearest_multivector()

Scanner & lance::Scanner::nearest_multivector ( const std::string & column,
const void * query_data,
size_t dimension,
size_t num_vectors,
LanceDataType element_type,
uint32_t k )

One multi-vector query, copied from dimension * num_vectors row-major elements.

◆ nprobes()

Scanner & lance::Scanner::nprobes ( uint32_t nprobes)

Replace both minimum and maximum partition-search bounds.

◆ offset()

Scanner & lance::Scanner::offset ( int64_t n)

Set the row offset.

◆ order_by() [1/2]

Scanner & lance::Scanner::order_by ( const std::vector< ColumnOrdering > & orderings)

◆ order_by() [2/2]

Scanner & lance::Scanner::order_by ( std::nullopt_t )

Replace the native result ordering. std::nullopt clears it; an empty vector is the explicit native empty ordering. Lance validates column names when the scan is materialized. Not supported with nearest_multivector(); that scan fails on start.

◆ prefilter()

Scanner & lance::Scanner::prefilter ( bool enable)

Apply scanner filters before vector/MinHash ranking when enabled, or refine ranked candidates afterward when disabled; postfiltering may return fewer than the configured limit. This does not change the fragment search domain.

◆ project() [1/2]

Scanner & lance::Scanner::project ( const std::vector< ProjectionColumn > & columns)

Replace the projection with ordered output-name / SQL-expression pairs. An empty vector is an explicit empty projection; use std::nullopt to restore the unset projection. Strings are copied during this call.

◆ project() [2/2]

Scanner & lance::Scanner::project ( std::nullopt_t )

Clear the projection and scan all dataset columns (native unset).

◆ query_parallelism()

Scanner & lance::Scanner::query_parallelism ( int32_t parallelism)

◆ refine_factor()

Scanner & lance::Scanner::refine_factor ( uint32_t f)

◆ row_addr_allowlist() [1/2]

Scanner & lance::Scanner::row_addr_allowlist ( const std::vector< uint64_t > & row_ids)

Restrict the scan or search to rows whose _rowid is in row_ids (vector overload).

◆ row_addr_allowlist() [2/2]

Scanner & lance::Scanner::row_addr_allowlist ( const uint64_t * row_ids,
size_t len )

Restrict the scan or search to rows whose _rowid is in row_ids (applied before ranking). len == 0 allows no rows.

◆ row_addr_blocklist() [1/2]

Scanner & lance::Scanner::row_addr_blocklist ( const std::vector< uint64_t > & row_ids)

Exclude rows whose _rowid is in row_ids (vector overload).

◆ row_addr_blocklist() [2/2]

Scanner & lance::Scanner::row_addr_blocklist ( const uint64_t * row_ids,
size_t len )

Exclude rows whose _rowid is in row_ids (applied before ranking).

◆ scalar_index_auto_selection()

Scanner & lance::Scanner::scalar_index_auto_selection ( bool enabled = true)

Enable bounded page-cost selection among BTree segments covering the read domain. Applies only to scalar_index_segment scans; fragment_ids remains required. Disabled by default.

◆ scalar_index_segment()

Scanner & lance::Scanner::scalar_index_segment ( const std::array< uint8_t, 16 > & segment_uuid)

Generate exact candidates from one BTree/Bitmap/LabelList segment. fragment_ids is required and defines the complete read/fallback domain. See lance.h. Requires live rows only: vector/MinHash/FTS queries and include_deleted_rows(true) are rejected at stream creation. use_scalar_index(false) selects the scoped fallback without searching the segment.

◆ scan_async()

void lance::Scanner::scan_async ( LanceCallback callback,
void * ctx ) const

Start an async scan with a non-null callback. On success, the callback's ArrowArrayStream result is library-allocated and must be passed exactly once to lance::scanner_async_stream_free, which also invokes release when necessary. The callback normally runs on the dispatcher thread, but a rare infrastructure fallback may invoke it on the calling or producing thread, possibly before this method returns, so it must be thread-safe. Exactly one completion is delivered; callback and non-null context storage must remain valid until it returns.

◆ scan_in_order()

Scanner & lance::Scanner::scan_in_order ( bool ordered = true)

Configure whether batches are returned in storage order.

◆ schema()

void lance::Scanner::schema ( ArrowSchema * out) const

Export the configured output schema from its actual native plan. Planning-only; does not start iteration or advance an existing stream. out is caller-owned; release it exactly once on success.

◆ search_effort()

Scanner & lance::Scanner::search_effort ( double effort)

Set native continuous IVF search effort. Any explicit value, including 0.5, ignores fixed nprobes while explicit minimum/maximum remain.

◆ statistics_callback()

Scanner & lance::Scanner::statistics_callback ( LanceScanStatisticsCallback callback,
void * callback_ctx )

Register a non-null callback for scan statistics after successful full exhaustion. The registration applies to every stream derived from this scanner, including concurrent streams and streams created after an earlier callback returns. The callback is not guaranteed on error, cancellation, or early release. It may run on the thread that observes EOF, must be thread-safe, must not throw, and must not re-enter the originating scanner. The callback and a non-null context must remain valid until the scanner is closed, all async scan requests have delivered their completion callbacks, and all derived streams are released. From callback entry until the enclosing operation that observes EOF has returned to its caller, the callback must not directly or indirectly cause any ArrowArrayStream derived from this Scanner to be accessed, called, released, moved, or destroyed. This includes signaling or scheduling another thread to act based only on callback completion: the callback returns before the enclosing stream operation does. Such interaction is reentrant and has undefined behavior. Normal access may resume only after the enclosing ArrowArrayStream get_next, lance_scanner_next, or lance_scanner_poll_next call returns.

◆ strict_batch_size()

Scanner & lance::Scanner::strict_batch_size ( bool strict_batch_size = true)

Configure whether row-based output batches are strict.

◆ substrait_aggregate() [1/2]

Scanner & lance::Scanner::substrait_aggregate ( const std::vector< uint8_t > & bytes)

Set a Substrait aggregate Plan (vector overload).

◆ substrait_aggregate() [2/2]

Scanner & lance::Scanner::substrait_aggregate ( const uint8_t * bytes,
size_t len )

Set a Substrait aggregate Plan (serialized bytes). The plan is validated immediately; a failed replacement keeps the previous aggregate. Count and analyze-count replace it with COUNT(*).

◆ substrait_filter() [1/2]

Scanner & lance::Scanner::substrait_filter ( const std::vector< uint8_t > & bytes)

Set a Substrait filter (vector overload).

◆ substrait_filter() [2/2]

Scanner & lance::Scanner::substrait_filter ( const uint8_t * bytes,
size_t len )

Set a Substrait filter (serialized ExtendedExpression bytes). Wins over any SQL filter passed to the Scanner constructor.

◆ target_parallelism()

Scanner & lance::Scanner::target_parallelism ( size_t partitions)

Set the target number of physical execution partitions.

◆ to_arrow_stream() [1/2]

ArrowStream lance::Scanner::to_arrow_stream ( )

Materialize an independent stream and return the owning handle.

The returned ArrowStream releases the native stream exactly once, on destruction or reset(); moving it transfers ownership and leaves the source empty. The raw-out overload above keeps its caller-owned contract. The scanner remains valid.

◆ to_arrow_stream() [2/2]

void lance::Scanner::to_arrow_stream ( ArrowArrayStream * out)

Materialize an independent ArrowArrayStream (blocking). The scanner remains valid. out is caller-owned; call its non-null release callback exactly once.

◆ use_index()

Scanner & lance::Scanner::use_index ( bool enable)

◆ use_scalar_index()

Scanner & lance::Scanner::use_scalar_index ( bool enable = true)

Configure whether scalar indices may be used to optimize filters. False also disables explicit scalar segment search, retaining its fragment domain.

◆ use_stats()

Scanner & lance::Scanner::use_stats ( bool use_stats = true)

Configure whether file statistics may optimize the scan.

◆ with_row_address()

Scanner & lance::Scanner::with_row_address ( bool enable = true)

Include or omit the _rowaddr metadata column.

◆ with_row_id()

Scanner & lance::Scanner::with_row_id ( bool enable = true)

Enable/disable row ID in output.

Friends And Related Symbol Documentation

◆ Fragment

friend class Fragment
friend

Definition at line 5710 of file declarations.hpp.


The documentation for this class was generated from the following file: