|
Lance C/C++ Bindings
C ABI and header-only C++ RAII wrappers for the Lance columnar data format
|
#include <lance/detail/declarations.hpp>
Public Member Functions | |
| Fragment (LanceFragment *fragment) | |
| Adopt a handle from the C API; closed on destruction. | |
| Fragment (Fragment &&) noexcept=default | |
| Fragment & | operator= (Fragment &&) noexcept=default |
| Fragment (const Fragment &)=delete | |
| Fragment & | operator= (const Fragment &)=delete |
| uint64_t | id () const |
| Native fragment ID. | |
| uint64_t | data_file_count () const |
| Number of Native base data files; excludes overlays and the deletion file. | |
| bool | is_bound () const |
| Whether this handle retains a dataset-bound native fragment. | |
| DataFile | data_file_at (size_t index) const |
| Clone one native base data file from owned fragment metadata. | |
| std::optional< DataFile > | data_file_for_field (int32_t field_id) const |
| std::string | metadata_json () const |
| void | schema (ArrowSchema *out) const |
| LanceSchema | native_schema () const |
| Clone the fragment's native schema from its staged dataset snapshot. | |
| uint64_t | physical_rows () const |
| Physical row count, including deleted rows. May perform data-file I/O. | |
| uint64_t | deleted_rows () const |
| Deleted-row count. May load the deletion vector. | |
| uint64_t | logical_rows () const |
| Logical row count from Native count_rows(None). | |
| uint64_t | read_version () const |
| Dataset read version captured by this bound fragment. | |
| Scanner | scan () const |
| Start a scanner over this fragment's owned snapshot. | |
| void | take (const uint32_t *indices, size_t num_indices, const std::vector< std::string > &columns, ArrowArrayStream *out) const |
| void | take (const uint32_t *indices, size_t num_indices, ArrowArrayStream *out) const |
| Take fragment-local logical rows with the full logical schema. | |
| ArrowStream | take (const uint32_t *indices, size_t num_indices, const std::vector< std::string > &columns) const |
| ArrowStream | take (const uint32_t *indices, size_t num_indices) const |
| ArrowStream | take (std::span< const uint32_t > indices, const std::vector< std::string > &columns) const |
| ArrowStream | take (std::span< const uint32_t > indices) const |
| uint64_t | count_rows (std::optional< std::string > filter=std::nullopt) const |
| std::optional< Fragment > | delete_if (const std::string &predicate) const |
| std::pair< Fragment, LanceSchema > | add_columns_sql (const std::vector< SqlColumn > &columns, std::optional< uint32_t > batch_size=std::nullopt) const |
| std::pair< Fragment, LanceSchema > | add_columns_nulls (const ArrowSchema *columns) const |
| Add all-null columns described by a borrowed Arrow schema. | |
| std::pair< Fragment, LanceSchema > | add_columns_reader (ArrowArrayStream *stream, std::optional< uint32_t > batch_size=std::nullopt) const |
| Add columns from a consumed Arrow stream using Native Reader semantics. | |
| std::pair< Fragment, LanceSchema > | add_columns_batch_udf (const BatchUDF &udf, std::optional< std::vector< std::string > > read_columns=std::nullopt, std::optional< uint32_t > batch_size=std::nullopt) const |
| Add columns through the shared BatchUDF callback adapter. | |
| std::pair< Fragment, LanceSchema > | add_columns_batch_udf (const BatchUDFV2 &udf, std::optional< std::vector< std::string > > read_columns=std::nullopt, std::optional< uint32_t > batch_size=std::nullopt) const |
| Add columns through the shared schema-aware BatchUDF adapter. | |
| std::pair< Fragment, LanceSchema > | merge_columns (ArrowArrayStream *stream, const std::string &left_on, const std::string &right_on) const |
| Merge a consumed right-hand Arrow stream into this bound fragment. | |
| FragmentUpdateColumnsResult | update_columns (ArrowArrayStream *stream, const std::string &left_on, const std::string &right_on) const |
| DataReplacementGroup | write_columns (const LanceSchema &schema, ArrowArrayStream *stream) const |
| Stage a replacement data file using the manifest's default version. | |
| DataReplacementGroup | write_column_with_version (const LanceSchema &schema, ArrowArrayStream *stream, LanceFileFormatVersion file_version) const |
| Stage a replacement data file using an explicit native file version. | |
| std::optional< Fragment > | delete_rows (const std::vector< uint32_t > &offsets) const |
| FragmentOverlayWriter | write_overlay (const LanceSchema &schema) const |
| const LanceFragment * | c_handle () const |
Static Public Member Functions | |
| static Fragment | from_data_files (uint64_t fragment_id, const std::vector< const DataFile * > &data_files, std::optional< uint64_t > physical_rows=std::nullopt) |
| static Fragment | create (const std::string &dataset_uri, ArrowArrayStream *stream, uint64_t fragment_id, const FragmentCreateOptions &options={}, const std::vector< std::pair< std::string, std::string > > &storage_opts={}, const Session *session=nullptr) |
| static std::vector< Fragment > | create_many (const std::string &dataset_uri, ArrowArrayStream *stream, const FragmentCreateOptions &options={}, const std::vector< std::pair< std::string, std::string > > &storage_opts={}, const Session *session=nullptr) |
| static Fragment | create_from_file (const Dataset &dataset, const std::string &filename, uint64_t fragment_id, std::optional< uint64_t > physical_rows=std::nullopt) |
RAII handle over a dataset-bound or independently constructed fragment. Native FileFragment owns an Arc<Dataset>, so bound handles remain valid and keep reading the same dataset version after the source Dataset is closed or mutated. Detached handles own copied native metadata and support operation construction without dataset access.
Definition at line 2554 of file declarations.hpp.
|
explicit |
Adopt a handle from the C API; closed on destruction.
|
defaultnoexcept |
|
delete |
| std::pair< Fragment, LanceSchema > lance::Fragment::add_columns_batch_udf | ( | const BatchUDF & | udf, |
| std::optional< std::vector< std::string > > | read_columns = std::nullopt, | ||
| std::optional< uint32_t > | batch_size = std::nullopt ) const |
Add columns through the shared BatchUDF callback adapter.
| std::pair< Fragment, LanceSchema > lance::Fragment::add_columns_batch_udf | ( | const BatchUDFV2 & | udf, |
| std::optional< std::vector< std::string > > | read_columns = std::nullopt, | ||
| std::optional< uint32_t > | batch_size = std::nullopt ) const |
Add columns through the shared schema-aware BatchUDF adapter.
| std::pair< Fragment, LanceSchema > lance::Fragment::add_columns_nulls | ( | const ArrowSchema * | columns | ) | const |
Add all-null columns described by a borrowed Arrow schema.
| std::pair< Fragment, LanceSchema > lance::Fragment::add_columns_reader | ( | ArrowArrayStream * | stream, |
| std::optional< uint32_t > | batch_size = std::nullopt ) const |
Add columns from a consumed Arrow stream using Native Reader semantics.
| std::pair< Fragment, LanceSchema > lance::Fragment::add_columns_sql | ( | const std::vector< SqlColumn > & | columns, |
| std::optional< uint32_t > | batch_size = std::nullopt ) const |
Add SQL-derived columns to this bound fragment.
batch_size == std::nullopt maps to native None; an engaged zero is forwarded as Some(0). Returns detached fragment metadata and the complete native final schema for a later Merge operation.
| const LanceFragment * lance::Fragment::c_handle | ( | ) | const |
| uint64_t lance::Fragment::count_rows | ( | std::optional< std::string > | filter = std::nullopt | ) | const |
Count fragment rows. std::nullopt calls native count_rows(None); an empty string is passed as an explicit native filter.
|
static |
Create one fragment without publishing a version.
Maps to native FragmentCreateBuilder::write(source, Some(fragment_id)). Native owns schema inference and compatibility, file format, physical row counts and error semantics; an empty input fails with the native "Input
data was empty." error. The stream is consumed on every return path, including a null stream pointer (which is rejected unconsumed) and local conversion failures. A null options.schema keeps native inference.
Returns independently owned detached metadata that stays valid after the source dataset, schema and session are closed. Closing it never deletes the written data file; publish the fragment with an Append transaction.
|
static |
Create one fragment from an existing Lance data file in dataset's data directory.
Maps to native FileFragment::create_from_file. filename is relative to the dataset's data directory. physical_rows == std::nullopt maps to native None; an engaged value maps to Some(value). Native owns file version, schema compatibility and physical-row validation. The dataset supplies the target snapshot and is not modified. A file whose stored schema native cannot project to the dataset schema is rejected, as with Blob v2 data files.
|
static |
Create zero or more fragments without publishing a version.
Maps to native FragmentCreateBuilder::write_fragments, so options.write.params.max_rows_per_file splitting and fragment ID assignment stay native. The stream follows the same consumption contract as create; an empty input returns an empty vector.
| DataFile lance::Fragment::data_file_at | ( | size_t | index | ) | const |
Clone one native base data file from owned fragment metadata.
| uint64_t lance::Fragment::data_file_count | ( | ) | const |
Number of Native base data files; excludes overlays and the deletion file.
| std::optional< DataFile > lance::Fragment::data_file_for_field | ( | int32_t | field_id | ) | const |
Find the native base data file that stores a field ID. Missing fields return std::nullopt; a negative field ID is an invalid argument.
| std::optional< Fragment > lance::Fragment::delete_if | ( | const std::string & | predicate | ) | const |
Delete rows from this fragment without publishing a transaction.
The source handle remains usable. The returned fragment owns the new deletion-file metadata and can be scanned before publication. A full deletion returns std::nullopt.
| std::optional< Fragment > lance::Fragment::delete_rows | ( | const std::vector< uint32_t > & | offsets | ) | const |
Add physical row offsets to a clone and return updated bound metadata. A full deletion returns std::nullopt.
| uint64_t lance::Fragment::deleted_rows | ( | ) | const |
Deleted-row count. May load the deletion vector.
|
static |
Construct detached native Fragment metadata from borrowed data files.
The data files are cloned in input order. physical_rows == / std::nullopt maps to native None; all other metadata retains native Fragment::new defaults. A fragment ID of zero requests native commit-time allocation. Schema coverage and physical_rows are caller metadata; this constructor does not infer or revalidate them.
| uint64_t lance::Fragment::id | ( | ) | const |
Native fragment ID.
| bool lance::Fragment::is_bound | ( | ) | const |
Whether this handle retains a dataset-bound native fragment.
| uint64_t lance::Fragment::logical_rows | ( | ) | const |
Logical row count from Native count_rows(None).
| std::pair< Fragment, LanceSchema > lance::Fragment::merge_columns | ( | ArrowArrayStream * | stream, |
| const std::string & | left_on, | ||
| const std::string & | right_on ) const |
Merge a consumed right-hand Arrow stream into this bound fragment.
| std::string lance::Fragment::metadata_json | ( | ) | const |
Native Fragment metadata serialized as JSON. Includes base data files, overlays, deletion-file metadata, row-id/version metadata, and the optional physical_rows value.
| LanceSchema lance::Fragment::native_schema | ( | ) | const |
Clone the fragment's native schema from its staged dataset snapshot.
| uint64_t lance::Fragment::physical_rows | ( | ) | const |
Physical row count, including deleted rows. May perform data-file I/O.
| uint64_t lance::Fragment::read_version | ( | ) | const |
Dataset read version captured by this bound fragment.
| Scanner lance::Fragment::scan | ( | ) | const |
Start a scanner over this fragment's owned snapshot.
| void lance::Fragment::schema | ( | ArrowSchema * | out | ) | const |
Export the logical dataset schema through Arrow C Data Interface. out is caller-owned; release it exactly once.
| ArrowStream lance::Fragment::take | ( | const uint32_t * | indices, |
| size_t | num_indices ) const |
Take fragment-local logical rows with all columns and return the owning stream. Ownership and validation follow the projecting overload above.
| void lance::Fragment::take | ( | const uint32_t * | indices, |
| size_t | num_indices, | ||
| ArrowArrayStream * | out ) const |
Take fragment-local logical rows with the full logical schema.
| ArrowStream lance::Fragment::take | ( | const uint32_t * | indices, |
| size_t | num_indices, | ||
| const std::vector< std::string > & | columns ) const |
Take fragment-local logical rows and return the owning stream.
The projection, explicit-empty-projection behavior and native validation are the same as the raw-out overload. The returned ArrowStream releases the native stream exactly once, on destruction or reset(); moving it transfers ownership and leaves the source empty. out from the raw-out overload remains caller-owned.
| void lance::Fragment::take | ( | const uint32_t * | indices, |
| size_t | num_indices, | ||
| const std::vector< std::string > & | columns, | ||
| ArrowArrayStream * | out ) const |
Take fragment-local logical rows by index with an explicit projection. Indices retain the selected core's ordering and duplicate constraints. out is caller-owned and its non-null release must be called exactly once. An empty columns vector is an explicit empty projection and produces a zero-column batch with the requested row count.
| ArrowStream lance::Fragment::take | ( | std::span< const uint32_t > | indices | ) | const |
Borrow all-column indices from a contiguous range and return the owning stream. Ownership follows the overload above.
| ArrowStream lance::Fragment::take | ( | std::span< const uint32_t > | indices, |
| const std::vector< std::string > & | columns ) const |
Borrow indices from a contiguous range and return the owning stream. The range is read only during this call. Empty-range and projection behavior are inherited from the pointer/count overload above.
| FragmentUpdateColumnsResult lance::Fragment::update_columns | ( | ArrowArrayStream * | stream, |
| const std::string & | left_on, | ||
| const std::string & | right_on ) const |
Rewrite existing columns through a native join and return matched physical offsets with the updated metadata.
| DataReplacementGroup lance::Fragment::write_column_with_version | ( | const LanceSchema & | schema, |
| ArrowArrayStream * | stream, | ||
| LanceFileFormatVersion | file_version ) const |
Stage a replacement data file using an explicit native file version.
| DataReplacementGroup lance::Fragment::write_columns | ( | const LanceSchema & | schema, |
| ArrowArrayStream * | stream ) const |
Stage a replacement data file using the manifest's default version.
| FragmentOverlayWriter lance::Fragment::write_overlay | ( | const LanceSchema & | schema | ) | const |
Open an overlay writer for this bound fragment. The schema may be a compatible subset of the fragment schema. Commit the resulting overlay with the dataset read version used to open the writer. Native overlays are experimental. For release builds, set LANCE_ENABLE_UNSTABLE_DATA_OVERLAY_FILES=1 in every process that reads or modifies an overlay dataset, including before publication.