Lance C/C++ Bindings
C ABI and header-only C++ RAII wrappers for the Lance columnar data format
Loading...
Searching...
No Matches
declarations.hpp
Go to the documentation of this file.
1/* SPDX-License-Identifier: Apache-2.0 */
2/* SPDX-FileCopyrightText: Copyright The Lance Authors */
3
4// Shared C++ declarations for lance.hpp (generated from lance.hpp).
5#pragma once
6
7/* SPDX-License-Identifier: Apache-2.0 */
8/* SPDX-FileCopyrightText: Copyright The Lance Authors */
9
22#include "lance/lance.h"
23
24#include <array>
25#include <cstdlib>
26#include <cstring>
27#include <cstdint>
28#include <functional>
29#include <map>
30#include <memory>
31#include <optional>
32#include <span>
33#include <stdexcept>
34#include <string>
35#include <string_view>
36#include <utility>
37#include <vector>
38
39namespace lance {
40
41class Scanner;
43
44// ─── Version ─────────────────────────────────────────────────────────────────
45
48std::string_view version() noexcept;
49
50// ─── Error ───────────────────────────────────────────────────────────────────
51
52class Error : public std::runtime_error {
53public:
55
56 Error(LanceErrorCode code_value, std::string message);
57};
58
59namespace detail {
60
62struct FreeString {
63 void operator() (const char* ptr) const noexcept;
64};
65
67using OwnedString = std::unique_ptr<const char, FreeString>;
68
75[[noreturn]] void throw_error();
76
78std::string take_string(const char* raw);
79
81struct FreeBytes {
82 void operator() (uint8_t* ptr) const noexcept;
83};
84
86using OwnedBytes = std::unique_ptr<uint8_t, FreeBytes>;
87
90std::vector<uint8_t> take_bytes(uint8_t* raw, size_t len);
91
92} // namespace detail
93
100
105void init_logging(std::string_view filter = "info");
106
109std::string build_rq_model(uint32_t dimension, uint32_t num_bits = 5);
110
114
115// ─── RAII Handle Template ────────────────────────────────────────────────────
116
117template <typename T, void (*Deleter)(T*)>
118class Handle {
119 T* ptr_;
120
121public:
122 explicit Handle(T* ptr = nullptr) : ptr_(ptr) {}
124 if (ptr_) Deleter(ptr_);
125 }
126
127 Handle(Handle&& o) noexcept : ptr_(o.ptr_) { o.ptr_ = nullptr; }
128 Handle& operator=(Handle&& o) noexcept {
129 if (this != &o) {
130 if (ptr_) Deleter(ptr_);
131 ptr_ = o.ptr_;
132 o.ptr_ = nullptr;
133 }
134 return *this;
135 }
136
137 Handle(const Handle&) = delete;
138 Handle& operator=(const Handle&) = delete;
139
140 T* get() const { return ptr_; }
141 T* release() {
142 auto p = ptr_;
143 ptr_ = nullptr;
144 return p;
145 }
146 explicit operator bool() const { return ptr_ != nullptr; }
147};
148
155 ArrowArrayStream stream_{};
156 bool active_ = false;
157
158public:
159 ArrowStream() noexcept = default;
160
161 explicit ArrowStream(ArrowArrayStream stream) noexcept;
162
164
165 ArrowStream(const ArrowStream&) = delete;
166 ArrowStream& operator=(const ArrowStream&) = delete;
167
168 ArrowStream(ArrowStream&& other) noexcept;
169
170 ArrowStream& operator=(ArrowStream&& other) noexcept {
171 if (this != &other) {
172 reset();
173 stream_ = other.stream_;
174 active_ = other.active_;
175 other.stream_ = {};
176 other.active_ = false;
177 }
178 return *this;
179 }
180
181 void reset() noexcept {
182 if (active_ && stream_.release) {
183 stream_.release(&stream_);
184 }
185 stream_ = {};
186 active_ = false;
187 }
188
189 ArrowArrayStream* get() noexcept { return &stream_; }
190 const ArrowArrayStream* get() const noexcept { return &stream_; }
191 ArrowArrayStream* operator->() noexcept { return &stream_; }
192 const ArrowArrayStream* operator->() const noexcept { return &stream_; }
193 explicit operator bool() const noexcept { return active_; }
194};
195
196// ─── Forward Declarations ────────────────────────────────────────────────────
197
198class Scanner;
199class Dataset;
200class Fragment;
201class FragmentOverlayWriter;
202class FragmentUpdateColumnsResult;
203class LanceSchema;
204class Batch;
205struct Table;
206class ArrowSchemaOwner;
207class ShardWriter;
208class LsmScanner;
209class ExecutionPlan;
210class IndexModel;
211class IndexSegmentBuilder;
212class IndexSegmentMetadata;
213class CompactionOptions;
214class CompactionPlan;
215class CompactionTask;
216class RewriteResult;
217class UpdatedFragmentOffsets;
218class KeyExistenceFilter;
219class RewriteGroup;
220class RewrittenIndex;
221struct UpdateOperationSpec;
222struct CompactedSsTable;
223struct BasePath;
224class OptimizeIndicesOptions;
225class OptimizeIndicesPlan;
226class OptimizeIndexTask;
227class OptimizeIndexMerge;
228class IndexSegmentResult;
229class IvfModel;
230class FtsQueryContext;
231class FtsQuery;
232class Namespace;
233class SqlQueryBuilder;
234class SqlQuery;
235class DatasetDeltaBuilder;
236class DatasetDelta;
237class StorageOptionsAccessor;
238class CommitLock;
239class Session;
240
246struct BasePath {
247 uint32_t id = 0;
248 std::string path;
249 std::optional<std::string> name;
250 bool is_dataset_root = false;
251};
252
253// ─── Version history ─────────────────────────────────────────────────────────
254
259 uint64_t id;
261};
262
265 uint64_t id = 0;
266 int64_t timestamp_ns = 0;
267 std::map<std::string, std::string> metadata;
268};
269
272struct TagInfo {
273 std::string name;
274 std::optional<std::string> branch;
275 uint64_t version = 0;
276 std::optional<int64_t> created_at_ns;
277 std::optional<int64_t> updated_at_ns;
278 uint64_t manifest_size = 0;
279 std::map<std::string, std::string> metadata;
280};
281
283class Ref {
285
286public:
287 explicit Ref(LanceRef* reference);
288
289 Ref(Ref&&) noexcept = default;
290 Ref& operator=(Ref&&) noexcept = default;
291 Ref(const Ref&) = delete;
292 Ref& operator=(const Ref&) = delete;
293
294 static Ref version_number(uint64_t version);
295
296 static Ref version(
297 std::optional<std::string> branch,
298 std::optional<uint64_t> version_number);
299
300 static Ref tag(const std::string& tag_name);
301
302 const LanceRef* c_handle() const;
303};
304
309 uint32_t id;
311};
312
313// ─── Dataset maintenance ─────────────────────────────────────────────────────
314
317 uint64_t bytes_removed = 0;
318 uint64_t old_versions = 0;
319 uint64_t data_files_removed = 0;
320 uint64_t transaction_files_removed = 0;
321 uint64_t index_files_removed = 0;
322 uint64_t deletion_files_removed = 0;
323 uint64_t failed_deletes = 0;
324};
325
335
338 int64_t seconds = 0;
339 uint32_t nanos = 0;
340};
341
353 std::optional<CleanupTimestamp> before_timestamp;
354 std::optional<uint64_t> before_version;
355 std::optional<std::vector<uint64_t>> versions;
356 std::optional<uint64_t> retain_versions;
357 std::optional<bool> delete_unverified;
358 std::optional<bool> error_if_tagged_old_versions;
359 std::optional<bool> clean_referenced_branches;
360 std::optional<uint64_t> delete_rate_limit;
361};
362
367 std::optional<uint64_t> delete_concurrency;
368 std::optional<uint64_t> delete_rate_limit;
369 std::optional<uint64_t> max_candidate_files;
370};
371
374 int64_t older_than_seconds = 0;
375 int32_t older_than_nanos = 0;
376 std::optional<bool> delete_unverified;
377 std::optional<bool> error_if_tagged_old_versions;
378};
379
382 std::string path;
383 CleanupFileKind kind = CleanupFileKind::Manifest;
384 bool unverified = false;
385 uint64_t size_bytes = 0;
386};
387
390 std::string name;
391 uint64_t referenced_version = 0;
392 bool cleanup_candidate = false;
393};
394
397 uint64_t read_version = 0;
399 std::vector<CleanupCandidateFile> candidate_files;
400 bool candidate_files_truncated = false;
401 uint64_t candidate_file_limit = 0;
402 std::vector<CleanupReferencedBranch> referenced_branches;
403 std::vector<std::string> warnings;
404};
405
406// ─── Write mode ──────────────────────────────────────────────────────────────
407
413
418
423
427 FieldReferenceKind kind_;
428 int32_t field_id_ = 0;
429 std::string path_;
430
431 FieldReference(FieldReferenceKind kind, int32_t field_id, std::string path);
432
433public:
434 static FieldReference by_id(int32_t field_id);
435
436 static FieldReference by_path(std::string path);
437
439};
440
446 std::vector<std::pair<std::string, std::optional<std::string>>> values;
447 MetadataUpdateMode mode = MetadataUpdateMode::Merge;
448};
449
454
459
465
471
476 float boost = 1.0f;
477 std::optional<uint32_t> fuzziness = uint32_t{0};
478 uint64_t max_expansions = 50;
479 FtsMatchOperator match_operator = FtsMatchOperator::Or;
480 uint32_t prefix_length = 0;
481 FtsDocumentGranularity document_granularity =
482 FtsDocumentGranularity::Unspecified;
483};
484
487 uint32_t slop = 0;
488 FtsDocumentGranularity document_granularity =
489 FtsDocumentGranularity::Unspecified;
490};
491
495 std::optional<std::vector<float>> boosts;
496 FtsMatchOperator match_operator = FtsMatchOperator::Or;
497};
498
503 std::optional<std::vector<float>> boosts;
504 FtsMatchOperator match_operator = FtsMatchOperator::Or;
505};
506
509 float negative_boost = 0.5f;
510};
511
520 uint64_t max_rows_per_file = 0;
521 uint64_t max_rows_per_group = 0;
522 uint64_t max_bytes_per_file = 0;
524 std::optional<std::string> data_storage_version;
525 bool enable_stable_row_ids = false;
526};
527
541 uint64_t interval = 0;
542 int64_t older_than_seconds = 0;
543 int32_t older_than_nanos = 0;
544};
545
554 std::optional<AutoCleanupParams> auto_cleanup;
555 bool skip_auto_cleanup = false;
556};
557
564 const WriteOptions& options,
565 LanceAutoCleanupParams& cleanup);
566
570 uint64_t seconds = 0;
571 uint32_t nanos = 0;
572};
573
579
585 std::optional<bool> use_stable_row_ids;
586 std::optional<bool> enable_v2_manifest_paths;
587 std::optional<uint32_t> max_retries;
588 std::optional<CommitDuration> retry_timeout;
589 CommitTimeoutMode timeout_mode = CommitTimeoutMode::Default;
591 bool detached = false;
592 bool skip_auto_cleanup = false;
593 std::optional<std::string> data_storage_version;
594};
595
603 std::optional<std::vector<std::pair<std::string, std::string>>>
605};
606
611
617 std::optional<uint64_t> data_cache_bytes;
618 std::optional<uint64_t> max_page_bytes;
619 std::optional<bool> keep_original_array;
620};
621
627 std::string base_path;
628 const StorageOptionsAccessor* storage_options_accessor = nullptr;
629 std::optional<uint64_t> block_size;
630 std::optional<CommitDuration> s3_credentials_refresh_offset;
632 std::optional<bool> list_is_lexically_ordered;
633};
634
637 uint64_t bytes_written = 0;
638 uint64_t rows_written = 0;
639 uint32_t files_written = 0;
640};
641
644 uint64_t fragment_id = 0;
645 std::optional<uint64_t> physical_rows;
646 uint64_t file_count = 0;
647};
648
664
668 std::optional<std::vector<std::pair<std::string, std::string>>>
670 std::optional<bool> enable_v2_manifest_paths;
671 std::optional<std::vector<BasePath>> initial_bases;
672 std::optional<std::vector<uint32_t>> target_bases;
673 std::optional<std::vector<std::string>> target_base_names_or_paths;
674 std::optional<bool> target_all_bases;
675 std::optional<std::vector<DatasetBaseStoreParams>> base_store_params;
676 bool allow_external_blob_outside_bases = false;
677 ExternalBlobMode external_blob_mode = ExternalBlobMode::Reference;
678 std::optional<uint64_t> blob_pack_file_size_threshold;
679 std::optional<DatasetFileWriterOptions> file_writer_options;
680 const Session* session = nullptr;
681 const StorageOptionsAccessor* storage_options_accessor = nullptr;
682 const CommitLock* commit_lock = nullptr;
684};
685
694
695public:
697
699 NativeWriteOptions& operator=(NativeWriteOptions&&) noexcept = default;
701 NativeWriteOptions& operator=(const NativeWriteOptions&) = delete;
702
703 const LanceNativeWriteOptions* c_handle() const;
704};
705
715 const LanceSchema* schema = nullptr;
716 WriteMode mode = WriteMode::Create;
718};
719
720// ─── Native transactions ─────────────────────────────────────────────────────
721
723class DataFile {
725
726public:
727 explicit DataFile(LanceDataFile* file);
728
729 DataFile(DataFile&&) noexcept = default;
730 DataFile& operator=(DataFile&&) noexcept = default;
731 DataFile(const DataFile&) = delete;
732 DataFile& operator=(const DataFile&) = delete;
733
735 std::string path() const;
736
738 std::vector<int32_t> fields() const;
739
741 std::vector<int32_t> column_indices() const;
742
744 std::pair<uint32_t, uint32_t> file_version() const;
745
747 std::optional<uint64_t> file_size() const;
748
750 std::optional<uint32_t> base_id() const;
751
753 DataFile clone() const;
754
755 const LanceDataFile* c_handle() const;
756};
757
761 handle_;
762
763public:
765
767 DataReplacementGroup(uint64_t fragment_id, const DataFile& file);
768
770 DataReplacementGroup& operator=(DataReplacementGroup&&) noexcept = default;
772 DataReplacementGroup& operator=(const DataReplacementGroup&) = delete;
773
774 uint64_t fragment_id() const;
775
776 DataFile file() const;
777
779 DataReplacementGroup clone() const;
780
781 const LanceDataReplacementGroup* c_handle() const;
782};
783
792
793public:
794 explicit UpdateMap(LanceUpdateMap* map);
795
799 UpdateMap(const std::vector<std::string>& keys,
800 const std::vector<std::optional<std::string>>& values,
801 bool replace);
802
803 UpdateMap(UpdateMap&&) noexcept = default;
804 UpdateMap& operator=(UpdateMap&&) noexcept = default;
805 UpdateMap(const UpdateMap&) = delete;
806 UpdateMap& operator=(const UpdateMap&) = delete;
807
808 size_t count() const;
809
810 std::string key_at(size_t index) const;
811
812 std::optional<std::string> value_at(size_t index) const;
813
814 bool replace() const;
815
817 UpdateMap clone() const;
818
819 const LanceUpdateMap* c_handle() const;
820};
821
828 std::optional<UpdateMap> config_updates;
829 std::optional<UpdateMap> table_metadata_updates;
830 std::optional<UpdateMap> schema_metadata_updates;
831 std::map<int32_t, UpdateMap> field_metadata_updates;
832};
833
839
847
848public:
850
851 DataOverlayFile(const DataFile& data_file,
852 OverlayCoverageKind coverage_kind,
853 const std::vector<std::vector<uint8_t>>& bitmaps,
854 uint64_t committed_version = 0);
855
856 DataOverlayFile(DataOverlayFile&&) noexcept = default;
857 DataOverlayFile& operator=(DataOverlayFile&&) noexcept = default;
859 DataOverlayFile& operator=(const DataOverlayFile&) = delete;
860
862 DataFile data_file() const;
863
864 OverlayCoverageKind coverage_kind() const;
865
867 uint64_t bitmap_count() const;
868
870 std::vector<uint8_t> bitmap_at(size_t index) const;
871
873 uint64_t committed_version() const;
874
876 DataOverlayFile clone() const;
877
878 const LanceDataOverlayFile* c_handle() const;
879};
880
884
885public:
887
889 DataOverlayGroup(uint64_t fragment_id,
890 const std::vector<const DataOverlayFile*>& overlays);
891
892 DataOverlayGroup(DataOverlayGroup&&) noexcept = default;
893 DataOverlayGroup& operator=(DataOverlayGroup&&) noexcept = default;
895 DataOverlayGroup& operator=(const DataOverlayGroup&) = delete;
896
897 uint64_t fragment_id() const;
898
899 uint64_t overlay_count() const;
900
902 DataOverlayFile overlay_at(size_t index) const;
903
905 DataOverlayGroup clone() const;
906
907 const LanceDataOverlayGroup* c_handle() const;
908};
909
929
930// ─── Native update and rewrite values ───────────────────────────────────────
931
937
939struct IndexFile {
940 std::string path;
941 uint64_t size_bytes = 0;
942};
943
946 std::vector<uint8_t> bitmap;
947 uint32_t num_bits = 0;
948 uint64_t number_of_items = 0;
949 double probability = 0.0;
950};
951
961 handle_;
962
963public:
965
968 const std::vector<std::pair<uint64_t, std::vector<uint32_t>>>& entries);
969
972 default;
975
977 size_t size() const;
978
979 uint64_t fragment_id_at(size_t index) const;
980
981 size_t offset_count_at(size_t index) const;
982
984 std::vector<uint32_t> offsets_at(size_t index) const;
985
988
989 const LanceUpdatedFragmentOffsets* c_handle() const;
990};
991
1000
1001public:
1003
1005 KeyExistenceFilter& operator=(KeyExistenceFilter&&) noexcept = default;
1007 KeyExistenceFilter& operator=(const KeyExistenceFilter&) = delete;
1008
1010 static KeyExistenceFilter from_proto(const std::vector<uint8_t>& bytes);
1011
1013
1014 std::vector<int32_t> field_ids() const;
1015
1018 std::vector<uint64_t> exact_keys() const;
1019
1021 BloomFilterValues bloom() const;
1022
1025 std::vector<uint8_t> to_proto() const;
1026
1028 KeyExistenceFilter clone() const;
1029
1030 const LanceKeyExistenceFilter* c_handle() const;
1031};
1032
1039
1040public:
1042
1045 RewriteGroup(const std::vector<const Fragment*>& old_fragments,
1046 const std::vector<const Fragment*>& new_fragments);
1047
1048 RewriteGroup(RewriteGroup&&) noexcept = default;
1049 RewriteGroup& operator=(RewriteGroup&&) noexcept = default;
1050 RewriteGroup(const RewriteGroup&) = delete;
1051 RewriteGroup& operator=(const RewriteGroup&) = delete;
1052
1053 size_t old_fragment_count() const;
1054 Fragment old_fragment_at(size_t index) const;
1055 std::vector<Fragment> old_fragments() const;
1056 size_t new_fragment_count() const;
1057 Fragment new_fragment_at(size_t index) const;
1058 std::vector<Fragment> new_fragments() const;
1059
1061 RewriteGroup clone() const;
1062
1063 const LanceRewriteGroup* c_handle() const;
1064};
1065
1069
1070public:
1072
1076 RewrittenIndex(const std::array<uint8_t, 16>& old_id,
1077 const std::array<uint8_t, 16>& new_id,
1078 std::string_view details_type_url,
1079 const std::vector<uint8_t>& details_value,
1080 uint32_t index_version,
1081 std::optional<std::vector<IndexFile>> index_files);
1082
1083 RewrittenIndex(RewrittenIndex&&) noexcept = default;
1084 RewrittenIndex& operator=(RewrittenIndex&&) noexcept = default;
1086 RewrittenIndex& operator=(const RewrittenIndex&) = delete;
1087
1088 std::array<uint8_t, 16> old_id() const;
1089
1090 std::array<uint8_t, 16> new_id() const;
1091
1092 std::string details_type_url() const;
1093
1094 std::vector<uint8_t> details_value() const;
1095
1096 uint32_t version() const;
1097
1098 bool has_files() const;
1099
1102 std::vector<IndexFile> files() const;
1103
1105 RewrittenIndex clone() const;
1106
1107 const LanceRewrittenIndex* c_handle() const;
1108};
1109
1114
1115public:
1116 explicit Operation(LanceOperation* operation);
1117
1118 Operation(Operation&&) noexcept = default;
1119 Operation& operator=(Operation&&) noexcept = default;
1120 Operation(const Operation&) = delete;
1121 Operation& operator=(const Operation&) = delete;
1122
1123 OperationKind kind() const;
1124
1127 uint64_t fragment_count() const;
1128
1131 bool preserves_nullability() const;
1132
1134 uint64_t append_fragment_count() const;
1135
1137 Fragment append_fragment_at(size_t index) const;
1138
1140 uint64_t restore_version() const;
1141
1143 uint32_t reserve_fragments_count() const;
1144
1146 uint64_t update_bases_count() const;
1147
1150 LanceBasePathView update_bases_at(size_t index) const;
1151
1153 std::vector<BasePath> update_bases() const;
1154
1156 uint64_t overwrite_fragment_count() const;
1157
1159 Fragment overwrite_fragment_at(size_t index) const;
1160
1162 LanceSchema overwrite_schema() const;
1163
1166 bool has_config_upsert_values() const;
1167
1169 uint64_t config_upsert_count() const;
1170
1172 std::string config_upsert_key_at(size_t index) const;
1173
1175 std::string config_upsert_value_at(size_t index) const;
1176
1179 bool has_initial_bases() const;
1180
1182 uint64_t initial_base_count() const;
1183
1186 LanceBasePathView initial_base_at(size_t index) const;
1187
1189 std::vector<BasePath> initial_bases() const;
1190
1192 uint64_t merge_fragment_count() const;
1193
1195 Fragment merge_fragment_at(size_t index) const;
1196
1198 LanceSchema merge_schema() const;
1199
1201 bool merge_preserves_nullability() const;
1202
1204 LanceSchema project_schema() const;
1205
1207 bool clone_is_shallow() const;
1208
1210 std::optional<std::string> clone_ref_name() const;
1211
1213 uint64_t clone_ref_version() const;
1214
1216 std::string clone_ref_path() const;
1217
1219 std::optional<std::string> clone_branch_name() const;
1220
1222 std::optional<UpdateMap> config_updates() const;
1223
1225 std::optional<UpdateMap> table_metadata_updates() const;
1226
1228 std::optional<UpdateMap> schema_metadata_updates() const;
1229
1231 std::map<int32_t, UpdateMap> field_metadata_updates() const;
1232
1239 static Operation make_overwrite(
1240 const LanceSchema& schema,
1241 const std::vector<const Fragment*>& fragments,
1242 std::optional<std::vector<std::pair<std::string, std::string>>>
1243 config_upsert_values = std::nullopt,
1244 std::optional<std::vector<BasePath>> initial_bases = std::nullopt);
1245
1250 static Operation make_merge(
1251 const LanceSchema& schema,
1252 const std::vector<const Fragment*>& fragments,
1253 bool preserves_nullability = false);
1254
1259 static Operation make_clone(
1260 bool is_shallow,
1261 std::optional<std::string> ref_name,
1262 uint64_t ref_version,
1263 std::string ref_path,
1264 std::optional<std::string> branch_name);
1265
1268 static Operation make_update_config(const UpdateConfigOptions& options);
1269
1272 static Operation make_append(const std::vector<const Fragment*>& fragments);
1273
1275 static Operation make_restore(uint64_t version);
1276
1278 static Operation make_reserve_fragments(uint32_t num_fragments);
1279
1282 static Operation make_update_bases(const std::vector<BasePath>& new_bases);
1283
1287 static Operation make_delete(
1288 const std::vector<const Fragment*>& updated_fragments,
1289 const std::vector<uint64_t>& deleted_fragment_ids,
1290 const std::string& predicate);
1291
1295 static Operation make_create_index(
1296 const std::vector<const IndexSegmentMetadata*>& new_indices,
1297 const std::vector<const IndexSegmentMetadata*>& removed_indices);
1298
1302 static Operation make_data_replacement(
1303 const std::vector<const DataReplacementGroup*>& replacements);
1304
1308 static Operation make_data_overlay(
1309 const std::vector<const DataOverlayGroup*>& groups);
1310
1315 static Operation make_project(const LanceSchema& schema,
1316 bool preserves_nullability = false);
1317
1320 std::vector<IndexSegmentMetadata> create_index_new() const;
1321
1323 std::vector<IndexSegmentMetadata> create_index_removed() const;
1324
1326 uint64_t data_replacement_count() const;
1327
1329 DataReplacementGroup data_replacement_at(size_t index) const;
1330
1332 uint64_t data_overlay_group_count() const;
1333
1335 DataOverlayGroup data_overlay_group_at(size_t index) const;
1336
1338 uint64_t delete_updated_fragment_count() const;
1339
1341 std::string delete_updated_fragment_metadata_json(size_t index) const;
1342
1344 uint64_t delete_deleted_fragment_count() const;
1345
1347 uint64_t delete_deleted_fragment_id(size_t index) const;
1348
1350 std::string delete_predicate() const;
1351
1356 static Operation make_update(const UpdateOperationSpec& spec);
1357
1362 static Operation make_rewrite(
1363 const std::vector<const RewriteGroup*>& groups,
1364 const std::vector<const RewrittenIndex*>& rewritten_indices,
1365 const IndexSegmentMetadata* frag_reuse_index = nullptr);
1366
1370 static Operation make_update_mem_wal_state(
1371 const std::vector<CompactedSsTable>& compacted_sstables);
1372
1376 static Operation make_update_mem_wal_state_with_dir_id(
1377 const std::vector<CompactedSsTable>& compacted_sstables,
1378 const std::string& dir_id);
1379
1380 // Update inspection. Inspecting a different operation kind throws
1381 // LANCE_ERR_NOT_SUPPORTED; every getter below reports native fields
1382 // unchanged.
1383
1385 uint64_t removed_fragment_count() const;
1386
1388 uint64_t removed_fragment_id(size_t index) const;
1389
1391 uint64_t updated_fragment_count() const;
1392
1394 Fragment updated_fragment_at(size_t index) const;
1395
1397 uint64_t new_fragment_count() const;
1398
1400 Fragment new_fragment_at(size_t index) const;
1401
1403 uint64_t fields_modified_count() const;
1404
1406 uint32_t fields_modified(size_t index) const;
1407
1409 uint64_t compacted_sstable_count() const;
1410
1412 CompactedSsTable compacted_sstable_at(size_t index) const;
1413
1415 uint64_t fields_for_preserving_frag_bitmap_count() const;
1416
1418 uint32_t fields_for_preserving_frag_bitmap(size_t index) const;
1419
1421 std::optional<UpdateMode> update_mode() const;
1422
1424 std::optional<KeyExistenceFilter> inserted_rows_filter() const;
1425
1428 std::optional<UpdatedFragmentOffsets> updated_fragment_offsets() const;
1429
1432 std::optional<std::string> update_mem_wal_dir_id() const;
1433
1435 uint64_t rewrite_group_count() const;
1436
1438 RewriteGroup rewrite_group_at(size_t index) const;
1439
1441 uint64_t rewritten_index_count() const;
1442
1444 RewrittenIndex rewritten_index_at(size_t index) const;
1445
1447 std::optional<IndexSegmentMetadata> frag_reuse_index() const;
1448
1449 // UpdateMemWalState inspection. Inspecting a different operation kind
1450 // throws LANCE_ERR_NOT_SUPPORTED.
1451
1453 uint64_t update_mem_wal_state_compacted_sstable_count() const;
1454
1456 CompactedSsTable update_mem_wal_state_compacted_sstable_at(
1457 size_t index) const;
1458
1461 std::string update_mem_wal_state_dir_id() const;
1462
1463 const LanceOperation* c_handle() const;
1464};
1465
1473 std::optional<std::string> uuid;
1474 std::optional<std::string> tag;
1475 std::optional<std::vector<std::pair<std::string, std::string>>>
1477};
1478
1483
1484public:
1485 explicit Transaction(LanceTransaction* transaction);
1486
1487 Transaction(Transaction&&) noexcept = default;
1488 Transaction& operator=(Transaction&&) noexcept = default;
1489 Transaction(const Transaction&) = delete;
1490 Transaction& operator=(const Transaction&) = delete;
1491
1492 uint64_t read_version() const;
1493
1494 std::string uuid() const;
1495
1496 std::optional<std::string> tag() const;
1497
1498 bool has_properties() const;
1499
1500 std::map<std::string, std::string> properties() const;
1501
1502 Operation operation() const;
1503
1505 static Transaction from_operation(
1506 uint64_t read_version,
1507 const Operation& operation,
1508 const TransactionOptions& options = {});
1509
1511 std::vector<uint8_t> to_proto() const;
1512
1514 static Transaction from_proto(const std::vector<uint8_t>& bytes);
1515
1517};
1518
1521using ConfigUpdate = std::pair<std::string, std::optional<std::string>>;
1522
1528 std::optional<std::vector<std::pair<std::string, std::string>>>
1530};
1531
1536using TrackedFilesProgressCallback = std::function<void(
1537 uint64_t manifests_processed,
1538 std::optional<uint64_t> manifests_total)>;
1539
1540// ─── Column alteration ───────────────────────────────────────────────────────
1541
1549 std::string path;
1550 std::optional<std::string> rename;
1552 const ArrowSchema* data_type = nullptr;
1553};
1554
1555// ─── New column (SQL) ────────────────────────────────────────────────────────
1556
1561 std::string name;
1562 std::string expression;
1563};
1564
1565// ─── Schema-evolution callbacks ─────────────────────────────────────────────
1566
1570 uint32_t fragment_id = 0;
1571 std::size_t batch_index = 0;
1572};
1573
1577using BatchUDFMapper = std::function<void(
1578 const ArrowArray& input,
1579 const ArrowSchema& input_schema,
1580 ArrowArray& output)>;
1581
1592 std::function<bool(
1593 const BatchUDFInfo&,
1595
1596 std::function<void(
1597 const BatchUDFInfo&,
1598 ArrowArray&,
1600
1601 std::function<std::optional<std::string>(uint32_t)> get_fragment;
1602
1603 std::function<void(uint64_t, const std::string&)> insert_fragment;
1604};
1605
1608struct BatchUDF {
1610 const ArrowSchema* output_schema = nullptr;
1611 std::optional<UDFCheckpointStore> checkpoint_store;
1612};
1613
1618using BatchUDFGetBatchV2 = std::function<bool(
1619 const BatchUDFInfo&,
1620 ArrowArray&,
1621 ArrowSchema&)>;
1622
1628
1629 std::function<void(
1630 const BatchUDFInfo&,
1631 ArrowArray&,
1633
1634 std::function<std::optional<std::string>(uint32_t)> get_fragment;
1635
1636 std::function<void(uint64_t, const std::string&)> insert_fragment;
1637};
1638
1642 const ArrowSchema* output_schema = nullptr;
1643 std::optional<UDFCheckpointStoreV2> checkpoint_store;
1644};
1645
1646namespace callback_detail {
1647
1649
1651 LanceCallbackError* target,
1652 int32_t code,
1653 const char* message) noexcept;
1654
1656
1658
1661};
1662
1665};
1666
1670
1674
1675template <typename Context>
1676inline int32_t mapper_trampoline(
1677 void* callback_ctx,
1678 const ArrowArray* input,
1679 const ArrowSchema* input_schema,
1680 ArrowArray* output,
1681 LanceCallbackError* error) noexcept {
1682 try {
1683 auto* context = static_cast<Context*>(callback_ctx);
1684 context->udf->mapper(*input, *input_schema, *output);
1685 return 0;
1686 } catch (const lance::Error& exception) {
1688 set_callback_error(error, static_cast<int32_t>(exception.code), exception.what());
1689 return -1;
1690 } catch (const std::exception& exception) {
1692 set_callback_error(error, LANCE_ERR_INTERNAL, exception.what());
1693 return -1;
1694 } catch (...) {
1696 set_callback_error(error, LANCE_ERR_INTERNAL, "unknown C++ exception");
1697 return -1;
1698 }
1699}
1700
1702 void* callback_ctx,
1703 const LanceUDFBatchInfo* raw_info,
1704 ArrowArray* output,
1705 LanceCallbackError* error) noexcept;
1706
1708 void* callback_ctx,
1709 const LanceUDFBatchInfo* raw_info,
1710 ArrowArray* output,
1711 ArrowSchema* output_schema,
1712 LanceCallbackError* error) noexcept;
1713
1714template <typename Context>
1716 void* callback_ctx,
1717 const LanceUDFBatchInfo* raw_info,
1718 ArrowArray* batch,
1719 ArrowSchema* batch_schema,
1720 LanceCallbackError* error) noexcept {
1721 try {
1722 auto* context = static_cast<Context*>(callback_ctx);
1723 BatchUDFInfo info{raw_info->fragment_id, raw_info->batch_index};
1724 context->store->insert_batch(info, *batch, *batch_schema);
1725 return 0;
1726 } catch (const lance::Error& exception) {
1727 set_callback_error(error, static_cast<int32_t>(exception.code), exception.what());
1728 return -1;
1729 } catch (const std::exception& exception) {
1730 set_callback_error(error, LANCE_ERR_INTERNAL, exception.what());
1731 return -1;
1732 } catch (...) {
1733 set_callback_error(error, LANCE_ERR_INTERNAL, "unknown C++ exception");
1734 return -1;
1735 }
1736}
1737
1738template <typename Context>
1740 void* callback_ctx,
1741 uint32_t fragment_id,
1742 LanceOwnedString* out_json,
1743 LanceCallbackError* error) noexcept {
1744 try {
1745 auto* context = static_cast<Context*>(callback_ctx);
1746 auto json = context->store->get_fragment(fragment_id);
1747 if (!json) return 0;
1748
1749 char* copy = static_cast<char*>(std::malloc(json->size() + 1));
1750 if (copy == nullptr) {
1752 error, LANCE_ERR_INTERNAL, "failed to allocate callback JSON");
1753 return -1;
1754 }
1755 std::memcpy(copy, json->data(), json->size());
1756 copy[json->size()] = '\0';
1757 out_json->data = copy;
1758 out_json->release = &release_owned_string;
1759 return 1;
1760 } catch (const lance::Error& exception) {
1761 set_callback_error(error, static_cast<int32_t>(exception.code), exception.what());
1762 return -1;
1763 } catch (const std::exception& exception) {
1764 set_callback_error(error, LANCE_ERR_INTERNAL, exception.what());
1765 return -1;
1766 } catch (...) {
1767 set_callback_error(error, LANCE_ERR_INTERNAL, "unknown C++ exception");
1768 return -1;
1769 }
1770}
1771
1772template <typename Context>
1774 void* callback_ctx,
1775 uint64_t fragment_id,
1776 const char* fragment_json,
1777 LanceCallbackError* error) noexcept {
1778 try {
1779 auto* context = static_cast<Context*>(callback_ctx);
1780 context->store->insert_fragment(
1781 fragment_id, std::string(fragment_json == nullptr ? "" : fragment_json));
1782 return 0;
1783 } catch (const lance::Error& exception) {
1784 set_callback_error(error, static_cast<int32_t>(exception.code), exception.what());
1785 return -1;
1786 } catch (const std::exception& exception) {
1787 set_callback_error(error, LANCE_ERR_INTERNAL, exception.what());
1788 return -1;
1789 } catch (...) {
1790 set_callback_error(error, LANCE_ERR_INTERNAL, "unknown C++ exception");
1791 return -1;
1792 }
1793}
1794
1801 std::optional<std::vector<std::string>> read_columns;
1802 std::vector<const char*> read_column_ptrs;
1803 uint32_t batch_size_value = 0;
1804 const char* const* read_columns_ptr = nullptr;
1805 const uint32_t* batch_size_ptr = nullptr;
1806 MapperContext mapper_context{};
1807 CheckpointContext checkpoint_context{};
1810 MapperContextV2 mapper_context_v2{};
1811 CheckpointContextV2 checkpoint_context_v2{};
1814
1816 std::optional<std::vector<std::string>> columns,
1817 std::optional<uint32_t> batch_size);
1818
1820 std::optional<std::vector<std::string>> columns,
1821 std::optional<uint32_t> batch_size);
1822
1823 BatchUDFCall(const BatchUDFCall&) = delete;
1827
1828private:
1829 void prepare_arguments(std::optional<uint32_t> batch_size);
1830};
1831
1832} // namespace callback_detail
1833
1834// ─── Commit lock ─────────────────────────────────────────────────────────────
1835
1844public:
1845 virtual ~CommitLease() noexcept = default;
1846 virtual void release(bool success) = 0;
1847};
1848
1849namespace commit_lock_detail {
1850struct State;
1851} // namespace commit_lock_detail
1852
1855 std::unique_ptr<commit_lock_detail::State> state_;
1856
1857public:
1860 using Acquire = std::function<std::unique_ptr<CommitLease>(uint64_t)>;
1861
1862 explicit CommitLock(Acquire acquire);
1864
1866 CommitLock& operator=(CommitLock&&) noexcept;
1867 CommitLock(const CommitLock&) = delete;
1868 CommitLock& operator=(const CommitLock&) = delete;
1869
1870 const LanceCommitLock* c_handle() const;
1871};
1872
1873namespace commit_lock_detail {
1874
1878
1880 std::unique_ptr<CommitLease> lease;
1881};
1882
1883extern "C" int32_t acquire_trampoline(
1884 void* callback_ctx,
1885 uint64_t version,
1886 void** out_lease,
1887 LanceCallbackError* error) noexcept;
1888
1889extern "C" int32_t release_trampoline(
1890 void*,
1891 void* lease,
1892 bool success,
1893 LanceCallbackError* error) noexcept;
1894
1895extern "C" void destroy_lease_trampoline(void*, void* lease) noexcept;
1896
1897extern "C" void release_context_trampoline(void* callback_ctx) noexcept;
1898
1899} // namespace commit_lock_detail
1900
1901
1902
1903inline CommitLock::~CommitLock() = default;
1904
1905inline CommitLock::CommitLock(CommitLock&&) noexcept = default;
1906
1907inline CommitLock& CommitLock::operator=(CommitLock&&) noexcept = default;
1908
1909// ─── Storage options ─────────────────────────────────────────────────────────
1910
1911using StorageOptions = std::map<std::string, std::string>;
1912
1915
1917
1918public:
1919 using Fetch = std::function<std::optional<StorageOptions>()>;
1920
1922 std::string provider_id,
1923 Fetch fetch,
1924 Fetch force_fetch = {});
1925
1930 const Namespace& ns,
1931 const std::vector<std::string>& table_id);
1932
1934
1935 std::string provider_id() const;
1936};
1937
1938namespace storage_options_detail {
1939
1941 std::vector<std::string> strings;
1942 std::vector<const char*> keys;
1943 std::vector<const char*> values;
1944};
1945
1946void release_fetch_snapshot(void* raw) noexcept;
1947
1949 const StorageOptionsProvider::Fetch& fetch,
1951 LanceCallbackError* error,
1952 const char* context) noexcept;
1953
1958
1960 void* callback_ctx,
1962 LanceCallbackError* error) noexcept;
1963
1965 void* callback_ctx,
1967 LanceCallbackError* error) noexcept;
1968
1969void provider_release(void* callback_ctx) noexcept;
1970
1972 const std::string& provider_id,
1974 StorageOptionsProvider::Fetch force_fetch);
1975
1976} // namespace storage_options_detail
1977
1978
1979
1982
1983public:
1986 std::optional<StorageOptions> initial = std::nullopt,
1987 const StorageOptionsProvider* provider = nullptr);
1988
1990 std::optional<StorageOptions> snapshot() const;
1991
1993};
1994
2002 uint64_t version = 0;
2003 const StorageOptionsAccessor* storage_options_accessor = nullptr;
2014 std::optional<std::vector<DatasetBaseStoreParams>> base_store_params;
2015};
2016
2017// ─── Shared Session ──────────────────────────────────────────────────────────
2018
2025
2029 SessionCacheSpecKind kind = SessionCacheSpecKind::Default;
2030 uint64_t size_bytes = 0;
2031 std::string backend_uri;
2032 std::string backend_kind;
2033 std::vector<std::pair<std::string, std::string>> backend_options;
2034
2036
2037 static SessionCacheSpec with_size(uint64_t capacity_bytes);
2038
2039 static SessionCacheSpec from_uri(std::string uri);
2040
2042 std::string backend_kind,
2043 std::vector<std::pair<std::string, std::string>> backend_options = {});
2044};
2045
2046class Session {
2048
2049 static LanceSessionCacheSpec c_cache_spec(
2050 const SessionCacheSpec& spec,
2051 std::vector<const char*>& option_keys,
2052 std::vector<const char*>& option_values);
2053
2054 static LanceSession* create(
2055 const SessionCacheSpec& index_cache,
2056 const SessionCacheSpec& metadata_cache);
2057
2058public:
2062 const SessionCacheSpec& index_cache,
2063 const SessionCacheSpec& metadata_cache);
2064
2065 Session(uint64_t index_cache_size_bytes, uint64_t metadata_cache_size_bytes);
2066
2068
2070 uint64_t size_bytes() const;
2071
2073 uint64_t approx_num_items() const;
2074
2075 const LanceSession* c_handle() const;
2076};
2077
2078// ─── Owned native dataset-write options ─────────────────────────────────────
2079
2080namespace native_write_options_detail {
2081
2085
2089 LanceCallbackError* error,
2090 const char* context) noexcept;
2091
2092extern "C" int32_t begin_fragment_trampoline(
2093 void* callback_ctx,
2095 LanceCallbackError* error) noexcept;
2096
2098 void* callback_ctx,
2100 LanceCallbackError* error) noexcept;
2101
2103 void* callback_ctx,
2104 const LanceWriteStats* stats) noexcept;
2105
2106extern "C" void release_progress_context(void* callback_ctx) noexcept;
2107
2111 std::vector<std::string> paths;
2112 std::vector<LanceBaseStoreParams> views;
2114};
2115
2122 const std::optional<std::vector<DatasetBaseStoreParams>>& base_store_params,
2123 BaseStoreParamsHolder& holder);
2124
2128
2129 bool has_transaction_properties = false;
2130 std::vector<const char*> property_keys;
2131 std::vector<const char*> property_values;
2133
2134 std::vector<std::string> base_paths;
2135 std::vector<std::optional<std::string>> base_names;
2136 std::vector<LanceBasePath> base_views;
2137 LanceBasePath empty_base{};
2139
2140 std::vector<uint32_t> target_ids;
2141 LanceUInt32List target_list{};
2142
2143 std::vector<std::string> target_names;
2144 std::vector<const char*> target_name_ptrs;
2145 LanceStringList target_name_list{};
2146
2148
2150
2151 std::unique_ptr<ProgressContext> progress_ctx;
2153};
2154
2156 const std::optional<std::vector<BasePath>>& initial_bases,
2157 BuildState& state);
2158
2159} // namespace native_write_options_detail
2160
2161
2162
2163// ─── Process-local FTS query context ────────────────────────────────────────
2164
2169
2170public:
2172
2173 FtsQueryContext(FtsQueryContext&&) noexcept = default;
2174 FtsQueryContext& operator=(FtsQueryContext&&) noexcept = default;
2176 FtsQueryContext& operator=(const FtsQueryContext&) = delete;
2177
2178 const LanceFtsQueryContext* c_handle() const;
2179};
2180
2181// ─── Typed full-text query ───────────────────────────────────────────────────
2182
2188
2189 explicit FtsQuery(LanceFtsQuery* query);
2190
2191 static void copy_boosts(
2192 const std::optional<std::vector<float>>& boosts,
2193 float& empty_boost,
2194 const float*& data,
2195 size_t& count);
2196
2197public:
2198 FtsQuery(FtsQuery&&) noexcept = default;
2199 FtsQuery& operator=(FtsQuery&&) noexcept = default;
2200 FtsQuery(const FtsQuery&) = delete;
2201 FtsQuery& operator=(const FtsQuery&) = delete;
2202
2205 static FtsQuery match(
2206 const std::string& terms,
2207 std::optional<std::string> column = std::nullopt,
2208 const FtsMatchOptions& options = {});
2209
2213 const std::string& terms,
2214 std::optional<std::string> column = std::nullopt,
2215 const FtsPhraseOptions& options = {});
2216
2220 const std::vector<std::pair<FtsOccur, const FtsQuery*>>& clauses);
2221
2225 const FtsQuery& positive,
2226 const FtsQuery& negative,
2227 const FtsBoostOptions& options = {});
2228
2232 const std::string& terms,
2233 const std::vector<std::string>& columns,
2234 const FtsMultiMatchOptions& options = {});
2235
2239 const std::string& terms,
2240 const std::vector<std::string>& columns,
2241 const FtsCombinedFieldsOptions& options = {});
2242
2243 const LanceFtsQuery* c_handle() const;
2244};
2245
2246// ─── Native tokenization and process diagnostics ────────────────────────────
2247
2249struct FtsToken {
2250 std::string text;
2251 uint32_t position = 0;
2252};
2253
2260
2261 explicit FtsTokenList(LanceFtsTokenList* tokens);
2262
2263public:
2264 FtsTokenList(FtsTokenList&&) noexcept = default;
2265 FtsTokenList& operator=(FtsTokenList&&) noexcept = default;
2266 FtsTokenList(const FtsTokenList&) = delete;
2267 FtsTokenList& operator=(const FtsTokenList&) = delete;
2268
2272 static FtsTokenList tokenize(
2273 std::string_view text,
2274 std::optional<std::string> params_json = std::nullopt);
2275
2277 size_t size() const;
2278
2279 bool empty() const;
2280
2282 FtsToken at(size_t index) const;
2283
2285 std::vector<FtsToken> tokens() const;
2286
2287 const LanceFtsTokenList* c_handle() const;
2288};
2289
2291uint64_t process_iops_counter();
2292
2295uint64_t process_bytes_read_counter();
2296
2299 uint64_t iops = 0;
2300 uint64_t bytes_read = 0;
2301};
2302
2304
2307std::string simd_info_json();
2308
2309// ─── Blob file ───────────────────────────────────────────────────────────────
2310
2313 uint64_t offset;
2314 uint64_t length;
2315};
2316
2323 std::optional<size_t> inline_size_threshold;
2324 std::optional<size_t> dedicated_size_threshold;
2325};
2326
2332 const std::string& name,
2333 bool nullable,
2334 ArrowSchema* out);
2335
2341 const std::string& name,
2342 bool nullable,
2343 const BlobFieldOptions& options,
2344 ArrowSchema* out);
2345
2355 handle_;
2356
2357public:
2358 explicit BlobDescriptorArrayBuilder(const std::string& column);
2359
2360 void append_inline(const uint8_t* data, size_t len);
2361
2362 void append_inline(const std::vector<uint8_t>& data);
2363
2365
2366 void append_packed(uint32_t blob_id, uint64_t offset, uint64_t length);
2367
2368 void append_packed(uint32_t blob_id, const BlobRange& range);
2369
2370 void extend_packed(uint32_t blob_id,
2371 const std::vector<BlobRange>& ranges);
2372
2373 void append_dedicated(uint32_t blob_id, uint64_t length);
2374
2376 const std::string& uri,
2377 uint64_t offset,
2378 uint64_t length,
2379 std::optional<uint32_t> base_id = std::nullopt);
2380
2381 void append_external(uint32_t base_id,
2382 const std::string& uri,
2383 uint64_t offset,
2384 uint64_t length);
2385
2386 void push_external(const std::string& uri,
2387 std::optional<BlobRange> range = std::nullopt);
2388
2390 void field(ArrowSchema* out) const;
2391
2394 void finish(ArrowArray* out_array, ArrowSchema* out_schema);
2395};
2396
2404
2405public:
2407
2408 PackedBlobWriter(PackedBlobWriter&&) noexcept = default;
2409 PackedBlobWriter& operator=(PackedBlobWriter&&) noexcept = default;
2411 PackedBlobWriter& operator=(const PackedBlobWriter&) = delete;
2412
2414 uint32_t blob_id() const;
2415
2417 std::string path() const;
2418
2420 void write_blob(const uint8_t* data, size_t len);
2421
2422 void write_blob(const std::vector<uint8_t>& data);
2423
2425 void write_blobs(ArrowArray* payloads, const ArrowSchema* schema);
2426
2428 void finish_array(
2429 const std::string& field_name,
2430 ArrowArray* out_array,
2431 ArrowSchema* out_schema);
2432};
2433
2440
2441public:
2443
2445 DedicatedBlobWriter& operator=(DedicatedBlobWriter&&) noexcept = default;
2447 DedicatedBlobWriter& operator=(const DedicatedBlobWriter&) = delete;
2448
2450 uint32_t blob_id() const;
2451
2453 std::string path() const;
2454
2456 void write(const uint8_t* data, size_t len);
2457
2458 void write(const std::vector<uint8_t>& data);
2459
2461 void finish_array(
2462 const std::string& field_name,
2463 ArrowArray* out_array,
2464 ArrowSchema* out_schema);
2465};
2466
2474
2480 std::optional<uint64_t> io_buffer_size;
2481 bool preserve_order = true;
2482};
2483
2486 uint64_t row = 0;
2487 uint64_t offset = 0;
2488 uint64_t length = 0;
2489};
2490
2499
2500public:
2502 explicit BlobFile(LanceBlobFile* blob);
2503
2505 uint64_t size() const;
2506
2508 std::vector<uint8_t> read();
2509
2512 std::vector<uint8_t> read_up_to(size_t len);
2513
2517 size_t read_into(uint8_t* dst, size_t len);
2518
2521 std::vector<uint8_t> read_range(uint64_t offset, size_t len) const;
2522
2526 std::vector<std::vector<uint8_t>> read_ranges(
2527 const std::vector<BlobRange>& ranges) const;
2528
2530 void set_buffer_size(size_t buffer_size);
2531
2534 void seek(uint64_t pos);
2535
2537 uint64_t tell() const;
2538
2541 void close();
2542
2544 bool closed() const;
2545};
2546
2547// ─── Fragment handles ────────────────────────────────────────────────────────
2548
2556
2557public:
2559 explicit Fragment(LanceFragment* fragment);
2560
2561 Fragment(Fragment&&) noexcept = default;
2562 Fragment& operator=(Fragment&&) noexcept = default;
2563 Fragment(const Fragment&) = delete;
2564 Fragment& operator=(const Fragment&) = delete;
2565
2573 static Fragment from_data_files(
2574 uint64_t fragment_id,
2575 const std::vector<const DataFile*>& data_files,
2576 std::optional<uint64_t> physical_rows = std::nullopt);
2577
2579 uint64_t id() const;
2580
2582 uint64_t data_file_count() const;
2583
2585 bool is_bound() const;
2586
2588 DataFile data_file_at(size_t index) const;
2589
2592 std::optional<DataFile> data_file_for_field(int32_t field_id) const;
2593
2597 std::string metadata_json() const;
2598
2601 void schema(ArrowSchema* out) const;
2602
2604 LanceSchema native_schema() const;
2605
2607 uint64_t physical_rows() const;
2608
2610 uint64_t deleted_rows() const;
2611
2613 uint64_t logical_rows() const;
2614
2616 uint64_t read_version() const;
2617
2619 Scanner scan() const;
2620
2626 void take(const uint32_t* indices, size_t num_indices,
2627 const std::vector<std::string>& columns,
2628 ArrowArrayStream* out) const;
2629
2631 void take(const uint32_t* indices, size_t num_indices,
2632 ArrowArrayStream* out) const;
2633
2641 ArrowStream take(const uint32_t* indices, size_t num_indices,
2642 const std::vector<std::string>& columns) const;
2643
2646 ArrowStream take(const uint32_t* indices, size_t num_indices) const;
2647
2651 ArrowStream take(std::span<const uint32_t> indices,
2652 const std::vector<std::string>& columns) const;
2653
2656 ArrowStream take(std::span<const uint32_t> indices) const;
2657
2660 uint64_t count_rows(std::optional<std::string> filter = std::nullopt) const;
2661
2667 std::optional<Fragment> delete_if(const std::string& predicate) const;
2668
2674 std::pair<Fragment, LanceSchema> add_columns_sql(
2675 const std::vector<SqlColumn>& columns,
2676 std::optional<uint32_t> batch_size = std::nullopt) const;
2677
2679 std::pair<Fragment, LanceSchema> add_columns_nulls(
2680 const ArrowSchema* columns) const;
2681
2683 std::pair<Fragment, LanceSchema> add_columns_reader(
2684 ArrowArrayStream* stream,
2685 std::optional<uint32_t> batch_size = std::nullopt) const;
2686
2688 std::pair<Fragment, LanceSchema> add_columns_batch_udf(
2689 const BatchUDF& udf,
2690 std::optional<std::vector<std::string>> read_columns = std::nullopt,
2691 std::optional<uint32_t> batch_size = std::nullopt) const;
2692
2694 std::pair<Fragment, LanceSchema> add_columns_batch_udf(
2695 const BatchUDFV2& udf,
2696 std::optional<std::vector<std::string>> read_columns = std::nullopt,
2697 std::optional<uint32_t> batch_size = std::nullopt) const;
2698
2700 std::pair<Fragment, LanceSchema> merge_columns(
2701 ArrowArrayStream* stream,
2702 const std::string& left_on,
2703 const std::string& right_on) const;
2704
2708 ArrowArrayStream* stream,
2709 const std::string& left_on,
2710 const std::string& right_on) const;
2711
2714 const LanceSchema& schema,
2715 ArrowArrayStream* stream) const;
2716
2718 DataReplacementGroup write_column_with_version(
2719 const LanceSchema& schema,
2720 ArrowArrayStream* stream,
2721 LanceFileFormatVersion file_version) const;
2722
2725 std::optional<Fragment> delete_rows(
2726 const std::vector<uint32_t>& offsets) const;
2727
2734 FragmentOverlayWriter write_overlay(const LanceSchema& schema) const;
2735
2748 static Fragment create(
2749 const std::string& dataset_uri,
2750 ArrowArrayStream* stream,
2751 uint64_t fragment_id,
2752 const FragmentCreateOptions& options = {},
2753 const std::vector<std::pair<std::string, std::string>>& storage_opts = {},
2754 const Session* session = nullptr);
2755
2762 static std::vector<Fragment> create_many(
2763 const std::string& dataset_uri,
2764 ArrowArrayStream* stream,
2765 const FragmentCreateOptions& options = {},
2766 const std::vector<std::pair<std::string, std::string>>& storage_opts = {},
2767 const Session* session = nullptr);
2768
2780 const Dataset& dataset,
2781 const std::string& filename,
2782 uint64_t fragment_id,
2783 std::optional<uint64_t> physical_rows = std::nullopt);
2784
2785 const LanceFragment* c_handle() const;
2786};
2787
2788
2789
2790
2791
2796 handle_;
2797
2798public:
2800
2803 FragmentUpdateColumnsResult&&) noexcept = default;
2806 const FragmentUpdateColumnsResult&) = delete;
2807
2809 Fragment fragment() const;
2810
2812 std::vector<uint32_t> fields_modified() const;
2813
2815 std::vector<uint32_t> matched_offsets() const;
2816
2819 std::vector<uint8_t> matched_offsets_serialized() const;
2820
2821 const LanceFragmentUpdateColumnsResult* c_handle() const;
2822};
2823
2832
2833public:
2834 explicit LanceSchema(::LanceSchema* schema);
2835
2836 LanceSchema(LanceSchema&&) noexcept = default;
2837 LanceSchema& operator=(LanceSchema&&) noexcept = default;
2838 LanceSchema(const LanceSchema&) = delete;
2839 LanceSchema& operator=(const LanceSchema&) = delete;
2840
2842 LanceSchema clone() const;
2843
2845 static LanceSchema from_dataset(const Dataset& dataset);
2846
2848 static LanceSchema from_fragment(const Fragment& fragment);
2849
2852 static LanceSchema from_operation(const Operation& operation);
2853
2856 static LanceSchema project(const LanceSchema& schema,
2857 const std::vector<std::string>& columns);
2858
2861 int32_t field_id(const std::string& column) const;
2862
2867 static LanceSchema from_arrow(const ArrowSchema* schema);
2868
2871 void to_arrow(ArrowSchema* out) const;
2872
2873 const ::LanceSchema* c_handle() const;
2874};
2875
2876
2877
2878namespace fragment_mutation_detail {
2879
2880std::pair<Fragment, LanceSchema> take_fragment_schema_pair(
2881 ::LanceFragment* fragment, ::LanceSchema* schema);
2882
2885
2886} // namespace fragment_mutation_detail
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2955
2956 std::optional<uint64_t> num_partitions;
2957 std::optional<uint64_t> target_partition_size;
2958 std::optional<uint64_t> max_iters;
2959 std::optional<uint64_t> sample_rate;
2960 std::optional<uint64_t> streaming_sample_rate;
2961 std::optional<uint64_t> streaming_coreset_rate;
2962 uint64_t streaming_refine_passes = 0;
2963
2964 std::optional<std::string> precomputed_partitions_file;
2965 std::optional<std::pair<std::string, std::vector<std::string>>>
2967 std::optional<uint64_t> shuffle_partition_batches;
2968 std::optional<uint64_t> shuffle_partition_concurrency;
2969 std::optional<std::map<std::string, std::string>> storage_options;
2970
2971 std::optional<uint64_t> num_sub_vectors;
2972 std::optional<uint64_t> num_bits;
2973 IndexModel* ivf_centroids = nullptr;
2974 IndexModel* pq_codebook = nullptr;
2975 std::optional<std::string> rabitq_model_json;
2976
2977 std::optional<uint64_t> hnsw_max_level;
2978 std::optional<uint64_t> hnsw_m;
2979 std::optional<uint64_t> hnsw_ef_construction;
2980
2982 bool skip_transpose = false;
2983 std::map<std::string, std::string> runtime_hints;
2984 std::optional<bool> train;
2985
2988 VectorIndexOptions& accelerator(std::string device);
2989};
2990
2991// ─── Native maintenance options and plans ───────────────────────────────────
2992
2996
2997public:
2999
3001
3003 CompactionOptions& operator=(CompactionOptions&&) noexcept = default;
3005 CompactionOptions& operator=(const CompactionOptions&) = delete;
3006
3008 static CompactionOptions from_dataset(const Dataset& dataset);
3009
3010 CompactionOptions clone() const;
3011
3012 CompactionOptions& set_target_rows_per_fragment(uint64_t value);
3013
3014 CompactionOptions& set_max_rows_per_group(uint64_t value);
3015
3016 CompactionOptions& set_max_bytes_per_file(std::optional<uint64_t> value);
3017
3018 CompactionOptions& set_materialize_deletions(bool value);
3019
3020 CompactionOptions& set_materialize_deletions_threshold(float value);
3021
3024 CompactionOptions& set_num_threads(std::optional<uint64_t> value);
3025
3026 CompactionOptions& set_batch_size(std::optional<uint64_t> value);
3027
3028 CompactionOptions& set_io_buffer_size(std::optional<uint64_t> value);
3029
3030 CompactionOptions& set_defer_index_remap(bool value);
3031
3032 CompactionOptions& set_index_remap_mode(LanceIndexRemapMode value);
3033
3034 CompactionOptions& set_compaction_mode(
3035 std::optional<LanceCompactionMode> value);
3036
3037 CompactionOptions& set_binary_copy_read_batch_bytes(
3038 std::optional<uint64_t> value);
3039
3040 CompactionOptions& set_max_source_fragments(
3041 std::optional<uint64_t> value);
3042
3043 CompactionOptions& set_max_source_rows(std::optional<uint64_t> value);
3044
3045 CompactionOptions& set_max_source_bytes(std::optional<uint64_t> value);
3046
3047 CompactionOptions& set_excluded_fragment_ids(
3048 const std::vector<uint32_t>& fragment_ids);
3049
3050 CompactionOptions& set_max_overlays_per_fragment(
3051 std::optional<uint64_t> value);
3052
3053 CompactionOptions& set_data_storage_version(
3054 std::optional<std::string> selector);
3055
3056 CompactionOptions& set_transaction_properties(
3057 std::optional<std::vector<std::pair<std::string, std::string>>> value =
3058 std::nullopt);
3059
3060 const LanceCompactionOptionsV2* c_handle() const;
3061};
3062
3066
3067public:
3069
3070 RewriteResult(RewriteResult&&) noexcept = default;
3071 RewriteResult& operator=(RewriteResult&&) noexcept = default;
3073 RewriteResult& operator=(const RewriteResult&) = delete;
3074
3075 uint64_t read_version() const;
3076
3077 LanceCompactionMetrics metrics() const;
3078
3079 size_t original_fragment_count() const;
3080
3081 size_t new_fragment_count() const;
3082
3083 std::string original_fragment_metadata_json(size_t index) const;
3084
3085 std::string new_fragment_metadata_json(size_t index) const;
3086
3089 Fragment original_fragment_at(size_t index) const;
3090
3093 Fragment new_fragment_at(size_t index) const;
3094
3095 std::string json() const;
3096
3097 static RewriteResult from_json(std::string_view json);
3098
3099 const LanceRewriteResult* c_handle() const;
3100};
3101
3105
3106public:
3108
3109 CompactionTask(CompactionTask&&) noexcept = default;
3110 CompactionTask& operator=(CompactionTask&&) noexcept = default;
3112 CompactionTask& operator=(const CompactionTask&) = delete;
3113
3114 uint64_t read_version() const;
3115
3116 size_t fragment_count() const;
3117
3118 std::string fragment_metadata_json(size_t index) const;
3119
3120 std::vector<std::string> fragment_metadata_json() const;
3121
3122 CompactionOptions options() const;
3123
3124 RewriteResult execute(const Dataset& dataset) const;
3125
3126 std::string json() const;
3127
3128 static CompactionTask from_json(std::string_view json);
3129
3130 const LanceCompactionTask* c_handle() const;
3131};
3132
3136
3137public:
3139
3140 CompactionPlan(CompactionPlan&&) noexcept = default;
3141 CompactionPlan& operator=(CompactionPlan&&) noexcept = default;
3143 CompactionPlan& operator=(const CompactionPlan&) = delete;
3144
3145 uint64_t read_version() const;
3146
3147 size_t num_tasks() const;
3148
3149 CompactionTask task(size_t index) const;
3150
3151 CompactionOptions options() const;
3152
3153 std::string json() const;
3154
3155 static CompactionPlan from_json(std::string_view json);
3156
3157 const LanceCompactionPlan* c_handle() const;
3158};
3159
3163 handle_;
3164
3165public:
3167
3169
3172 default;
3175
3177
3178 OptimizeIndicesOptions& set_num_indices_to_merge(
3179 std::optional<uint64_t> value);
3180
3181 OptimizeIndicesOptions& set_enable_partition_rebalancing(bool value);
3182
3183 OptimizeIndicesOptions& set_index_names(
3184 std::optional<std::vector<std::string>> names);
3185
3186 OptimizeIndicesOptions& set_retrain(bool value);
3187
3188 OptimizeIndicesOptions& set_transaction_properties(
3189 std::optional<std::vector<std::pair<std::string, std::string>>> value =
3190 std::nullopt);
3191
3192 OptimizeIndicesOptions& set_max_rows_per_task(
3193 std::optional<uint64_t> value);
3194
3195 OptimizeIndicesOptions& set_max_rows_per_segment(
3196 std::optional<uint64_t> value);
3197
3198 const LanceOptimizeIndicesOptions* c_handle() const;
3199};
3200
3204
3205public:
3207
3209 IndexSegmentResult& operator=(IndexSegmentResult&&) noexcept = default;
3211 IndexSegmentResult& operator=(const IndexSegmentResult&) = delete;
3212
3213 std::array<uint8_t, 16> plan_id() const;
3214
3215 uint64_t read_version() const;
3216
3217 uint32_t group() const;
3218
3219 IndexSegmentMetadata segment() const;
3220
3221 size_t replace_count() const;
3222
3223 std::array<uint8_t, 16> replace_uuid(size_t index) const;
3224
3225 std::string json() const;
3226
3227 static IndexSegmentResult from_json(std::string_view json);
3228
3229 const LanceIndexSegmentResult* c_handle() const;
3230};
3231
3235
3236public:
3238
3240 OptimizeIndexTask& operator=(OptimizeIndexTask&&) noexcept = default;
3242 OptimizeIndexTask& operator=(const OptimizeIndexTask&) = delete;
3243
3244 std::array<uint8_t, 16> plan_id() const;
3245
3246 uint64_t read_version() const;
3247
3248 uint32_t group() const;
3249
3250 size_t fragment_count() const;
3251
3252 uint32_t fragment_id(size_t index) const;
3253
3254 std::vector<uint32_t> fragment_ids() const;
3255
3256 IndexSegmentMetadata reference() const;
3257
3258 size_t old_segment_count() const;
3259
3260 IndexSegmentMetadata old_segment(size_t index) const;
3261
3262 std::optional<uint64_t> num_indices_to_merge() const;
3263
3264 bool enable_partition_rebalancing() const;
3265
3266 bool retrain() const;
3267
3268 std::optional<IndexSegmentResult> execute(const Dataset& dataset) const;
3269
3270 std::string json() const;
3271
3272 static OptimizeIndexTask from_json(std::string_view json);
3273
3274 const LanceOptimizeIndexTask* c_handle() const;
3275};
3276
3280
3281public:
3283
3285 OptimizeIndexMerge& operator=(OptimizeIndexMerge&&) noexcept = default;
3287 OptimizeIndexMerge& operator=(const OptimizeIndexMerge&) = delete;
3288
3289 std::array<uint8_t, 16> plan_id() const;
3290
3291 uint64_t read_version() const;
3292
3293 uint32_t group() const;
3294
3295 size_t old_segment_count() const;
3296
3297 IndexSegmentMetadata old_segment(size_t index) const;
3298
3299 size_t replace_count() const;
3300
3301 std::array<uint8_t, 16> replace_uuid(size_t index) const;
3302
3303 std::optional<IndexSegmentResult> execute(
3304 const Dataset& dataset,
3305 const std::vector<IndexSegmentResult>& task_results) const;
3306
3307 std::string json() const;
3308
3309 static OptimizeIndexMerge from_json(std::string_view json);
3310
3311 const LanceOptimizeIndexMerge* c_handle() const;
3312};
3313
3317 handle_;
3318
3319public:
3321
3323 OptimizeIndicesPlan& operator=(OptimizeIndicesPlan&&) noexcept = default;
3325 OptimizeIndicesPlan& operator=(const OptimizeIndicesPlan&) = delete;
3326
3327 std::array<uint8_t, 16> plan_id() const;
3328
3329 uint64_t read_version() const;
3330
3331 size_t num_tasks() const;
3332
3333 size_t num_merges() const;
3334
3335 OptimizeIndexTask task(size_t index) const;
3336
3337 OptimizeIndexMerge merge(size_t index) const;
3338
3339 std::string json() const;
3340
3341 static OptimizeIndicesPlan from_json(std::string_view json);
3342
3343 const LanceOptimizeIndicesPlan* c_handle() const;
3344};
3345
3348 std::optional<uint64_t> sample_rate;
3349 std::optional<uint64_t> max_iters;
3350};
3351
3354 std::optional<bool> train;
3355};
3356
3360 bool with_position = false;
3361 std::optional<std::vector<std::array<uint8_t, 16>>> index_segments;
3362};
3363
3364// ─── MemWAL / LSM ───────────────────────────────────────────────────────────
3365
3373
3376 std::array<uint8_t, 16> shard_id{};
3377 uint64_t generation = 0;
3378
3379 static CompactedSsTable from_uuid(const std::string& shard_id,
3380 uint64_t generation);
3381
3383};
3384
3396 std::vector<uint64_t> removed_fragment_ids;
3397 std::vector<const Fragment*> updated_fragments;
3398 std::vector<const Fragment*> new_fragments;
3399 std::vector<uint32_t> fields_modified;
3400 std::vector<CompactedSsTable> compacted_sstables;
3402 std::optional<UpdateMode> update_mode;
3403 std::optional<KeyExistenceFilter> inserted_rows_filter;
3404 std::optional<UpdatedFragmentOffsets> updated_fragment_offsets;
3405 std::optional<std::string> mem_wal_dir_id;
3406};
3407
3409struct SsTable {
3410 uint64_t generation = 0;
3411 std::string path;
3412};
3413
3416 std::string index_name;
3417 std::optional<uint32_t> num_edges;
3418 std::optional<uint32_t> ef_construction;
3419 std::optional<uint32_t> max_level;
3420};
3421
3424 uint64_t put_count = 0;
3425 uint64_t put_time_nanos = 0;
3426 uint64_t wal_flush_count = 0;
3427 uint64_t wal_flush_time_nanos = 0;
3428 uint64_t wal_flush_bytes = 0;
3429 uint64_t wal_io_time_nanos = 0;
3430 uint64_t wal_io_count = 0;
3431 uint64_t index_update_time_nanos = 0;
3432 uint64_t index_update_count = 0;
3433 uint64_t index_update_rows = 0;
3434 uint64_t memtable_flush_count = 0;
3435 uint64_t memtable_flush_time_nanos = 0;
3436 uint64_t memtable_flush_rows = 0;
3437 uint64_t memtable_flush_failures = 0;
3438};
3439
3442 bool is_live = false;
3443 uint64_t row_count = 0;
3444 uint64_t batch_count = 0;
3445 uint64_t estimated_size_bytes = 0;
3446 uint64_t index_bytes = 0;
3447 uint64_t frozen_bytes = 0;
3448 uint64_t grace_bytes = 0;
3449 uint64_t retained_bytes = 0;
3450 uint64_t generation = 0;
3451 std::optional<uint64_t> max_buffered_batch_position;
3452 uint64_t durable_batch_count = 0;
3453 uint64_t global_offset = 0;
3454 std::optional<uint64_t> pending_wal_start_batch_position;
3455 std::optional<uint64_t> pending_wal_end_batch_position;
3456 uint64_t pending_wal_batch_count = 0;
3457 uint64_t pending_wal_row_count = 0;
3458 uint64_t pending_wal_estimated_bytes = 0;
3459 uint64_t frozen_count = 0;
3460};
3461
3464 uint64_t batch_position_begin = 0;
3465 uint64_t batch_position_end = 0;
3466};
3467
3471public:
3472 std::optional<bool> durable_write;
3473 std::optional<uint64_t> max_wal_buffer_size;
3474 std::optional<uint64_t> max_wal_flush_interval_ms;
3475 std::optional<uint64_t> max_memtable_size;
3476 std::optional<uint64_t> max_memtable_rows;
3477 std::optional<uint64_t> max_memtable_batches;
3478 std::optional<uint64_t> max_unflushed_memtable_bytes;
3479 std::optional<uint64_t> manifest_scan_batch_size;
3480 std::optional<uint64_t> backpressure_log_interval_ms;
3481 std::optional<uint64_t> stats_log_interval_ms;
3482 std::vector<HnswParams> hnsw_params;
3483
3495
3496 LanceShardWriterConfig to_c(std::vector<std::string>& names,
3497 std::vector<::LanceMemWalHnswParams>& params) const;
3498};
3499
3503 std::optional<std::string> column;
3504 uint32_t num_buckets = 0;
3507 std::optional<std::vector<std::string>> maintained_indexes;
3508 std::optional<ShardWriterConfig> writer_config;
3509};
3510
3514
3515public:
3517
3518 ShardingField(ShardingField&&) noexcept = default;
3519 ShardingField& operator=(ShardingField&&) noexcept = default;
3521 ShardingField& operator=(const ShardingField&) = delete;
3522
3523 static ShardingField create(
3524 std::string field_id,
3525 std::vector<int32_t> source_ids,
3526 std::optional<std::string> transform,
3527 std::optional<std::string> expression,
3528 std::string result_type,
3529 std::map<std::string, std::string> parameters = {});
3530
3532
3533 std::string id() const;
3534
3535 std::vector<int32_t> source_ids() const;
3536
3537 std::optional<std::string> transform() const;
3538
3539 std::optional<std::string> expression() const;
3540
3541 std::string result_type() const;
3542
3543 std::map<std::string, std::string> parameters() const;
3544
3545 std::optional<std::string> parameter(const std::string& key) const;
3546
3547 const ::LanceMemWalShardingField* c_handle() const;
3548};
3549
3553
3554public:
3556
3557 ShardingSpec(ShardingSpec&&) noexcept = default;
3558 ShardingSpec& operator=(ShardingSpec&&) noexcept = default;
3559 ShardingSpec(const ShardingSpec&) = delete;
3560 ShardingSpec& operator=(const ShardingSpec&) = delete;
3561
3562 static ShardingSpec create(uint32_t spec_id,
3563 std::vector<ShardingField> fields);
3564
3565 ShardingSpec clone() const;
3566
3570 Batch evaluate(const Dataset& dataset, const Batch& batch) const;
3571
3573 Batch evaluate(const Batch& batch, const LanceSchema& schema) const;
3574
3575 uint32_t id() const;
3576
3577 size_t field_count() const;
3578
3579 ShardingField field_at(size_t index) const;
3580
3581 std::vector<ShardingField> fields() const;
3582
3583 void add_field(ShardingField field);
3584
3585 const ::LanceMemWalShardingSpec* c_handle() const;
3586
3587private:
3588 friend class Dataset;
3589};
3590
3594
3595public:
3597
3598 ShardSnapshot(ShardSnapshot&&) noexcept = default;
3599 ShardSnapshot& operator=(ShardSnapshot&&) noexcept = default;
3601 ShardSnapshot& operator=(const ShardSnapshot&) = delete;
3602
3603 static ShardSnapshot create(const std::string& shard_id);
3604
3605 ShardSnapshot clone() const;
3606
3607 std::string shard_id() const;
3608
3609 uint32_t spec_id() const;
3610
3611 ShardSnapshot& set_spec_id(uint32_t value);
3612
3613 uint64_t current_generation() const;
3614
3615 ShardSnapshot& set_current_generation(uint64_t value);
3616
3617 ShardSnapshot& add_sstable(uint64_t generation, const std::string& path);
3618
3619 std::vector<SsTable> sstables() const;
3620
3621 const ::LanceMemWalShardSnapshot* c_handle() const;
3622};
3623
3626 uint32_t num_shards_ = 0;
3627 bool maintain_all_ = false;
3628 std::vector<std::string> maintained_;
3629 std::vector<ShardingSpec> specs_;
3630 std::map<std::string, std::string> defaults_;
3631 std::string dir_id_;
3632
3633public:
3634 MemWalIndexDetails(uint32_t num_shards,
3635 bool maintain_all,
3636 std::vector<std::string> maintained,
3637 std::vector<ShardingSpec> specs,
3638 std::map<std::string, std::string> defaults,
3639 std::string dir_id = {});
3640
3642 MemWalIndexDetails& operator=(MemWalIndexDetails&&) noexcept = default;
3644 MemWalIndexDetails& operator=(const MemWalIndexDetails&) = delete;
3645
3648 const std::string& dir_id() const;
3649 uint32_t num_shards() const;
3650 bool maintain_all_indexes() const;
3651 const std::vector<std::string>& maintained_indexes() const;
3652 const std::map<std::string, std::string>& writer_config_defaults() const;
3653 size_t sharding_spec_count() const;
3654 ShardingSpec sharding_spec_at(size_t index) const;
3655 std::vector<ShardingSpec> sharding_specs() const;
3656};
3657
3661
3662public:
3664
3665 ~ShardWriter() = default;
3666 ShardWriter(ShardWriter&&) noexcept = default;
3667 ShardWriter& operator=(ShardWriter&&) noexcept = default;
3668 ShardWriter(const ShardWriter&) = delete;
3669 ShardWriter& operator=(const ShardWriter&) = delete;
3670
3672 static ShardWriter open(const Dataset& dataset,
3673 const std::string& shard_id,
3674 const ShardWriterConfig& config = {});
3675
3676 std::string shard_id() const;
3677
3679
3681
3683
3685
3689 std::optional<ShardSnapshot> snapshot() const;
3690
3691 LsmScanner lsm_scanner(std::vector<ShardSnapshot> snapshots);
3692
3693 void close();
3694
3695 const ::LanceShardWriter* c_handle() const;
3696};
3697
3701
3702public:
3703 explicit LsmScanner(::LanceLsmScanner* scanner);
3704 ~LsmScanner() = default;
3705 LsmScanner(LsmScanner&&) noexcept = default;
3706 LsmScanner& operator=(LsmScanner&&) noexcept = default;
3707 LsmScanner(const LsmScanner&) = delete;
3708 LsmScanner& operator=(const LsmScanner&) = delete;
3709
3710 static LsmScanner from_snapshots(const Dataset& dataset,
3711 std::vector<ShardSnapshot> snapshots);
3712
3713 LsmScanner& project(const std::vector<std::string>& columns);
3714
3715 LsmScanner& filter(const std::string& expression);
3716
3717 LsmScanner& limit(std::optional<int64_t> limit,
3718 std::optional<int64_t> offset = std::nullopt);
3719
3720 LsmScanner& with_row_address();
3721
3722 LsmScanner& with_memtable_gen();
3723
3724 Batch to_batch() const;
3725 std::vector<Batch> to_batches() const;
3726 Table to_table() const;
3727 uint64_t count_rows() const;
3728
3729 ArrowStream to_reader() const;
3730
3731 const ::LanceLsmScanner* c_handle() const;
3732};
3733
3737
3738public:
3740 ~ExecutionPlan() = default;
3741 ExecutionPlan(ExecutionPlan&&) noexcept = default;
3742 ExecutionPlan& operator=(ExecutionPlan&&) noexcept = default;
3744 ExecutionPlan& operator=(const ExecutionPlan&) = delete;
3745
3746 ArrowSchemaOwner schema() const;
3747 ArrowSchemaOwner dataset_schema() const;
3748
3749 std::string explain() const;
3750
3751 Batch to_batch() const;
3752 std::vector<Batch> to_batches() const;
3753 Table to_table() const;
3754
3755 ArrowStream to_reader() const;
3756
3757 const ::LanceMemWalPlan* c_handle() const;
3758};
3759
3763
3764public:
3766 std::vector<ShardSnapshot> snapshots,
3767 std::optional<std::vector<std::string>> pk_columns = std::nullopt);
3768
3771 LsmPointLookupPlanner& operator=(LsmPointLookupPlanner&&) noexcept = default;
3774
3775 ExecutionPlan plan_lookup(
3776 const Batch& pk_value,
3777 std::optional<std::vector<std::string>> columns = std::nullopt) const;
3778
3779private:
3781 friend class Dataset;
3782};
3783
3787
3788public:
3790 std::vector<ShardSnapshot> snapshots,
3791 std::string vector_column,
3792 std::optional<std::vector<std::string>> pk_columns = std::nullopt,
3793 MemWalDistanceType distance_type = MemWalDistanceType::L2,
3794 std::optional<std::string> filter = std::nullopt);
3795
3798 LsmVectorSearchPlanner& operator=(LsmVectorSearchPlanner&&) noexcept = default;
3801
3802 ExecutionPlan plan_search(
3803 const std::vector<float>& query,
3804 uint64_t k = 10,
3805 uint64_t nprobes = 20,
3806 std::optional<std::vector<std::string>> columns = std::nullopt,
3807 bool refine_base_table = false,
3808 double overfetch_factor = 1.0) const;
3809
3810private:
3812 friend class Dataset;
3813};
3814
3815// ─── Dataset ─────────────────────────────────────────────────────────────────
3816
3817class Dataset {
3819
3824 class ArrowStreamInput {
3825 ArrowArrayStream* stream_;
3826 bool armed_ = true;
3827 ArrowSchema schema_ = {};
3828
3829 public:
3830 explicit ArrowStreamInput(ArrowArrayStream* stream);
3831
3832 ~ArrowStreamInput();
3833
3834 ArrowStreamInput(const ArrowStreamInput&) = delete;
3835 ArrowStreamInput& operator=(const ArrowStreamInput&) = delete;
3836 ArrowStreamInput(ArrowStreamInput&&) = delete;
3837 ArrowStreamInput& operator=(ArrowStreamInput&&) = delete;
3838
3839 const ArrowSchema* read_schema();
3840
3841 ArrowArrayStream* consume() noexcept;
3842 };
3843
3844 static std::vector<const char*> to_c_key_values(
3845 const std::vector<std::pair<std::string, std::string>>& entries);
3846
3848 const WriteOptions& options,
3849 LanceAutoCleanupParams& cleanup);
3850
3851 static LanceUncommittedWriteOptions to_c_uncommitted_write_options(
3852 const UncommittedWriteOptions& options,
3853 LanceAutoCleanupParams& cleanup,
3854 std::vector<const char*>& properties);
3855
3856 static LanceCommitOptions to_c_commit_options(const CommitOptions& options);
3857
3858 static RemovalStats from_c_removal_stats(const LanceRemovalStats& stats);
3859
3860 static LanceCleanupPolicy to_c_cleanup_policy(
3861 const CleanupPolicy& policy,
3862 std::vector<uint64_t>& versions,
3863 uint64_t& empty_versions_sentinel);
3864
3865 static LanceCleanupOperationOptions to_c_cleanup_operation(
3866 const CleanupOperationOptions& options);
3867
3868 static CleanupExplanation read_cleanup_explanation(
3869 const LanceCleanupExplanation* explanation);
3870
3871 static VersionDetails read_version(const LanceVersion* version);
3872
3873 static TagInfo read_tag(const LanceTag* tag);
3874
3882 static void adopt_blobs(const std::vector<LanceBlobFile*>& raw,
3883 std::vector<std::optional<BlobFile>>& blobs);
3884
3885 static std::string run_metadata_update_json(
3886 LanceDataset* dataset,
3887 const std::vector<std::pair<std::string, std::optional<std::string>>>& values,
3888 MetadataUpdateMode mode,
3889 bool schema_metadata);
3890
3891 static void run_field_metadata_update(
3892 LanceDataset* dataset,
3893 const std::vector<FieldMetadataUpdate>& updates);
3894
3895 struct TrackedFilesProgressCapture {
3897 };
3898
3899 static void tracked_files_progress_trampoline(
3900 void* callback_ctx,
3901 uint64_t manifests_processed,
3902 const uint64_t* manifests_total) noexcept;
3903
3904 static void tracked_files_progress_release(
3905 void* callback_ctx) noexcept;
3906
3909 static Dataset write_impl(
3910 const std::string& uri,
3911 ArrowArrayStream* stream,
3912 WriteMode mode,
3913 const LanceWriteParams* legacy_params,
3914 const LanceWriteOptions* native_options,
3915 const std::vector<std::pair<std::string, std::string>>& storage_opts,
3916 const StorageOptionsAccessor* storage_options_accessor = nullptr);
3917
3918public:
3923 const std::string& uri,
3924 const std::vector<std::pair<std::string, std::string>>& storage_opts = {},
3925 uint64_t version = 0);
3926
3930 const Session& session,
3931 const std::string& uri,
3932 const std::vector<std::pair<std::string, std::string>>& storage_opts = {},
3933 uint64_t version = 0);
3934
3942 const std::string& uri,
3943 const DatasetOpenOptions& options = {},
3944 const Session* session = nullptr);
3945
3952 const std::string& uri,
3953 const StorageOptionsAccessor* storage_accessor,
3954 uint64_t version,
3955 const Session* session,
3956 const CommitLock* commit_lock);
3957
3965 const std::string& uri,
3966 ArrowArrayStream* stream,
3967 WriteMode mode,
3968 const std::vector<std::pair<std::string, std::string>>& storage_opts = {});
3969
3977 const std::string& uri,
3978 ArrowArrayStream* stream,
3979 WriteMode mode,
3980 const WriteParams& params,
3981 const std::vector<std::pair<std::string, std::string>>& storage_opts = {});
3982
3991 const std::string& uri,
3992 ArrowArrayStream* stream,
3993 WriteMode mode,
3994 const WriteOptions& options,
3995 const std::vector<std::pair<std::string, std::string>>& storage_opts = {});
3996
4001 const std::string& uri,
4002 ArrowArrayStream* stream,
4003 WriteMode mode,
4004 const StorageOptionsAccessor& storage_options_accessor);
4005
4009 const std::string& uri,
4010 ArrowArrayStream* stream,
4011 WriteMode mode,
4012 const WriteParams& params,
4013 const StorageOptionsAccessor& storage_options_accessor);
4014
4018 const std::string& uri,
4019 ArrowArrayStream* stream,
4020 WriteMode mode,
4021 const WriteOptions& options,
4022 const StorageOptionsAccessor& storage_options_accessor);
4023
4031 const std::string& uri,
4032 ArrowArrayStream* stream,
4033 WriteMode mode,
4034 const WriteOptions& options,
4035 const StorageOptionsAccessor* storage_accessor,
4036 const Session* session,
4037 const CommitLock* commit_lock);
4038
4047 const std::string& uri,
4048 ArrowArrayStream* stream,
4049 WriteMode mode,
4050 const NativeWriteOptions& options);
4051
4060 const std::string& uri,
4061 ArrowArrayStream* stream,
4062 WriteMode mode,
4063 const NativeWriteOptions& options);
4064
4068 const Namespace& ns,
4069 const std::vector<std::string>& table_id,
4070 const std::vector<std::pair<std::string, std::string>>& storage_opts = {},
4071 uint64_t version = 0,
4072 const Session* session = nullptr);
4073
4079 const Namespace& ns,
4080 const std::vector<std::string>& table_id,
4081 ArrowArrayStream* stream,
4082 WriteMode mode,
4083 const WriteOptions& options = {},
4084 const std::vector<std::pair<std::string, std::string>>& storage_opts = {},
4085 const std::optional<std::string>& branch = std::nullopt,
4086 const Session* session = nullptr);
4087
4091 const Namespace& ns,
4092 const std::vector<std::string>& table_id,
4093 const std::string& uri,
4094 const Transaction& transaction,
4095 const CommitOptions& options = {},
4096 const std::vector<std::pair<std::string, std::string>>& storage_opts = {},
4097 const Session* session = nullptr);
4098
4107 const std::string& uri,
4108 ArrowArrayStream* stream,
4109 WriteMode mode,
4110 const UncommittedWriteOptions& options = {},
4111 const std::vector<std::pair<std::string, std::string>>& storage_opts = {},
4112 const Session* session = nullptr);
4113
4122 const std::string& uri,
4123 ArrowArrayStream* stream,
4124 WriteMode mode,
4125 const StorageOptionsAccessor& storage_options_accessor,
4126 const UncommittedWriteOptions& options = {},
4127 const Session* session = nullptr);
4128
4138 const std::string& uri,
4139 ArrowArrayStream* stream,
4140 WriteMode mode,
4141 const UncommittedWriteOptions& options,
4142 const StorageOptionsAccessor* storage_accessor,
4143 const Session* session,
4144 const CommitLock* commit_lock);
4145
4149 const std::string& uri,
4150 const Transaction& transaction,
4151 const CommitOptions& options = {},
4152 const std::vector<std::pair<std::string, std::string>>& storage_opts = {},
4153 const Session* session = nullptr);
4154
4158 const std::string& uri,
4159 const Transaction& transaction,
4160 const StorageOptionsAccessor& storage_options_accessor,
4161 const CommitOptions& options = {},
4162 const Session* session = nullptr);
4163
4171 const std::string& uri,
4172 const Transaction& transaction,
4173 const CommitOptions& options,
4174 const StorageOptionsAccessor* storage_accessor,
4175 const Session* session,
4176 const CommitLock* commit_lock);
4177
4181 const std::string& uri,
4182 const std::vector<std::reference_wrapper<const Transaction>>& transactions,
4183 const CommitOptions& options = {},
4184 const std::vector<std::pair<std::string, std::string>>& storage_opts = {},
4185 const Session* session = nullptr);
4186
4191 const std::string& uri,
4192 const std::vector<std::reference_wrapper<const Transaction>>& transactions,
4193 const StorageOptionsAccessor& storage_options_accessor,
4194 const CommitOptions& options = {},
4195 const Session* session = nullptr);
4196
4200 const std::string& uri,
4201 const std::vector<std::reference_wrapper<const Transaction>>& transactions,
4202 const CommitOptions& options,
4203 const StorageOptionsAccessor* storage_accessor,
4204 const Session* session,
4205 const CommitLock* commit_lock);
4206
4219
4221 uint64_t count_rows() const;
4222
4227 uint64_t count_rows(const std::string& filter) const;
4228
4230 uint64_t version() const;
4231
4236 std::string uri() const;
4237
4239 uint64_t latest_version() const;
4240
4244 std::string metadata_json() const;
4245
4252 const std::vector<std::pair<std::string, std::optional<std::string>>>& values,
4253 MetadataUpdateMode mode = MetadataUpdateMode::Merge);
4254
4260 const std::vector<std::pair<std::string, std::optional<std::string>>>& values,
4261 MetadataUpdateMode mode = MetadataUpdateMode::Merge);
4262
4267 void update_field_metadata(const std::vector<FieldMetadataUpdate>& updates);
4268
4271 std::string data_storage_version() const;
4272
4276
4279 std::vector<int32_t> field_ids() const;
4280
4283 int32_t resolve_field_id(const FieldReference& field) const;
4284
4287 std::string field_path(int32_t field_id) const;
4288
4291 std::vector<VersionInfo> versions() const;
4292
4298
4303
4310 std::map<std::string, std::string> config() const;
4311
4321 const std::vector<ConfigUpdate>& updates,
4322 MetadataUpdateMode mode = MetadataUpdateMode::Merge);
4323
4326 void update_config(const std::vector<ConfigUpdate>& updates);
4327
4331 std::string base_paths_json() const;
4332
4343 const std::vector<BasePath>& bases,
4344 const AddBasesOptions& options = {});
4345
4350 std::optional<uint64_t> min_version = std::nullopt,
4351 TrackedFilesProgressCallback progress = {}) const;
4352
4357
4361 std::optional<Transaction> read_transaction() const;
4362
4365 std::optional<Transaction> read_transaction_by_version(
4366 uint64_t version) const;
4367
4372
4376 std::vector<VersionDetails> version_details() const;
4377
4379 std::vector<uint64_t> version_refs() const;
4380
4382 Dataset checkout(const Ref& reference) const;
4383
4407 const std::string& target_path,
4408 const Ref* reference = nullptr,
4409 const StorageOptionsAccessor* storage_options = nullptr) const;
4410
4430 const std::string& target_path,
4431 const Ref* reference = nullptr,
4432 const StorageOptionsAccessor* storage_options = nullptr) const;
4433
4441 const std::string& branch_name,
4442 const Ref& reference,
4443 std::optional<std::vector<std::pair<std::string, std::string>>> storage_opts =
4444 std::nullopt) const;
4445
4448 Dataset checkout_branch(const std::string& branch_name) const;
4449
4452 std::string branches_json() const;
4453
4455 std::string get_branch_json(const std::string& branch_name) const;
4456
4458 std::string branch_identifier_json() const;
4459
4462 void delete_branch(const std::string& branch_name) const;
4463
4466 void force_delete_branch(const std::string& branch_name) const;
4467
4471 const std::string& branch_name,
4472 const std::vector<std::pair<std::string, std::string>>& metadata) const;
4473
4475 std::vector<TagInfo> tags() const;
4476
4478 TagInfo get_tag(const std::string& name) const;
4479
4481 void create_tag(const std::string& name, const Ref& reference) const;
4482
4484 void update_tag(const std::string& name, const Ref& reference) const;
4485
4487 void delete_tag(const std::string& name) const;
4488
4492 const std::string& name,
4493 const std::vector<std::pair<std::string, std::string>>& metadata) const;
4494
4498 std::vector<FieldStatistics> calculate_data_stats() const;
4499
4504 const CleanupOldVersionsOptions& options) const;
4505
4510 const CleanupPolicy& policy,
4511 const CleanupOperationOptions& operation = {}) const;
4512
4518 const CleanupPolicy& policy,
4519 const CleanupOperationOptions& operation = {}) const;
4520
4523 void validate() const;
4524
4527 uint64_t count_deleted_rows() const;
4528
4532 uint64_t num_small_files(size_t max_rows_per_group) const;
4533
4538 Dataset restore(uint64_t version) const;
4539
4547 uint64_t delete_rows(const std::string& predicate);
4548
4557 uint64_t update(
4558 const std::string& predicate,
4559 const std::vector<std::pair<std::string, std::string>>& updates);
4560
4568 void merge(ArrowArrayStream* source, const std::string& left_on);
4569
4576 void merge(
4577 ArrowArrayStream* source,
4578 const std::string& left_on,
4579 const std::string& right_on);
4580
4591 const std::vector<std::string>& on_columns,
4592 ArrowArrayStream* source,
4593 const LanceMergeInsertParams* params = nullptr);
4594
4597 const std::vector<std::string>& on_columns,
4598 ArrowArrayStream* source);
4599
4600 // ─── MemWAL / LSM ────────────────────────────────────────────────────────
4601
4607
4610 std::optional<MemWalIndexDetails> mem_wal_index_details() const;
4611
4614 ShardWriter mem_wal_writer(const std::string& shard_id,
4615 const ShardWriterConfig& config = {}) const;
4616
4620 const std::vector<std::string>& on_columns,
4621 ArrowArrayStream* source,
4622 const LanceMergeInsertParams* params,
4623 const std::vector<CompactedSsTable>& compacted_sstables);
4624
4630 const LanceCompactionOptions* options = nullptr);
4631
4635 const CompactionOptions* options = nullptr);
4636
4639 const CompactionOptions* options = nullptr) const;
4640
4643 const std::vector<RewriteResult>& results,
4644 const CompactionOptions* options = nullptr);
4645
4648 const OptimizeIndicesOptions* options = nullptr);
4649
4652 const OptimizeIndicesOptions* options = nullptr) const;
4653
4656 const std::vector<IndexSegmentResult>& results,
4657 const OptimizeIndicesOptions* options = nullptr);
4658
4661
4664
4673 void drop_columns(const std::vector<std::string>& columns);
4674
4686 void alter_columns(const std::vector<ColumnAlteration>& alterations);
4687
4696 void add_columns_sql(const std::vector<SqlColumn>& columns,
4697 uint64_t batch_size = 0);
4698
4714 const BatchUDF& udf,
4715 std::optional<std::vector<std::string>> read_columns = std::nullopt,
4716 std::optional<uint32_t> batch_size = std::nullopt);
4717
4722 const BatchUDFV2& udf,
4723 std::optional<std::vector<std::string>> read_columns = std::nullopt,
4724 std::optional<uint32_t> batch_size = std::nullopt);
4725
4735 void add_columns_nulls(const ArrowSchema* schema);
4736
4747 void add_columns_stream(ArrowArrayStream* stream, uint64_t batch_size = 0);
4748
4750 void schema(ArrowSchema* out) const;
4751
4761 const std::string& path,
4762 std::optional<uint32_t> base_id = std::nullopt) const;
4763
4766
4770 void take(const uint64_t* indices, size_t num_indices,
4771 const std::vector<std::string>& columns,
4772 ArrowArrayStream* out) const;
4773
4775 void take(const uint64_t* indices, size_t num_indices,
4776 ArrowArrayStream* out) const;
4777
4785 ArrowStream take(const uint64_t* indices, size_t num_indices,
4786 const std::vector<std::string>& columns) const;
4787
4790 ArrowStream take(const uint64_t* indices, size_t num_indices) const;
4791
4795 ArrowStream take(std::span<const uint64_t> indices,
4796 const std::vector<std::string>& columns) const;
4797
4800 ArrowStream take(std::span<const uint64_t> indices) const;
4801
4805 void take_rows(const uint64_t* row_ids, size_t num_row_ids,
4806 const std::vector<std::string>& columns,
4807 ArrowArrayStream* out) const;
4808
4814 void take_rows(std::span<const uint64_t> row_ids,
4815 const std::vector<std::string>& columns,
4816 ArrowArrayStream* out) const;
4817
4820 void take_rows(const uint64_t* row_ids, size_t num_row_ids,
4821 ArrowArrayStream* out) const;
4822
4825 void take_rows(std::span<const uint64_t> row_ids,
4826 ArrowArrayStream* out) const;
4827
4835 ArrowStream take_rows(const uint64_t* row_ids, size_t num_row_ids,
4836 const std::vector<std::string>& columns) const;
4837
4840 ArrowStream take_rows(const uint64_t* row_ids, size_t num_row_ids) const;
4841
4845 ArrowStream take_rows(std::span<const uint64_t> row_ids,
4846 const std::vector<std::string>& columns) const;
4847
4850 ArrowStream take_rows(std::span<const uint64_t> row_ids) const;
4851
4854 std::vector<std::optional<BlobFile>> take_blobs(
4855 const uint64_t* row_ids, size_t num_row_ids,
4856 const std::string& column) const;
4857
4860 std::vector<std::optional<BlobFile>> take_blobs_by_indices(
4861 const uint64_t* indices, size_t num_indices,
4862 const std::string& column) const;
4863
4867 std::vector<std::optional<BlobFile>> take_blobs_by_addresses(
4868 const uint64_t* row_addresses, size_t num_row_addresses,
4869 const std::string& column) const;
4870
4879 const std::string& column,
4880 BlobRowSelector selector,
4881 const std::vector<uint64_t>& rows,
4882 const BlobReadOptions& options = {}) const;
4883
4892 const std::string& column,
4893 BlobRowSelector selector,
4894 const std::vector<BlobRangeRequest>& requests,
4895 const BlobReadOptions& options = {}) const;
4896
4898 Scanner scan() const;
4899
4904 Scanner scan(const std::vector<std::string>& columns,
4905 const std::optional<std::string>& filter = std::nullopt) const;
4906
4908 Scanner scan(std::nullopt_t,
4909 const std::optional<std::string>& filter = std::nullopt) const;
4910
4916 SqlQueryBuilder sql(const std::string& sql) const;
4917
4924
4926 [[deprecated("Use prepare_fts_match_query() to select the Match operator")]] FtsQueryContext prepare_fts_query(
4927 const std::string& column,
4928 const std::string& query,
4929 uint32_t max_fuzzy_distance = 0,
4930 FtsCoverageMode coverage_mode = FtsCoverageMode::Strict) const;
4931
4937 const std::string& column,
4938 const std::string& query,
4939 FtsMatchOperator match_operator = FtsMatchOperator::Or,
4940 uint32_t max_fuzzy_distance = 0,
4941 FtsCoverageMode coverage_mode = FtsCoverageMode::Strict) const;
4942
4946 const std::string& column,
4947 const std::string& query,
4948 int32_t slop = 0,
4949 FtsCoverageMode coverage_mode = FtsCoverageMode::Strict) const;
4950
4952 uint64_t fragment_count() const;
4953
4955 std::vector<uint64_t> fragment_ids() const;
4956
4960 Fragment open_fragment(uint64_t fragment_id) const;
4961
4963 void create_vector_index(const std::string& column,
4964 const LanceVectorIndexParams& params,
4965 const std::string& name = "",
4966 bool replace = false);
4967
4979 const std::string& column,
4980 const LanceVectorIndexParams& params,
4982 void* callback_ctx,
4983 const std::string& name = "",
4984 bool replace = false);
4985
4992 const std::string& column,
4993 const VectorIndexOptions& options,
4994 const std::string& name = "",
4995 bool replace = false);
4996
5001 const std::string& column,
5002 const VectorIndexOptions& options,
5004 void* callback_ctx,
5005 const std::string& name = "",
5006 bool replace = false);
5007
5011 void create_scalar_index(const std::string& column,
5012 LanceScalarIndexType index_type,
5013 const std::string& name = "",
5014 const std::string& params_json = "",
5015 bool replace = false);
5016
5022 const std::string& column,
5023 LanceScalarIndexType index_type,
5025 void* callback_ctx,
5026 const std::string& name = "",
5027 const std::string& params_json = "",
5028 bool replace = false);
5029
5034 const std::string& column,
5035 LanceScalarIndexType index_type,
5036 const ScalarIndexOptions& options,
5037 const std::string& index_name = "",
5038 const std::string& params_json = "",
5039 bool replace = false);
5040
5047 const std::string& column,
5048 LanceScalarIndexType index_type,
5049 const ScalarIndexOptions& options,
5051 void* callback_ctx,
5052 const std::string& index_name = "",
5053 const std::string& params_json = "",
5054 bool replace = false);
5055
5060 const std::string& column,
5061 LanceScalarIndexType index_type,
5062 const std::string& index_name = "",
5063 const std::string& params_json = "",
5064 const LanceIndexSegmentBuildOptions* options = nullptr) const;
5065
5068 const std::string& column,
5069 LanceScalarIndexType index_type,
5070 const ScalarIndexOptions& options,
5071 const std::string& index_name = "",
5072 const std::string& params_json = "",
5073 const LanceIndexSegmentBuildOptions* build_options = nullptr) const;
5074
5077 const std::string& column,
5078 const LanceVectorIndexParams& params,
5079 const std::string& index_name = "",
5080 const LanceIndexSegmentBuildOptions* options = nullptr) const;
5081
5087 const std::string& column,
5088 const VectorIndexOptions& options,
5089 const std::string& index_name = "",
5090 std::optional<std::vector<uint32_t>> fragment_ids = std::nullopt,
5091 const std::array<uint8_t, 16>* index_uuid = nullptr) const;
5092
5095 const std::string& column,
5096 uint32_t num_partitions,
5097 LanceMetricType metric,
5098 const std::vector<uint32_t>& fragment_ids = {}) const;
5099
5103 const std::string& column,
5104 uint32_t num_sub_vectors,
5105 uint32_t num_bits,
5106 LanceMetricType metric,
5107 IndexModel& ivf_centroids,
5108 const std::vector<uint32_t>& fragment_ids = {}) const;
5109
5112 const std::string& column,
5113 uint32_t num_partitions,
5114 LanceMetricType metric,
5115 const IndexTrainerOptions& options = {},
5116 const std::vector<uint32_t>& fragment_ids = {}) const;
5117
5120 const std::string& column,
5121 uint32_t num_sub_vectors,
5122 uint32_t num_bits,
5123 LanceMetricType metric,
5124 IndexModel& ivf_centroids,
5125 const IndexTrainerOptions& options = {},
5126 const std::vector<uint32_t>& fragment_ids = {}) const;
5127
5129 std::string describe_indices_json() const;
5130
5133 std::string index_statistics_json(const std::string& index_name);
5134
5136 IvfModel get_ivf_model(const std::string& index_name) const;
5137
5139 std::optional<IndexModel> centroids(const std::string& index_name) const;
5140
5143 const std::string& index_name,
5144 uint64_t partition_id,
5145 bool with_vector = false) const;
5146
5148 void drop_index(const std::string& name);
5149
5153 void prewarm_index(const std::string& index_name) const;
5154
5157 const std::string& index_name,
5158 const IndexPrewarmOptions& options = {}) const;
5159
5161 uint64_t index_count() const;
5162
5164 std::string list_indices_json() const;
5165
5171 std::string index_segments_json() const;
5172
5175 const std::array<uint8_t, 16>& index_uuid,
5176 const std::string& index_type,
5177 std::optional<size_t> batch_readhead = std::nullopt,
5178 LanceIndexBuildProgressCallback callback = nullptr,
5179 void* callback_ctx = nullptr) const;
5180
5182 std::vector<uint8_t> merge_index_segments(
5183 const std::vector<std::vector<uint8_t>>& segment_metadata) const;
5184
5187 uint64_t index_segment_count(const std::string& index_name) const;
5188
5193 std::vector<std::array<uint8_t, 16>> index_segments(const std::string& index_name) const;
5194
5215 const std::string& index_name,
5216 const std::string& column,
5217 const std::vector<std::vector<uint8_t>>& segment_metadata);
5218
5220 const LanceDataset* c_handle() const;
5221
5222 friend class Fragment;
5223
5224private:
5225 explicit Dataset(LanceDataset* ptr);
5226};
5227
5228// ─── Dataset SQL ─────────────────────────────────────────────────────────────
5229
5235
5236public:
5238
5239 SqlQuery(SqlQuery&&) noexcept = default;
5240 SqlQuery& operator=(SqlQuery&&) noexcept = default;
5241 SqlQuery(const SqlQuery&) = delete;
5242 SqlQuery& operator=(const SqlQuery&) = delete;
5243
5250 ArrowStream into_stream();
5251};
5252
5259
5260public:
5262
5263 SqlQueryBuilder(SqlQueryBuilder&&) noexcept = default;
5264 SqlQueryBuilder& operator=(SqlQueryBuilder&&) noexcept = default;
5266 SqlQueryBuilder& operator=(const SqlQueryBuilder&) = delete;
5267
5271 SqlQueryBuilder& table_name(const std::string& name);
5272
5275 SqlQueryBuilder& with_row_id(bool enabled = true);
5276
5279 SqlQueryBuilder& with_row_addr(bool enabled = true);
5280
5282 SqlQueryBuilder& blob_handling(LanceBlobHandling handling);
5283
5286 SqlQueryBuilder& batch_size(uint64_t rows);
5287
5289 SqlQueryBuilder& batch_size_bytes(uint64_t bytes);
5290
5294 SqlQuery build();
5295};
5296
5297// ─── Dataset delta ───────────────────────────────────────────────────────────
5298
5307
5308public:
5310
5311 DatasetDelta(DatasetDelta&&) noexcept = default;
5312 DatasetDelta& operator=(DatasetDelta&&) noexcept = default;
5313 DatasetDelta(const DatasetDelta&) = delete;
5314 DatasetDelta& operator=(const DatasetDelta&) = delete;
5315
5321 std::vector<Transaction> list_transactions() const;
5322
5327 ArrowStream get_inserted_rows() const;
5328
5333 ArrowStream get_updated_rows() const;
5334
5339 ArrowStream get_upserted_rows() const;
5340
5346 ArrowStream get_deleted_row_ids() const;
5347};
5348
5354
5355public:
5357
5359 DatasetDeltaBuilder& operator=(DatasetDeltaBuilder&&) noexcept = default;
5361 DatasetDeltaBuilder& operator=(const DatasetDeltaBuilder&) = delete;
5362
5365 DatasetDeltaBuilder& compared_against_version(uint64_t version);
5366
5369 DatasetDeltaBuilder& begin_version(uint64_t version);
5370
5372 DatasetDeltaBuilder& end_version(uint64_t version);
5373
5377 DatasetDeltaBuilder& begin_timestamp(const LanceDeltaTimestamp& timestamp);
5378
5380 DatasetDeltaBuilder& end_timestamp(const LanceDeltaTimestamp& timestamp);
5381
5387};
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5406
5407 BatchCommitResult(Dataset&& dataset_value, Transaction&& transaction_value);
5408
5410 BatchCommitResult& operator=(BatchCommitResult&&) noexcept = default;
5412 BatchCommitResult& operator=(const BatchCommitResult&) = delete;
5413};
5414
5415
5416
5417
5418
5419
5420
5421// ─── Uncommitted index segments ──────────────────────────────────────────────
5422
5425 ArrowArray array_ = {};
5426 ArrowSchema schema_ = {};
5427
5428 void reset() noexcept;
5429
5430 friend class Dataset;
5431 friend class IvfModel;
5432
5433 IndexModel() noexcept = default;
5434
5435 IndexModel(ArrowArray array, ArrowSchema schema) noexcept;
5436
5437public:
5443 static IndexModel adopt(ArrowArray* array, ArrowSchema* schema);
5444
5446
5447 IndexModel(IndexModel&& other) noexcept;
5448 IndexModel& operator=(IndexModel&& other) noexcept {
5449 if (this != &other) {
5450 reset();
5451 array_ = other.array_;
5452 schema_ = other.schema_;
5453 other.array_ = {};
5454 other.schema_ = {};
5455 }
5456 return *this;
5457 }
5458 IndexModel(const IndexModel&) = delete;
5460
5461 ArrowArray* array() noexcept;
5462 const ArrowSchema* schema() const noexcept;
5463};
5464
5468
5469 explicit IvfModel(LanceIvfModel* model);
5470 friend class Dataset;
5471
5472public:
5473 IvfModel(IvfModel&&) noexcept = default;
5474 IvfModel& operator=(IvfModel&&) noexcept = default;
5475 IvfModel(const IvfModel&) = delete;
5476 IvfModel& operator=(const IvfModel&) = delete;
5477
5478 bool has_centroids() const;
5479
5481 std::optional<IndexModel> centroids() const;
5482
5483 uint64_t num_partitions() const;
5484
5485 uint64_t dimension() const;
5486
5488 uint64_t partition_size(uint64_t partition_id) const;
5489
5490 const LanceIvfModel* c_handle() const;
5491};
5492
5493namespace detail {
5494
5498 LanceVectorIndexOptions options_{};
5499 std::vector<const char*> storage_keys_;
5500 std::vector<const char*> storage_values_;
5501 LanceStringMap storage_{};
5502 std::vector<const char*> runtime_keys_;
5503 std::vector<const char*> runtime_values_;
5504 LanceStringMap runtime_{};
5505 std::vector<const char*> shuffle_buffers_;
5507
5508 static void set_optional(LanceOptionalU64& out,
5509 const std::optional<uint64_t>& value);
5510
5511 static void set_map(const std::map<std::string, std::string>& source,
5512 std::vector<const char*>& keys,
5513 std::vector<const char*>& values,
5514 LanceStringMap& out);
5515
5516public:
5518
5521 delete;
5522
5524};
5525
5526} // namespace detail
5527
5530 std::string path;
5531 uint64_t size_bytes = 0;
5532
5533 bool operator==(const IndexSegmentFile& other) const {
5534 return path == other.path && size_bytes == other.size_bytes;
5535 }
5536
5537 bool operator!=(const IndexSegmentFile& other) const {
5538 return !(*this == other);
5539 }
5540};
5541
5544 int64_t unix_seconds = 0;
5545 uint32_t nanos = 0;
5546};
5547
5551
5552public:
5554
5556 IndexSegmentMetadata& operator=(IndexSegmentMetadata&&) noexcept = default;
5558 IndexSegmentMetadata& operator=(const IndexSegmentMetadata&) = delete;
5559
5561 static IndexSegmentMetadata parse(const uint8_t* bytes, size_t len);
5562
5564 static IndexSegmentMetadata parse(const std::vector<uint8_t>& bytes);
5565
5566 std::array<uint8_t, 16> uuid() const;
5567
5568 std::string name() const;
5569
5570 uint64_t dataset_version() const;
5571
5572 int32_t index_version() const;
5573
5574 int32_t index_type() const;
5575
5576 std::string index_details_type_url() const;
5577
5578 std::vector<int32_t> field_ids() const;
5579
5580 std::vector<uint32_t> fragment_ids() const;
5581
5584
5588 IndexSegmentMetadata clone_with_fragment_ids(
5589 std::optional<std::vector<uint32_t>> fragment_ids) const;
5590
5593 std::vector<uint8_t> encode() const;
5594
5595 std::vector<int32_t> covering_field_ids() const;
5596
5599 std::vector<uint8_t> index_details_value() const;
5600
5601 std::vector<IndexSegmentFile> files() const;
5602
5603 std::optional<IndexTimestamp> created_at() const;
5604
5605 std::optional<uint32_t> base_id() const;
5606
5607 const LanceIndexSegmentMetadata* c_handle() const;
5608};
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5627
5628public:
5630
5632 IndexSegmentBuilder& operator=(IndexSegmentBuilder&&) noexcept = default;
5634 IndexSegmentBuilder& operator=(const IndexSegmentBuilder&) = delete;
5635
5639 std::vector<uint8_t> execute_uncommitted();
5640
5656 void* callback_ctx);
5657
5659};
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691// ─── Scanner ─────────────────────────────────────────────────────────────────
5692
5699
5702 std::string output_name;
5703 std::string expression;
5704};
5705
5706class Scanner {
5708
5709public:
5710 friend class Fragment;
5711
5712 explicit Scanner(LanceScanner* s);
5713
5715 Scanner& limit(int64_t n);
5716
5718 Scanner& offset(int64_t n);
5719
5721 Scanner& batch_size(int64_t n);
5722
5724 Scanner& batch_size_bytes(uint64_t bytes);
5725
5727 Scanner& io_buffer_size(uint64_t bytes);
5728
5730 Scanner& batch_readahead(size_t batches);
5731
5733 Scanner& fragment_readahead(size_t fragments);
5734
5736 Scanner& target_parallelism(size_t partitions);
5737
5739 Scanner& scan_in_order(bool ordered = true);
5740
5743 Scanner& use_scalar_index(bool enable = true);
5744
5746 Scanner& strict_batch_size(bool strict_batch_size = true);
5747
5749 Scanner& use_stats(bool use_stats = true);
5750
5752 Scanner& project(std::nullopt_t);
5753
5757 Scanner& project(const std::vector<ProjectionColumn>& columns);
5758
5761
5766 Scanner& order_by(std::nullopt_t);
5767
5768 Scanner& order_by(const std::vector<ColumnOrdering>& orderings);
5769
5773
5779 const std::vector<std::string>& early_except_columns = {});
5780
5782 Scanner& with_row_id(bool enable = true);
5783
5785 Scanner& with_row_address(bool enable = true);
5786
5790 Scanner& include_deleted_rows(bool include_deleted_rows = true);
5791
5797 Scanner& scalar_index_segment(const std::array<uint8_t, 16>& segment_uuid);
5798
5802
5804
5807 Scanner& fragment_ids(const uint64_t* ids, size_t len);
5808
5810 Scanner& fragment_ids(const std::vector<uint64_t>& ids);
5811
5814 Scanner& row_addr_allowlist(const uint64_t* row_ids, size_t len);
5815
5817 Scanner& row_addr_allowlist(const std::vector<uint64_t>& row_ids);
5818
5820 Scanner& row_addr_blocklist(const uint64_t* row_ids, size_t len);
5821
5823 Scanner& row_addr_blocklist(const std::vector<uint64_t>& row_ids);
5824
5827 Scanner& substrait_filter(const uint8_t* bytes, size_t len);
5828
5830 Scanner& substrait_filter(const std::vector<uint8_t>& bytes);
5831
5835 Scanner& substrait_aggregate(const uint8_t* bytes, size_t len);
5836
5838 Scanner& substrait_aggregate(const std::vector<uint8_t>& bytes);
5839
5841 Scanner& additional_sql_filter(const std::string& filter);
5842
5861
5865 Scanner& index_segments(const uint8_t* uuids, size_t len);
5866
5869 Scanner& index_segments(const std::vector<std::array<uint8_t, 16>>& uuids);
5870
5874 void schema(ArrowSchema* out) const;
5875
5877 std::string explain_plan(bool verbose = false) const;
5878
5881 std::string analyze_plan() const;
5882
5886 uint64_t count_rows() const;
5887
5889 std::string analyze_count_plan() const;
5890
5894
5902
5911 void scan_async(LanceCallback callback, void* ctx) const;
5912
5914 Scanner& nearest(const std::string& column, const float* q, size_t dim, uint32_t k);
5915
5918 Scanner& nearest(const std::string& column, std::span<const float> q, uint32_t k);
5919
5921 Scanner& nearest(const std::string& column, const void* q, size_t dim,
5922 LanceDataType dtype, uint32_t k);
5923
5929 Scanner& distance_range(std::optional<float> lower_bound = std::nullopt,
5930 std::optional<float> upper_bound = std::nullopt);
5931
5933 Scanner& nearest_batch(const std::string& column, const void* query_data,
5934 size_t dimension, size_t num_queries,
5935 LanceDataType element_type, uint32_t k);
5936
5938 Scanner& nearest_batch(const std::string& column, const float* query_data,
5939 size_t dimension, size_t num_queries, uint32_t k);
5940
5944 Scanner& nearest_batch(const std::string& column, std::span<const float> queries,
5945 size_t dimension, uint32_t k);
5946
5948 Scanner& nearest_multivector(const std::string& column, const void* query_data,
5949 size_t dimension, size_t num_vectors,
5950 LanceDataType element_type, uint32_t k);
5951
5953 Scanner& nprobes(uint32_t nprobes);
5955 Scanner& minimum_nprobes(uint32_t minimum_nprobes);
5957 Scanner& maximum_nprobes(uint32_t maximum_nprobes);
5960 Scanner& search_effort(double effort);
5962 Scanner& query_parallelism(int32_t parallelism);
5964 Scanner& ef(uint32_t e);
5966 Scanner& use_index(bool enable);
5971 Scanner& fast_search(bool enable = true);
5976 Scanner& prefilter(bool enable);
5977
5981 Scanner& full_text_search(const std::string& query,
5982 const std::vector<std::string>& columns = {},
5983 uint32_t max_fuzzy_distance = 0);
5984
5988
5992 Scanner& minhash_search(const std::string& column, const std::string& text);
5993
5997
5999 Scanner& fts_index_segments(const uint8_t* segment_uuids, size_t segment_count);
6000
6002 const std::vector<std::array<uint8_t, 16>>& segment_uuids);
6003
6006};
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038// ─── Batch ───────────────────────────────────────────────────────────────────
6039
6040class Batch {
6042
6043public:
6044 explicit Batch(LanceBatch* b);
6045
6049 static Batch from_arrow(ArrowArray* array, const ArrowSchema* schema);
6050
6052 void to_arrow(ArrowArray* out_array, ArrowSchema* out_schema) const;
6053
6054 const LanceBatch* c_handle() const;
6055};
6056
6063 handle_;
6064
6065public:
6067
6070 default;
6073
6075 void write_batch(const Batch& batch);
6076
6079 std::optional<DataOverlayGroup> finish();
6080
6082 void abort();
6083
6084 const LanceFragmentOverlayWriter* c_handle() const;
6085};
6086
6087
6088
6089// ─── Raw file ownership and snapshots ───────────────────────────────────────
6090
6093 ArrowSchema schema_{};
6094 bool active_ = false;
6095
6096public:
6097 ArrowSchemaOwner() noexcept = default;
6098 explicit ArrowSchemaOwner(ArrowSchema schema) noexcept;
6100
6102 ArrowSchemaOwner& operator=(const ArrowSchemaOwner&) = delete;
6103
6105
6106 ArrowSchemaOwner& operator=(ArrowSchemaOwner&& other) noexcept {
6107 if (this != &other) {
6108 reset();
6109 schema_ = other.schema_;
6110 active_ = other.active_;
6111 other.schema_ = {};
6112 other.active_ = false;
6113 }
6114 return *this;
6115 }
6116
6117 void reset() noexcept {
6118 if (active_ && schema_.release) schema_.release(&schema_);
6119 schema_ = {};
6120 active_ = false;
6121 }
6122
6123 ArrowSchema* get() noexcept { return &schema_; }
6124 const ArrowSchema* get() const noexcept { return &schema_; }
6125 explicit operator bool() const noexcept { return active_; }
6126};
6127
6128enum class FileCacheMode : int32_t {
6131};
6132
6140
6147
6149 uint64_t io_buffer_size_bytes = 0;
6151};
6152
6154 std::optional<std::vector<std::string>> columns;
6155 FileCacheMode cache_mode = FileCacheMode::None;
6156 std::optional<uint64_t> read_chunk_size;
6157 std::optional<uint64_t> batch_size_bytes;
6158 std::optional<bool> cache_repetition_index;
6159 std::optional<bool> validate_on_decode;
6160 std::optional<bool> inline_scheduling;
6161};
6162
6164 std::optional<uint64_t> data_cache_bytes;
6165 std::optional<uint64_t> max_page_bytes;
6166 std::optional<bool> keep_original_array;
6167 std::optional<std::string> version;
6168};
6169
6171 uint64_t num_rows = 0;
6172 uint64_t size_bytes = 0;
6173};
6174
6176 FileFormatVersion format_version = FileFormatVersion::V1;
6177 uint16_t major_version = 0;
6178 uint16_t minor_version = 0;
6179 uint64_t num_rows = 0;
6180 uint64_t num_data_bytes = 0;
6181 uint64_t num_column_metadata_bytes = 0;
6182 uint64_t num_global_buffer_bytes = 0;
6183 uint64_t num_footer_bytes = 0;
6184 uint64_t file_size_bytes = 0;
6185 std::size_t num_columns = 0;
6186 std::size_t num_physical_columns = 0;
6187 std::size_t num_global_buffers = 0;
6188};
6189
6191 uint64_t position = 0;
6192 uint64_t size = 0;
6193};
6194
6196 FileEncodingKind kind = FileEncodingKind::Absent;
6197 uint64_t buffer_location = 0;
6198 uint64_t buffer_length = 0;
6199 std::vector<uint8_t> direct_bytes;
6200};
6201
6203 std::vector<FileBufferDescriptor> buffers;
6204 uint64_t num_rows = 0;
6205 uint64_t priority = 0;
6208};
6209
6211 std::vector<FileBufferDescriptor> column_buffers;
6212 std::vector<FilePageMetadata> pages;
6214};
6215
6217 std::size_t num_pages = 0;
6218 uint64_t size_bytes = 0;
6219};
6220
6222 uint64_t block_size = 0;
6223 uint64_t max_iop_size = 0;
6224 uint64_t io_parallelism = 0;
6225 bool is_local = false;
6226 bool is_cloud = false;
6227 bool prefers_lite_scheduler = false;
6228};
6229
6230namespace file_detail {
6231
6233 const LanceBufferDescriptor& descriptor);
6234
6236 const LanceEncodingDescriptor& descriptor);
6237
6239 const FileReaderOptions& options,
6240 std::vector<const char*>& columns);
6241
6243 const FileWriterOptions& options);
6244
6245} // namespace file_detail
6246
6249
6250public:
6251 explicit FileMetadata(LanceFileMetadata* metadata);
6252
6254
6256
6257 std::vector<FileBufferDescriptor> global_buffers() const;
6258
6259 std::vector<FileColumnMetadata> columns() const;
6260};
6261
6264
6265public:
6267
6268 std::vector<FileColumnStatistics> columns() const;
6269};
6270
6273
6274public:
6275 explicit ByteBuffer(LanceByteBuffer* buffer);
6276
6277 std::vector<uint8_t> bytes() const;
6278};
6279
6282
6283public:
6284 explicit PathList(LancePathList* list);
6285
6286 std::vector<std::string> paths() const;
6287};
6288
6291
6292public:
6294
6295 std::vector<std::string> common_prefixes() const;
6296
6297 std::vector<std::string> objects() const;
6298};
6299
6300class FileReader;
6301class FileWriter;
6302
6305
6306public:
6308 const std::string& base_uri,
6309 const StorageOptionsAccessor* storage_options = nullptr,
6310 const Session* session = nullptr,
6311 std::optional<FileSchedulerConfig> scheduler_config = std::nullopt);
6312
6313 FileSession(FileSession&&) noexcept = default;
6314 FileSession& operator=(FileSession&&) noexcept = default;
6315 FileSession(const FileSession&) = delete;
6316 FileSession& operator=(const FileSession&) = delete;
6317
6318 void reset() noexcept;
6319 explicit operator bool() const noexcept;
6320
6321 std::string base_path() const;
6322
6323 FileReader open_reader(
6324 const std::string& relative_path,
6325 const FileReaderOptions& options = {}) const;
6327 const std::string& relative_path,
6328 const ArrowSchema* schema,
6329 const FileWriterOptions& options = {}) const;
6330
6332 const std::string& data_file_path,
6333 uint32_t blob_id) const;
6334
6336 const std::string& data_file_path,
6337 uint32_t blob_id) const;
6338
6339 bool contains(const std::string& relative_path) const;
6340
6341 PathList list(std::optional<std::string> relative_path = std::nullopt) const;
6342
6344 std::optional<std::string> relative_path = std::nullopt) const;
6345
6347 const std::string& relative_path,
6348 uint64_t offset,
6349 uint64_t length) const;
6350
6351 void delete_file(const std::string& relative_path) const;
6352
6354 const std::string& local_path,
6355 const std::string& relative_remote_path) const;
6356
6358 const std::string& relative_remote_path,
6359 const std::string& local_path) const;
6360
6362
6364
6366
6368};
6369
6372
6373public:
6374 explicit FileReader(LanceFileReader* reader);
6375 FileReader(FileReader&&) noexcept = default;
6376 FileReader& operator=(FileReader&&) noexcept = default;
6377 FileReader(const FileReader&) = delete;
6378 FileReader& operator=(const FileReader&) = delete;
6379
6380 void reset() noexcept;
6381 explicit operator bool() const noexcept;
6382
6383 uint64_t num_rows() const;
6384
6385 FileMetadata metadata() const;
6386
6387 FileStatistics statistics() const;
6388
6389 ByteBuffer read_global_buffer(uint32_t index) const;
6390
6393 ArrowStream read_all(
6394 uint32_t batch_size = 1024,
6395 uint32_t batch_readahead = 4) const;
6396
6399 ArrowStream read_range(
6400 uint64_t offset,
6401 uint64_t num_rows,
6402 uint32_t batch_size = 1024,
6403 uint32_t batch_readahead = 4) const;
6404
6407 ArrowStream read_indices(
6408 const std::vector<uint32_t>& indices,
6409 uint32_t batch_size = 1024,
6410 uint32_t batch_readahead = 4) const;
6411
6412 LanceScanStats io_stats() const;
6413};
6414
6417
6418public:
6419 explicit FileWriter(LanceFileWriter* writer);
6420 FileWriter(FileWriter&&) noexcept = default;
6421 FileWriter& operator=(FileWriter&&) noexcept = default;
6422 FileWriter(const FileWriter&) = delete;
6423 FileWriter& operator=(const FileWriter&) = delete;
6424
6425 void reset() noexcept;
6426 explicit operator bool() const noexcept;
6427
6428 void write_batch(const Batch& batch);
6429
6430 void add_schema_metadata(
6431 const std::string& key,
6432 const std::string& value);
6433
6434 uint32_t add_global_buffer(const std::vector<uint8_t>& bytes);
6435
6437
6438 void abort();
6439};
6440
6441
6442
6443
6444
6445
6446// ─── Fragment writer (free functions) ────────────────────────────────────────
6447
6448
6462void write_fragments(
6463 const std::string& uri,
6464 const ArrowSchema* schema,
6465 ArrowArrayStream* stream,
6466 const std::vector<std::pair<std::string, std::string>>& storage_opts = {});
6467
6468// ─── Native namespaces ───────────────────────────────────────────────────────
6469
6470namespace namespace_detail {
6471
6472std::string json_escape(std::string_view value);
6473
6474std::string json_string(std::string_view value);
6475
6476std::string json_string_array(const std::vector<std::string>& values);
6477
6479 const std::vector<std::pair<std::string, std::string>>& entries);
6480
6482
6483void set_owned_string(LanceOwnedString* out, std::string value);
6484
6485void set_callback_error(
6486 LanceCallbackError* error, int32_t code, const std::string& message) noexcept;
6487
6488} // namespace namespace_detail
6489
6492class NamespaceError : public Error {
6493public:
6495 uint32_t native_code;
6496 std::string native_message;
6497
6499 LanceErrorCode code_value,
6500 std::string message_value,
6501 uint32_t native_code_value,
6502 std::string native_message_value);
6503};
6504
6508 std::optional<std::string> json_;
6509 std::vector<uint8_t> bytes_;
6510
6511 friend class Namespace;
6512
6513 NamespaceResult(std::optional<std::string> json, std::vector<uint8_t> bytes);
6514
6515public:
6516 NamespaceResult() = default;
6517 NamespaceResult(NamespaceResult&&) noexcept = default;
6518 NamespaceResult& operator=(NamespaceResult&&) noexcept = default;
6520 NamespaceResult& operator=(const NamespaceResult&) = delete;
6521
6522 bool has_json() const noexcept;
6523 const std::optional<std::string>& json() const noexcept;
6524 const std::vector<uint8_t>& bytes() const noexcept;
6525};
6526
6531public:
6532 using Callback = std::function<std::map<std::string, std::string>(
6533 const std::string&, const std::string&)>;
6534
6535private:
6536 Callback callback_;
6537
6538public:
6540 const Callback& callback() const noexcept;
6541};
6542
6546
6547 struct ContextProviderContext {
6548 std::function<std::map<std::string, std::string>(
6549 const std::string&, const std::string&)> callback;
6550 };
6551
6552 struct CustomClientContext {
6553 std::function<std::string(const std::string&)> describe_table;
6554 std::function<std::string(const std::string&)> describe_table_version;
6555 std::function<std::string(const std::string&)> create_table_version;
6556 std::function<std::string(const std::string&)> list_table_versions;
6557 };
6558
6559 struct CustomDispatchContext {
6560 std::function<std::string(const std::string&, const std::string&)> dispatch;
6561 };
6562
6563 static void context_provider_release(void* ctx) noexcept;
6564
6565 static void custom_client_release(void* ctx) noexcept;
6566
6567 static void custom_dispatch_release(void* ctx) noexcept;
6568
6569 static int32_t context_provider_call(
6570 void* raw_ctx,
6571 const char* operation,
6572 const char* object_id,
6573 LanceOwnedString* out_json,
6574 LanceCallbackError* out_error) noexcept;
6575
6576 template <typename Callback>
6577 static int32_t invoke_custom(
6578 Callback&& callback,
6579 const char* request_json,
6580 LanceOwnedString* out_json,
6581 LanceCallbackError* out_error) noexcept {
6582 try {
6583 std::string response = callback(request_json ? request_json : "{}");
6584 namespace_detail::set_owned_string(out_json, std::move(response));
6585 return 0;
6586 } catch (const lance::Error& error) {
6587 namespace_detail::set_callback_error(
6588 out_error, static_cast<int32_t>(error.code), error.what());
6589 } catch (const std::exception& error) {
6590 namespace_detail::set_callback_error(
6591 out_error, static_cast<int32_t>(LANCE_ERR_INTERNAL), error.what());
6592 } catch (...) {
6593 namespace_detail::set_callback_error(
6594 out_error,
6595 static_cast<int32_t>(LANCE_ERR_INTERNAL),
6596 "unknown C++ exception in namespace callback");
6597 }
6598 return 1;
6599 }
6600
6601 static int32_t custom_describe_table(
6602 void* ctx, const char* req, LanceOwnedString* out, LanceCallbackError* err) noexcept;
6603 static int32_t custom_describe_table_version(
6604 void* ctx, const char* req, LanceOwnedString* out, LanceCallbackError* err) noexcept;
6605 static int32_t custom_create_table_version(
6606 void* ctx, const char* req, LanceOwnedString* out, LanceCallbackError* err) noexcept;
6607 static int32_t custom_list_table_versions(
6608 void* ctx, const char* req, LanceOwnedString* out, LanceCallbackError* err) noexcept;
6609 static int32_t custom_dispatch_call(
6610 void* ctx,
6611 const char* operation,
6612 const char* req,
6613 LanceOwnedString* out,
6614 LanceCallbackError* err) noexcept;
6615
6616 static LanceNamespaceContextProviderSpec make_context_spec(
6617 const DynamicContextProvider* provider);
6618
6619 explicit Namespace(LanceNamespace* handle);
6620
6621public:
6626 std::function<std::string(const std::string&)> describe_table;
6627 std::function<std::string(const std::string&)> describe_table_version;
6628 std::function<std::string(const std::string&)> create_table_version;
6629 std::function<std::string(const std::string&)> list_table_versions;
6631 std::string namespace_id;
6632 };
6633
6639 std::function<std::string(const std::string&, const std::string&)> dispatch;
6641 std::string namespace_id;
6642 };
6643
6644 Namespace(Namespace&&) noexcept = default;
6645 Namespace& operator=(Namespace&&) noexcept = default;
6646 Namespace(const Namespace&) = delete;
6647 Namespace& operator=(const Namespace&) = delete;
6648
6649 static Namespace directory(
6650 const std::vector<std::pair<std::string, std::string>>& properties = {},
6651 const Session* session = nullptr,
6652 const DynamicContextProvider* context_provider = nullptr);
6653
6655 const std::vector<std::pair<std::string, std::string>>& properties,
6656 const DynamicContextProvider* context_provider = nullptr);
6657
6659 const std::string& impl_name,
6660 const std::vector<std::pair<std::string, std::string>>& properties = {},
6661 const Session* session = nullptr,
6662 const DynamicContextProvider* context_provider = nullptr);
6663
6664 static Namespace custom(const CustomClientSpec& spec);
6665
6667
6668 std::string id() const;
6669
6670 std::string ops_metrics_json() const;
6671
6673
6675 const std::string& operation,
6676 const std::string& request_json = "{}",
6677 const uint8_t* request_bytes = nullptr,
6678 size_t request_bytes_len = 0) const;
6679
6681 const std::string& operation,
6682 const std::string& request_json,
6683 const std::vector<uint8_t>& request_bytes) const;
6684
6685 const LanceNamespace* c_handle() const noexcept;
6686};
6687
6688
6689
6693 uint16_t port_ = 0;
6694
6695 explicit RestAdapter(LanceRestAdapter* raw);
6696
6697public:
6698 RestAdapter(RestAdapter&& other) noexcept;
6699 RestAdapter& operator=(RestAdapter&& other) noexcept {
6700 if (this != &other) {
6701 handle_ = std::move(other.handle_);
6702 port_ = other.port_;
6703 other.port_ = 0;
6704 }
6705 return *this;
6706 }
6707 RestAdapter(const RestAdapter&) = delete;
6709
6711 const Namespace& backend,
6712 const std::string& host = "127.0.0.1",
6713 uint16_t port = 0);
6714
6715 uint16_t port() const noexcept;
6716
6717 void shutdown();
6718};
6719
6720
6721
6722
6723
6724
6725
6726
6727// ─── MemWAL out-of-line definitions ──────────────────────────────────────────
6728
6730struct Table {
6732 std::vector<Batch> batches;
6733};
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778// ─── Native update and rewrite value definitions ────────────────────────────
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832} // namespace lance
Move-only owner of an Arrow C Data Interface schema.
const ArrowSchema * get() const noexcept
ArrowSchema * get() noexcept
ArrowSchemaOwner() noexcept=default
ArrowStream() noexcept=default
ArrowArrayStream * get() noexcept
ArrowArrayStream * operator->() noexcept
const ArrowArrayStream * get() const noexcept
void reset() noexcept
const ArrowArrayStream * operator->() const noexcept
const LanceBatch * c_handle() const
static Batch from_arrow(ArrowArray *array, const ArrowSchema *schema)
Batch(LanceBatch *b)
void to_arrow(ArrowArray *out_array, ArrowSchema *out_schema) const
Export the complete record-batch schema and top-level struct array.
void append_packed(uint32_t blob_id, uint64_t offset, uint64_t length)
void finish(ArrowArray *out_array, ArrowSchema *out_schema)
void push_external(const std::string &uri, std::optional< BlobRange > range=std::nullopt)
BlobDescriptorArrayBuilder(const std::string &column)
void append_inline(const uint8_t *data, size_t len)
void append_inline(const std::vector< uint8_t > &data)
void extend_packed(uint32_t blob_id, const std::vector< BlobRange > &ranges)
void append_dedicated(uint32_t blob_id, uint64_t length)
void append_managed(const std::string &uri, uint64_t offset, uint64_t length, std::optional< uint32_t > base_id=std::nullopt)
void append_packed(uint32_t blob_id, const BlobRange &range)
void field(ArrowSchema *out) const
Export the prepared field. out is caller-owned and must be released.
void append_external(uint32_t base_id, const std::string &uri, uint64_t offset, uint64_t length)
std::vector< uint8_t > read_range(uint64_t offset, size_t len) const
uint64_t tell() const
Current cursor position, in bytes from the start of the blob.
std::vector< std::vector< uint8_t > > read_ranges(const std::vector< BlobRange > &ranges) const
bool closed() const
Native closed state.
size_t read_into(uint8_t *dst, size_t len)
void seek(uint64_t pos)
std::vector< uint8_t > read_up_to(size_t len)
void set_buffer_size(size_t buffer_size)
Set the native sequential read-ahead size. Zero disables read-ahead.
std::vector< uint8_t > read()
Read from the cursor to the end (the whole blob when the cursor is 0).
BlobFile(LanceBlobFile *blob)
Adopt a handle from the C API; closed on destruction.
uint64_t size() const
Size of the blob in bytes. Independent of the cursor.
std::vector< uint8_t > bytes() const
ByteBuffer(LanceByteBuffer *buffer)
virtual ~CommitLease() noexcept=default
std::function< std::unique_ptr< CommitLease >(uint64_t)> Acquire
CommitLock(Acquire acquire)
CommitLock(CommitLock &&) noexcept
Presence-preserving owner of native CompactionOptions.
CompactionOptions(LanceCompactionOptionsV2 *options)
CompactionOptions(CompactionOptions &&) noexcept=default
Owned native compaction plan.
CompactionPlan(LanceCompactionPlan *plan)
CompactionPlan(CompactionPlan &&) noexcept=default
Owned snapshot of one native compaction task.
CompactionTask(LanceCompactionTask *task)
CompactionTask(CompactionTask &&) noexcept=default
Owned native DataFile metadata snapshot. Move-only.
DataFile(DataFile &&) noexcept=default
DataFile(LanceDataFile *file)
DataOverlayFile(DataOverlayFile &&) noexcept=default
DataOverlayFile(LanceDataOverlayFile *file)
DataOverlayFile(const DataFile &data_file, OverlayCoverageKind coverage_kind, const std::vector< std::vector< uint8_t > > &bitmaps, uint64_t committed_version=0)
Owned native DataOverlayGroup snapshot. Move-only.
DataOverlayGroup(LanceDataOverlayGroup *group)
DataOverlayGroup(DataOverlayGroup &&) noexcept=default
DataOverlayGroup(uint64_t fragment_id, const std::vector< const DataOverlayFile * > &overlays)
Construct a group by cloning the given overlay values in order.
Owned native DataReplacementGroup snapshot. Move-only.
DataReplacementGroup(DataReplacementGroup &&) noexcept=default
DataReplacementGroup(LanceDataReplacementGroup *group)
DataReplacementGroup(uint64_t fragment_id, const DataFile &file)
Construct a group by cloning file into native metadata.
DatasetDeltaBuilder(LanceDatasetDeltaBuilder *builder)
DatasetDeltaBuilder(DatasetDeltaBuilder &&) noexcept=default
DatasetDelta(LanceDatasetDelta *delta)
DatasetDelta(DatasetDelta &&) noexcept=default
std::vector< TagInfo > tags() const
Snapshot all tags. Entry order is unspecified.
void drop_index(const std::string &name)
Drop an index by name.
ArrowStream all_files_stream() const
uint64_t num_small_files(size_t max_rows_per_group) const
std::optional< Transaction > read_transaction() const
ArrowStream read_blobs(const std::string &column, BlobRowSelector selector, const std::vector< uint64_t > &rows, const BlobReadOptions &options={}) const
TagInfo get_tag(const std::string &name) const
Fetch one tag by name.
void add_columns_stream(ArrowArrayStream *stream, uint64_t batch_size=0)
IndexSegmentBuilder new_scalar_index_segment_builder_with_options(const std::string &column, LanceScalarIndexType index_type, const ScalarIndexOptions &options, const std::string &index_name="", const std::string &params_json="", const LanceIndexSegmentBuildOptions *build_options=nullptr) const
Create a scalar segment builder with the additive native train control.
static Dataset open_namespace(const Namespace &ns, const std::vector< std::string > &table_id, const std::vector< std::pair< std::string, std::string > > &storage_opts={}, uint64_t version=0, const Session *session=nullptr)
ArrowStream tracked_files_stream(std::optional< uint64_t > min_version=std::nullopt, TrackedFilesProgressCallback progress={}) const
void truncate_table()
Delete every row through native Dataset::truncate_table.
SqlQueryBuilder sql(const std::string &sql) const
Fragment open_fragment(uint64_t fragment_id) const
void create_vector_index(const std::string &column, const LanceVectorIndexParams &params, const std::string &name="", bool replace=false)
Create a vector index on a column.
bool has_stable_row_ids() const
IndexModel train_pq_model(const std::string &column, uint32_t num_sub_vectors, uint32_t num_bits, LanceMetricType metric, IndexModel &ivf_centroids, const std::vector< uint32_t > &fragment_ids={}) const
DatasetDeltaBuilder delta() const
CompactionPlan plan_compaction(const CompactionOptions *options=nullptr) const
Plan native compaction. NULL options select dataset config.
void delete_tag(const std::string &name) const
Delete a tag.
static Dataset write(const std::string &uri, ArrowArrayStream *stream, WriteMode mode, const std::vector< std::pair< std::string, std::string > > &storage_opts={})
void create_tag(const std::string &name, const Ref &reference) const
Create a tag from a native ref.
static Dataset commit_namespace_uri(const Namespace &ns, const std::vector< std::string > &table_id, const std::string &uri, const Transaction &transaction, const CommitOptions &options={}, const std::vector< std::pair< std::string, std::string > > &storage_opts={}, const Session *session=nullptr)
std::string index_segments_json() const
void validate() const
uint64_t version() const
Version of this dataset snapshot.
void take_rows(const uint64_t *row_ids, size_t num_row_ids, const std::vector< std::string > &columns, ArrowArrayStream *out) const
void add_bases(const std::vector< BasePath > &bases, const AddBasesOptions &options={})
void prewarm_index_with_options(const std::string &index_name, const IndexPrewarmOptions &options={}) const
Prewarm selected segments with native FTS position controls.
std::map< std::string, std::string > config() const
void replace_tag_metadata(const std::string &name, const std::vector< std::pair< std::string, std::string > > &metadata) const
ArrowStream take_rows(std::span< const uint64_t > row_ids) const
void commit_index_segments(const std::string &index_name, const std::string &column, const std::vector< std::vector< uint8_t > > &segment_metadata)
std::string update_config_json(const std::vector< ConfigUpdate > &updates, MetadataUpdateMode mode=MetadataUpdateMode::Merge)
void take(const uint64_t *indices, size_t num_indices, const std::vector< std::string > &columns, ArrowArrayStream *out) const
LanceMergeInsertResult upsert(const std::vector< std::string > &on_columns, ArrowArrayStream *source)
Convenience: classic upsert (when_matched=UpdateAll, when_not_matched=InsertAll).
OptimizeIndicesPlan plan_optimize_indices(const OptimizeIndicesOptions *options=nullptr) const
Plan the native distributed index optimization workflow.
std::string uri() const
void force_delete_branch(const std::string &branch_name) const
void update_tag(const std::string &name, const Ref &reference) const
Update an existing tag to a native ref. Metadata is preserved natively.
std::string metadata_json() const
void take_rows(std::span< const uint64_t > row_ids, ArrowArrayStream *out) const
void take_rows(const uint64_t *row_ids, size_t num_row_ids, ArrowArrayStream *out) const
void add_columns_sql(const std::vector< SqlColumn > &columns, uint64_t batch_size=0)
Scanner scan(const std::vector< std::string > &columns, const std::optional< std::string > &filter=std::nullopt) const
VersionDetails current_version() const
void commit_optimize_indices(const std::vector< IndexSegmentResult > &results, const OptimizeIndicesOptions *options=nullptr)
Commit merged native index segments.
static Dataset write_with_params_and_accessor(const std::string &uri, ArrowArrayStream *stream, WriteMode mode, const WriteParams &params, const StorageOptionsAccessor &storage_options_accessor)
Dataset restore(uint64_t version) const
void update_config(const std::vector< ConfigUpdate > &updates)
static Dataset commit_with_accessor(const std::string &uri, const Transaction &transaction, const StorageOptionsAccessor &storage_options_accessor, const CommitOptions &options={}, const Session *session=nullptr)
uint64_t update(const std::string &predicate, const std::vector< std::pair< std::string, std::string > > &updates)
static Dataset commit_with_commit_lock(const std::string &uri, const Transaction &transaction, const CommitOptions &options, const StorageOptionsAccessor *storage_accessor, const Session *session, const CommitLock *commit_lock)
LanceCompactionMetrics commit_compaction(const std::vector< RewriteResult > &results, const CompactionOptions *options=nullptr)
Commit native rewrite results. NULL options select native defaults.
std::optional< Transaction > read_transaction_by_version(uint64_t version) const
Dataset checkout(const Ref &reference) const
Check out a native ref as an independent dataset snapshot.
static Transaction write_uncommitted(const std::string &uri, ArrowArrayStream *stream, WriteMode mode, const UncommittedWriteOptions &options={}, const std::vector< std::pair< std::string, std::string > > &storage_opts={}, const Session *session=nullptr)
void create_vector_index_with_progress(const std::string &column, const LanceVectorIndexParams &params, LanceIndexBuildProgressCallback callback, void *callback_ctx, const std::string &name="", bool replace=false)
void create_vector_index_with_options(const std::string &column, const VectorIndexOptions &options, const std::string &name="", bool replace=false)
LanceCompactionMetrics compact_files(const LanceCompactionOptions *options=nullptr)
std::string list_indices_json() const
JSON array describing all user indexes.
FtsQueryContext prepare_fts_match_query(const std::string &column, const std::string &query, FtsMatchOperator match_operator=FtsMatchOperator::Or, uint32_t max_fuzzy_distance=0, FtsCoverageMode coverage_mode=FtsCoverageMode::Strict) const
std::string get_branch_json(const std::string &branch_name) const
JSON object for one native BranchContents value.
uint64_t count_deleted_rows() const
std::vector< uint64_t > fragment_ids() const
Get all fragment IDs.
std::string base_paths_json() const
void add_columns_nulls(const ArrowSchema *schema)
void replace_branch_metadata(const std::string &branch_name, const std::vector< std::pair< std::string, std::string > > &metadata) const
void optimize_indices(const OptimizeIndicesOptions *options=nullptr)
Run native single-process index optimization. NULL uses native defaults.
static Dataset write_with_options_with_commit_lock(const std::string &uri, ArrowArrayStream *stream, WriteMode mode, const WriteOptions &options, const StorageOptionsAccessor *storage_accessor, const Session *session, const CommitLock *commit_lock)
uint64_t fragment_count() const
Number of fragments in the dataset.
static Dataset write_with_options_and_accessor(const std::string &uri, ArrowArrayStream *stream, WriteMode mode, const WriteOptions &options, const StorageOptionsAccessor &storage_options_accessor)
static Transaction write_uncommitted_with_native_options(const std::string &uri, ArrowArrayStream *stream, WriteMode mode, const NativeWriteOptions &options)
IndexSegmentBuilder new_vector_index_segment_builder_with_options(const std::string &column, const VectorIndexOptions &options, const std::string &index_name="", std::optional< std::vector< uint32_t > > fragment_ids=std::nullopt, const std::array< uint8_t, 16 > *index_uuid=nullptr) const
void alter_columns(const std::vector< ColumnAlteration > &alterations)
ArrowStream take_rows(const uint64_t *row_ids, size_t num_row_ids, const std::vector< std::string > &columns) const
void merge_index_metadata(const std::array< uint8_t, 16 > &index_uuid, const std::string &index_type, std::optional< size_t > batch_readhead=std::nullopt, LanceIndexBuildProgressCallback callback=nullptr, void *callback_ctx=nullptr) const
Merge distributed Inverted index files. Files only; does not commit.
std::vector< VersionDetails > version_details() const
ArrowStream take(std::span< const uint64_t > indices, const std::vector< std::string > &columns) const
static BatchCommitResult commit_batch_with_commit_lock(const std::string &uri, const std::vector< std::reference_wrapper< const Transaction > > &transactions, const CommitOptions &options, const StorageOptionsAccessor *storage_accessor, const Session *session, const CommitLock *commit_lock)
static Dataset commit(const std::string &uri, const Transaction &transaction, const CommitOptions &options={}, const std::vector< std::pair< std::string, std::string > > &storage_opts={}, const Session *session=nullptr)
Scanner scan(std::nullopt_t, const std::optional< std::string > &filter=std::nullopt) const
Create a Scanner builder for all columns, with an optional SQL filter.
void merge(ArrowArrayStream *source, const std::string &left_on, const std::string &right_on)
void migrate_manifest_paths_v2()
Migrate manifest paths to native v2 naming through core.
IndexModel train_pq_model_with_options(const std::string &column, uint32_t num_sub_vectors, uint32_t num_bits, LanceMetricType metric, IndexModel &ivf_centroids, const IndexTrainerOptions &options={}, const std::vector< uint32_t > &fragment_ids={}) const
Train a PQ codebook with native trainer controls.
LanceObjectStoreIoStats io_stats_incremental() const
LanceSchema native_schema() const
Clone the current snapshot schema as an owned native value.
IndexModel train_ivf_model(const std::string &column, uint32_t num_partitions, LanceMetricType metric, const std::vector< uint32_t > &fragment_ids={}) const
Train shared IVF centroids as an Arrow C Data Interface array/schema.
static BatchCommitResult commit_batch(const std::string &uri, const std::vector< std::reference_wrapper< const Transaction > > &transactions, const CommitOptions &options={}, const std::vector< std::pair< std::string, std::string > > &storage_opts={}, const Session *session=nullptr)
int32_t resolve_field_id(const FieldReference &field) const
IndexModel train_ivf_model_with_options(const std::string &column, uint32_t num_partitions, LanceMetricType metric, const IndexTrainerOptions &options={}, const std::vector< uint32_t > &fragment_ids={}) const
Train IVF centroids with native sample-rate and iteration controls.
CleanupExplanation explain_cleanup(const CleanupPolicy &policy, const CleanupOperationOptions &operation={}) const
const LanceDataset * c_handle() const
Access the underlying C handle (does not transfer ownership).
LanceObjectStoreIoStats io_stats_snapshot() const
IndexSegmentBuilder new_scalar_index_segment_builder(const std::string &column, LanceScalarIndexType index_type, const std::string &index_name="", const std::string &params_json="", const LanceIndexSegmentBuildOptions *options=nullptr) const
void create_scalar_index(const std::string &column, LanceScalarIndexType index_type, const std::string &name="", const std::string &params_json="", bool replace=false)
Dataset checkout_branch(const std::string &branch_name) const
ArrowStream take_rows(std::span< const uint64_t > row_ids, const std::vector< std::string > &columns) const
ArrowStream read_blob_ranges(const std::string &column, BlobRowSelector selector, const std::vector< BlobRangeRequest > &requests, const BlobReadOptions &options={}) const
std::vector< uint64_t > version_refs() const
Lightweight attached-version refs ordered by version id.
void merge(ArrowArrayStream *source, const std::string &left_on)
FtsQueryContext prepare_fts_phrase_query(const std::string &column, const std::string &query, int32_t slop=0, FtsCoverageMode coverage_mode=FtsCoverageMode::Strict) const
void create_vector_index_with_options_and_progress(const std::string &column, const VectorIndexOptions &options, LanceIndexBuildProgressCallback callback, void *callback_ctx, const std::string &name="", bool replace=false)
std::string branches_json() const
static BatchCommitResult commit_batch_with_accessor(const std::string &uri, const std::vector< std::reference_wrapper< const Transaction > > &transactions, const StorageOptionsAccessor &storage_options_accessor, const CommitOptions &options={}, const Session *session=nullptr)
std::vector< std::optional< BlobFile > > take_blobs_by_indices(const uint64_t *indices, size_t num_indices, const std::string &column) const
FtsQueryContext prepare_fts_query(const std::string &column, const std::string &query, uint32_t max_fuzzy_distance=0, FtsCoverageMode coverage_mode=FtsCoverageMode::Strict) const
Compatibility wrapper for an OR Match query.
std::optional< MemWalIndexDetails > mem_wal_index_details() const
ArrowStream take(const uint64_t *indices, size_t num_indices) const
std::vector< VersionInfo > versions() const
ArrowStream read_index_partition(const std::string &index_name, uint64_t partition_id, bool with_vector=false) const
Read one logical IVF partition; the stream owns its native snapshot.
std::vector< int32_t > field_ids() const
std::string update_schema_metadata_json(const std::vector< std::pair< std::string, std::optional< std::string > > > &values, MetadataUpdateMode mode=MetadataUpdateMode::Merge)
void create_scalar_index_with_options_and_progress(const std::string &column, LanceScalarIndexType index_type, const ScalarIndexOptions &options, LanceIndexBuildProgressCallback callback, void *callback_ctx, const std::string &index_name="", const std::string &params_json="", bool replace=false)
LanceMergeInsertResult merge_insert(const std::vector< std::string > &on_columns, ArrowArrayStream *source, const LanceMergeInsertParams *params=nullptr)
std::vector< std::array< uint8_t, 16 > > index_segments(const std::string &index_name) const
std::vector< FieldStatistics > calculate_data_stats() const
DataFile create_data_file(const std::string &path, std::optional< uint32_t > base_id=std::nullopt) const
void update_field_metadata(const std::vector< FieldMetadataUpdate > &updates)
std::vector< std::optional< BlobFile > > take_blobs_by_addresses(const uint64_t *row_addresses, size_t num_row_addresses, const std::string &column) const
void take_rows(std::span< const uint64_t > row_ids, const std::vector< std::string > &columns, ArrowArrayStream *out) const
std::string data_storage_version() const
uint64_t count_rows(const std::string &filter) const
void create_scalar_index_with_progress(const std::string &column, LanceScalarIndexType index_type, LanceIndexBuildProgressCallback callback, void *callback_ctx, const std::string &name="", const std::string &params_json="", bool replace=false)
uint64_t count_rows() const
Number of rows in the dataset.
void schema(ArrowSchema *out) const
Export the schema as an Arrow C Data Interface struct.
LanceMergeInsertResult merge_insert_with_compaction(const std::vector< std::string > &on_columns, ArrowArrayStream *source, const LanceMergeInsertParams *params, const std::vector< CompactedSsTable > &compacted_sstables)
ArrowStream take_rows(const uint64_t *row_ids, size_t num_row_ids) const
uint64_t index_count() const
Number of user indexes (excludes system indexes).
static Dataset open_with_session(const Session &session, const std::string &uri, const std::vector< std::pair< std::string, std::string > > &storage_opts={}, uint64_t version=0)
std::optional< IndexModel > centroids(const std::string &index_name) const
Centroids from get_ivf_model(index_name), or nullopt when absent.
LanceCompactionMetrics compact_files_with_options(const CompactionOptions *options=nullptr)
static Dataset open_with_options(const std::string &uri, const DatasetOpenOptions &options={}, const Session *session=nullptr)
uint64_t index_segment_count(const std::string &index_name) const
*static Dataset open(const std::string &uri, const std::vector< std::pair< std::string, std::string > > &storage_opts={}, uint64_t version=0)
std::vector< std::optional< BlobFile > > take_blobs(const uint64_t *row_ids, size_t num_row_ids, const std::string &column) const
static Dataset write_with_native_options(const std::string &uri, ArrowArrayStream *stream, WriteMode mode, const NativeWriteOptions &options)
void 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)
Dataset clone_handle() const
static Dataset open_with_commit_lock(const std::string &uri, const StorageOptionsAccessor *storage_accessor, uint64_t version, const Session *session, const CommitLock *commit_lock)
ArrowStream take(const uint64_t *indices, size_t num_indices, const std::vector< std::string > &columns) const
Dataset create_branch(const std::string &branch_name, const Ref &reference, std::optional< std::vector< std::pair< std::string, std::string > > > storage_opts=std::nullopt) const
Scanner scan() const
Create a Scanner builder for this dataset.
void prewarm_index(const std::string &index_name) const
Dataset shallow_clone(const std::string &target_path, const Ref *reference=nullptr, const StorageOptionsAccessor *storage_options=nullptr) const
Dataset deep_clone(const std::string &target_path, const Ref *reference=nullptr, const StorageOptionsAccessor *storage_options=nullptr) const
RemovalStats cleanup_old_versions(const CleanupOldVersionsOptions &options) const
void drop_columns(const std::vector< std::string > &columns)
ShardWriter mem_wal_writer(const std::string &shard_id, const ShardWriterConfig &config={}) const
IndexSegmentBuilder new_vector_index_segment_builder(const std::string &column, const LanceVectorIndexParams &params, const std::string &index_name="", const LanceIndexSegmentBuildOptions *options=nullptr) const
Create a single-use builder for an uncommitted vector index segment.
static Dataset write_with_options(const std::string &uri, ArrowArrayStream *stream, WriteMode mode, const WriteOptions &options, const std::vector< std::pair< std::string, std::string > > &storage_opts={})
uint64_t delete_rows(const std::string &predicate)
IvfModel get_ivf_model(const std::string &index_name) const
Owned IVF model snapshot for the first physical vector segment.
ArrowStream take(std::span< const uint64_t > indices) const
void create_scalar_index_with_options(const std::string &column, LanceScalarIndexType index_type, const ScalarIndexOptions &options, const std::string &index_name="", const std::string &params_json="", bool replace=false)
static Dataset write(const std::string &uri, ArrowArrayStream *stream, WriteMode mode, const WriteParams &params, const std::vector< std::pair< std::string, std::string > > &storage_opts={})
void initialize_mem_wal(const MemWalInitOptions &options)
static Transaction write_uncommitted_with_commit_lock(const std::string &uri, ArrowArrayStream *stream, WriteMode mode, const UncommittedWriteOptions &options, const StorageOptionsAccessor *storage_accessor, const Session *session, const CommitLock *commit_lock)
RemovalStats cleanup(const CleanupPolicy &policy, const CleanupOperationOptions &operation={}) const
std::string index_statistics_json(const std::string &index_name)
std::string update_metadata_json(const std::vector< std::pair< std::string, std::optional< std::string > > > &values, MetadataUpdateMode mode=MetadataUpdateMode::Merge)
std::string branch_identifier_json() const
JSON object for this dataset snapshot's native BranchIdentifier.
std::vector< uint8_t > merge_index_segments(const std::vector< std::vector< uint8_t > > &segment_metadata) const
Merge existing uncommitted segments into one uncommitted segment.
uint64_t latest_version() const
Latest version ID (queries object store).
void take(const uint64_t *indices, size_t num_indices, ArrowArrayStream *out) const
Take all columns with the same stream ownership as the overload above.
std::string field_path(int32_t field_id) const
static Transaction write_uncommitted_with_accessor(const std::string &uri, ArrowArrayStream *stream, WriteMode mode, const StorageOptionsAccessor &storage_options_accessor, const UncommittedWriteOptions &options={}, const Session *session=nullptr)
static Dataset write_namespace(const Namespace &ns, const std::vector< std::string > &table_id, ArrowArrayStream *stream, WriteMode mode, const WriteOptions &options={}, const std::vector< std::pair< std::string, std::string > > &storage_opts={}, const std::optional< std::string > &branch=std::nullopt, const Session *session=nullptr)
void 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)
void delete_branch(const std::string &branch_name) const
static Dataset write_with_accessor(const std::string &uri, ArrowArrayStream *stream, WriteMode mode, const StorageOptionsAccessor &storage_options_accessor)
std::string describe_indices_json() const
JSON array of every native index description, including system indexes.
DedicatedBlobWriter(LanceDedicatedBlobWriter *writer)
DedicatedBlobWriter(DedicatedBlobWriter &&) noexcept=default
DelimitedList(LanceDelimitedList *list)
std::vector< std::string > objects() const
std::vector< std::string > common_prefixes() const
const Callback & callback() const noexcept
std::function< std::map< std::string, std::string >( const std::string &, const std::string &)> Callback
DynamicContextProvider(Callback callback)
Error(LanceErrorCode code_value, std::string message)
LanceErrorCode code
Owned native execution plan.
ExecutionPlan(::LanceMemWalPlan *plan)
ExecutionPlan(ExecutionPlan &&) noexcept=default
~ExecutionPlan()=default
LanceFieldReference c_handle() const
static FieldReference by_id(int32_t field_id)
static FieldReference by_path(std::string path)
std::vector< FileBufferDescriptor > global_buffers() const
FileMetadataInfo info() const
std::vector< FileColumnMetadata > columns() const
FileMetadata(LanceFileMetadata *metadata)
ArrowSchemaOwner schema() const
FileReader(FileReader &&) noexcept=default
FileReader(LanceFileReader *reader)
DelimitedList list_with_delimiter(std::optional< std::string > relative_path=std::nullopt) const
FileSession(FileSession &&) noexcept=default
DedicatedBlobWriter open_dedicated_blob_writer(const std::string &data_file_path, uint32_t blob_id) const
void download_file(const std::string &relative_remote_path, const std::string &local_path) const
ByteBuffer read_range(const std::string &relative_path, uint64_t offset, uint64_t length) const
void upload_file(const std::string &local_path, const std::string &relative_remote_path) const
LanceObjectStoreIoStats store_io_stats() const
LanceScanStats scheduler_stats() const
PathList list(std::optional< std::string > relative_path=std::nullopt) const
FileSession(const std::string &base_uri, const StorageOptionsAccessor *storage_options=nullptr, const Session *session=nullptr, std::optional< FileSchedulerConfig > scheduler_config=std::nullopt)
PackedBlobWriter open_packed_blob_writer(const std::string &data_file_path, uint32_t blob_id) const
FileWriter open_writer(const std::string &relative_path, const ArrowSchema *schema, const FileWriterOptions &options={}) const
LanceObjectStoreRegistryStats registry_stats() const
bool contains(const std::string &relative_path) const
void delete_file(const std::string &relative_path) const
FileStoreInfo store_info() const
FileStatistics(LanceFileStatistics *statistics)
std::vector< FileColumnStatistics > columns() const
FileWriter(LanceFileWriter *writer)
FileWriter(FileWriter &&) noexcept=default
FragmentOverlayWriter(FragmentOverlayWriter &&) noexcept=default
FragmentOverlayWriter(LanceFragmentOverlayWriter *writer)
Move-only owner of a native FragmentUpdateColumnsResult.
FragmentUpdateColumnsResult(FragmentUpdateColumnsResult &&) noexcept=default
FragmentUpdateColumnsResult(LanceFragmentUpdateColumnsResult *result)
const LanceFragment * c_handle() const
Fragment(LanceFragment *fragment)
Adopt a handle from the C API; closed on destruction.
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)
Fragment(Fragment &&) noexcept=default
FtsQueryContext(FtsQueryContext &&) noexcept=default
FtsQueryContext(LanceFtsQueryContext *context)
static FtsQuery multi_match(const std::string &terms, const std::vector< std::string > &columns, const FtsMultiMatchOptions &options={})
static FtsQuery boost(const FtsQuery &positive, const FtsQuery &negative, const FtsBoostOptions &options={})
static FtsQuery phrase(const std::string &terms, std::optional< std::string > column=std::nullopt, const FtsPhraseOptions &options={})
static FtsQuery boolean(const std::vector< std::pair< FtsOccur, const FtsQuery * > > &clauses)
static FtsQuery combined_fields(const std::string &terms, const std::vector< std::string > &columns, const FtsCombinedFieldsOptions &options={})
const LanceFtsQuery * c_handle() const
FtsQuery(FtsQuery &&) noexcept=default
FtsTokenList(FtsTokenList &&) noexcept=default
Handle(Handle &&o) noexcept
Handle & operator=(Handle &&o) noexcept
Handle(T *ptr=nullptr)
T * get() const
Handle(const Handle &)=delete
Handle & operator=(const Handle &)=delete
Move-only owner of an Arrow C Data Interface model array and schema.
ArrowArray * array() noexcept
IndexModel & operator=(const IndexModel &)=delete
IndexModel(const IndexModel &)=delete
Move-only builder for one uncommitted physical index segment.
IndexSegmentBuilder(IndexSegmentBuilder &&) noexcept=default
IndexSegmentBuilder(LanceIndexSegmentBuilder *builder)
Parsed metadata for one physical index segment.
IndexSegmentMetadata(LanceIndexSegmentMetadata *metadata)
IndexSegmentMetadata(IndexSegmentMetadata &&) noexcept=default
Owned native optimized index segment result.
IndexSegmentResult(LanceIndexSegmentResult *result)
IndexSegmentResult(IndexSegmentResult &&) noexcept=default
Move-only owner of a cloned native IVF model.
IvfModel(IvfModel &&) noexcept=default
KeyExistenceFilter(KeyExistenceFilter &&) noexcept=default
KeyExistenceFilter(LanceKeyExistenceFilter *filter)
LanceSchema(::LanceSchema *schema)
LanceSchema(LanceSchema &&) noexcept=default
Owned native point-lookup planner.
LsmPointLookupPlanner(const Dataset &dataset, std::vector< ShardSnapshot > snapshots, std::optional< std::vector< std::string > > pk_columns=std::nullopt)
LsmPointLookupPlanner(LsmPointLookupPlanner &&) noexcept=default
Owned native LSM scanner.
LsmScanner(::LanceLsmScanner *scanner)
LsmScanner(LsmScanner &&) noexcept=default
~LsmScanner()=default
Owned native vector-search planner.
LsmVectorSearchPlanner(LsmVectorSearchPlanner &&) noexcept=default
LsmVectorSearchPlanner(const Dataset &dataset, std::vector< ShardSnapshot > snapshots, std::string vector_column, std::optional< std::vector< std::string > > pk_columns=std::nullopt, MemWalDistanceType distance_type=MemWalDistanceType::L2, std::optional< std::string > filter=std::nullopt)
Owned copy of native MemWAL index details.
MemWalIndexDetails(uint32_t num_shards, bool maintain_all, std::vector< std::string > maintained, std::vector< ShardingSpec > specs, std::map< std::string, std::string > defaults, std::string dir_id={})
MemWalIndexDetails(MemWalIndexDetails &&) noexcept=default
NamespaceError(LanceErrorCode code_value, std::string message_value, uint32_t native_code_value, std::string native_message_value)
NamespaceResult(NamespaceResult &&) noexcept=default
Move-only namespace handle with native concrete-implementation retention.
static Namespace connect(const std::string &impl_name, const std::vector< std::pair< std::string, std::string > > &properties={}, const Session *session=nullptr, const DynamicContextProvider *context_provider=nullptr)
NamespaceResult call(const std::string &operation, const std::string &request_json, const std::vector< uint8_t > &request_bytes) const
static Namespace custom(const CustomClientSpec &spec)
std::string id() const
static Namespace custom_dispatch(const CustomDispatchSpec &spec)
std::string ops_metrics_json() const
NamespaceResult call(const std::string &operation, const std::string &request_json="{}", const uint8_t *request_bytes=nullptr, size_t request_bytes_len=0) const
Namespace(Namespace &&) noexcept=default
void reset_ops_metrics()
static Namespace rest(const std::vector< std::pair< std::string, std::string > > &properties, const DynamicContextProvider *context_provider=nullptr)
const LanceNamespace * c_handle() const noexcept
NativeWriteOptions(NativeWriteOptions &&) noexcept=default
NativeWriteOptions(const NativeWriteOptionsSpec &spec)
Operation(LanceOperation *operation)
Operation(Operation &&) noexcept=default
Owned snapshot of one native distributed index merge.
OptimizeIndexMerge(OptimizeIndexMerge &&) noexcept=default
OptimizeIndexMerge(LanceOptimizeIndexMerge *merge)
Owned snapshot of one native distributed index build task.
OptimizeIndexTask(OptimizeIndexTask &&) noexcept=default
OptimizeIndexTask(LanceOptimizeIndexTask *task)
Presence-preserving owner of native OptimizeOptions.
OptimizeIndicesOptions(OptimizeIndicesOptions &&) noexcept=default
OptimizeIndicesOptions(LanceOptimizeIndicesOptions *options)
Owned native distributed index optimization plan.
OptimizeIndicesPlan(OptimizeIndicesPlan &&) noexcept=default
OptimizeIndicesPlan(LanceOptimizeIndicesPlan *plan)
PackedBlobWriter(PackedBlobWriter &&) noexcept=default
PackedBlobWriter(LancePackedBlobWriter *writer)
std::vector< std::string > paths() const
PathList(LancePathList *list)
Owned native lance::dataset::refs::Ref.
static Ref tag(const std::string &tag_name)
const LanceRef * c_handle() const
Ref(LanceRef *reference)
Ref(Ref &&) noexcept=default
static Ref version_number(uint64_t version)
Move-only owner of a running native REST adapter.
RestAdapter & operator=(const RestAdapter &)=delete
uint16_t port() const noexcept
RestAdapter(const RestAdapter &)=delete
RestAdapter(RestAdapter &&other) noexcept
RestAdapter & operator=(RestAdapter &&other) noexcept
static RestAdapter start(const Namespace &backend, const std::string &host="127.0.0.1", uint16_t port=0)
RewriteGroup(const std::vector< const Fragment * > &old_fragments, const std::vector< const Fragment * > &new_fragments)
RewriteGroup(RewriteGroup &&) noexcept=default
RewriteGroup(LanceRewriteGroup *group)
Owned native compaction rewrite result.
RewriteResult(RewriteResult &&) noexcept=default
RewriteResult(LanceRewriteResult *result)
Owned native RewrittenIndex. Move-only.
RewrittenIndex(const std::array< uint8_t, 16 > &old_id, const std::array< uint8_t, 16 > &new_id, std::string_view details_type_url, const std::vector< uint8_t > &details_value, uint32_t index_version, std::optional< std::vector< IndexFile > > index_files)
RewrittenIndex(LanceRewrittenIndex *index)
RewrittenIndex(RewrittenIndex &&) noexcept=default
void scan_async(LanceCallback callback, void *ctx) const
Scanner & with_row_id(bool enable=true)
Enable/disable row ID in output.
Scanner & limit(int64_t n)
Set the row limit.
Scanner & maximum_nprobes(uint32_t maximum_nprobes)
Replace only the maximum partition-search bound.
uint64_t count_rows() const
Scanner & nearest(const std::string &column, std::span< const float > q, uint32_t k)
Scanner & statistics_callback(LanceScanStatisticsCallback callback, void *callback_ctx)
Scanner & additional_sql_filter(const std::string &filter)
Add an SQL filter that is combined with the selected primary filter using AND.
Scanner & batch_readahead(size_t batches)
Set the number of batches decoded concurrently.
Scanner & nearest(const std::string &column, const void *q, size_t dim, LanceDataType dtype, uint32_t k)
k-NN search (typed).
Scanner & batch_size(int64_t n)
Set the batch size.
Scanner & substrait_aggregate(const uint8_t *bytes, 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 & strict_batch_size(bool strict_batch_size=true)
Configure whether row-based output batches are strict.
Scanner & ef(uint32_t e)
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 & substrait_filter(const uint8_t *bytes, size_t len)
Scanner & minhash_search(const std::string &column, const std::string &text)
Scanner & substrait_filter(const std::vector< uint8_t > &bytes)
Set a Substrait filter (vector overload).
Scanner(LanceScanner *s)
Scanner & scalar_index_segment(const std::array< uint8_t, 16 > &segment_uuid)
Scanner & index_segments(const std::vector< std::array< uint8_t, 16 > > &uuids)
void schema(ArrowSchema *out) const
Scanner & row_addr_allowlist(const uint64_t *row_ids, size_t len)
std::string analyze_count_plan() const
Execute and format the native COUNT(*) plan, not the ordinary plan.
Scanner & use_stats(bool use_stats=true)
Configure whether file statistics may optimize the scan.
Scanner & disable_scoring_autoprojection()
Stop adding _score / _distance to explicit search projections.
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 & fragment_readahead(size_t fragments)
Set fragment readahead for unordered scans.
Scanner & order_by(std::nullopt_t)
Scanner & metric(LanceMetricType m)
Scanner & fragment_ids(const uint64_t *ids, size_t len)
Scanner & project(const std::vector< ProjectionColumn > &columns)
Scanner & nearest_batch(const std::string &column, std::span< const float > queries, size_t dimension, uint32_t k)
Scanner & scan_in_order(bool ordered=true)
Configure whether batches are returned in storage order.
Scanner & materialization_style(LanceMaterializationStyle style, const std::vector< std::string > &early_except_columns={})
std::string explain_plan(bool verbose=false) const
Explain the configured native plan without executing it.
LanceScanner * c_handle()
Access the underlying C handle.
Scanner & scalar_index_auto_selection(bool enabled=true)
Scanner & use_scalar_index(bool enable=true)
Scanner & distance_range(std::optional< float > lower_bound=std::nullopt, std::optional< float > upper_bound=std::nullopt)
Scanner & full_text_search(const FtsQuery &query)
Scanner & fts_query_context(const FtsQueryContext &context)
Scanner & index_segments(const uint8_t *uuids, size_t len)
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 & clear_scalar_index_segment()
Scanner & minimum_nprobes(uint32_t minimum_nprobes)
Replace only the minimum partition-search bound.
Scanner & refine_factor(uint32_t f)
void to_arrow_stream(ArrowArrayStream *out)
Scanner & search_effort(double effort)
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 & target_parallelism(size_t partitions)
Set the target number of physical execution partitions.
Scanner & offset(int64_t n)
Set the row offset.
Scanner & batch_size_bytes(uint64_t bytes)
Set the target output batch size in bytes.
Scanner & use_index(bool enable)
Scanner & blob_handling(LanceBlobHandling handling)
ArrowStream to_arrow_stream()
Scanner & fast_search(bool enable=true)
Scanner & fragment_ids(const std::vector< uint64_t > &ids)
Restrict the scan/search domain to specific fragment IDs (vector overload).
Scanner & prefilter(bool enable)
Scanner & query_parallelism(int32_t parallelism)
Scanner & include_deleted_rows(bool include_deleted_rows=true)
Scanner & with_row_address(bool enable=true)
Include or omit the _rowaddr metadata column.
Scanner & io_buffer_size(uint64_t bytes)
Set the scanner I/O buffer size in bytes, in the range [1, INT64_MAX].
Scanner & fts_index_segments(const std::vector< std::array< uint8_t, 16 > > &segment_uuids)
Scanner & approx_mode(LanceApproxMode approx_mode)
Scanner & nprobes(uint32_t nprobes)
Replace both minimum and maximum partition-search bounds.
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 & substrait_aggregate(const std::vector< uint8_t > &bytes)
Set a Substrait aggregate Plan (vector overload).
std::string analyze_plan() const
Scanner & project(std::nullopt_t)
Clear the projection and scan all dataset columns (native unset).
Scanner & full_text_search(const std::string &query, const std::vector< std::string > &columns={}, uint32_t max_fuzzy_distance=0)
Scanner & nearest(const std::string &column, const float *q, size_t dim, uint32_t k)
k-NN search (Float32 sugar).
Scanner & order_by(const std::vector< ColumnOrdering > &orderings)
Session(uint64_t index_cache_size_bytes, uint64_t metadata_cache_size_bytes)
Session(const SessionCacheSpec &index_cache, const SessionCacheSpec &metadata_cache)
const LanceSession * c_handle() const
uint64_t approx_num_items() const
Approximate number of items retained in both cache tiers.
uint64_t size_bytes() const
Current deep size of the session in bytes. This is not an RSS limit.
LanceSessionCacheStats cache_stats() const
Owned native shard snapshot.
ShardSnapshot(::LanceMemWalShardSnapshot *snapshot)
ShardSnapshot(ShardSnapshot &&) noexcept=default
std::optional< uint64_t > max_wal_buffer_size
ShardWriterConfig & add_hnsw_params(HnswParams value)
ShardWriterConfig & set_max_unflushed_memtable_bytes(uint64_t value)
LanceShardWriterConfig to_c(std::vector< std::string > &names, std::vector<::LanceMemWalHnswParams > &params) const
ShardWriterConfig & set_backpressure_log_interval_ms(uint64_t value)
std::optional< uint64_t > max_memtable_rows
std::optional< uint64_t > manifest_scan_batch_size
ShardWriterConfig & set_max_wal_flush_interval_ms(uint64_t value)
std::optional< uint64_t > max_memtable_batches
std::vector< HnswParams > hnsw_params
std::optional< bool > durable_write
std::optional< uint64_t > max_wal_flush_interval_ms
ShardWriterConfig & set_manifest_scan_batch_size(uint64_t value)
std::optional< uint64_t > stats_log_interval_ms
ShardWriterConfig & set_max_memtable_batches(uint64_t value)
std::optional< uint64_t > max_unflushed_memtable_bytes
ShardWriterConfig & set_max_wal_buffer_size(uint64_t value)
std::optional< uint64_t > max_memtable_size
ShardWriterConfig & set_durable_write(bool value)
ShardWriterConfig & set_stats_log_interval_ms(uint64_t value)
ShardWriterConfig & set_max_memtable_rows(uint64_t value)
std::optional< uint64_t > backpressure_log_interval_ms
ShardWriterConfig & set_max_memtable_size(uint64_t value)
Owned native shard writer.
ShardWriterStats stats() const
ShardWriter(::LanceShardWriter *writer)
ShardWriteResult delete_rows(ArrowArrayStream *stream)
std::optional< ShardSnapshot > snapshot() const
ShardWriter(ShardWriter &&) noexcept=default
std::string shard_id() const
const ::LanceShardWriter * c_handle() const
ShardWriteResult put(ArrowArrayStream *stream)
LsmScanner lsm_scanner(std::vector< ShardSnapshot > snapshots)
~ShardWriter()=default
ShardMemTableStats memtable_stats() const
Owned native sharding field.
std::optional< std::string > parameter(const std::string &key) const
std::optional< std::string > transform() const
ShardingField clone() const
std::optional< std::string > expression() const
ShardingField(::LanceMemWalShardingField *field)
std::map< std::string, std::string > parameters() const
std::string result_type() const
std::string id() const
const ::LanceMemWalShardingField * c_handle() const
ShardingField(ShardingField &&) noexcept=default
std::vector< int32_t > source_ids() const
Owned native sharding spec.
ShardingSpec(::LanceMemWalShardingSpec *spec)
ShardingSpec(ShardingSpec &&) noexcept=default
SqlQueryBuilder(LanceSqlQueryBuilder *builder)
SqlQueryBuilder(SqlQueryBuilder &&) noexcept=default
SqlQuery(LanceSqlQuery *query)
SqlQuery(SqlQuery &&) noexcept=default
std::optional< StorageOptions > snapshot() const
Resolve with native cache and expiration behavior.
StorageOptionsAccessor(std::optional< StorageOptions > initial=std::nullopt, const StorageOptionsProvider *provider=nullptr)
NULL optional means native None; an engaged empty map means Some(empty).
const LanceStorageOptionsAccessor * c_handle() const
std::function< std::optional< StorageOptions >()> Fetch
const LanceStorageOptionsProvider * c_handle() const
StorageOptionsProvider(std::string provider_id, Fetch fetch, Fetch force_fetch={})
static StorageOptionsProvider from_namespace(const Namespace &ns, const std::vector< std::string > &table_id)
std::string provider_id() const
std::vector< uint8_t > to_proto() const
Serialize with the selected core's native protobuf conversion.
static Transaction from_proto(const std::vector< uint8_t > &bytes)
Parse one complete native protobuf Transaction.
const LanceTransaction * c_handle() const
Transaction(LanceTransaction *transaction)
Transaction(Transaction &&) noexcept=default
UpdateMap(const std::vector< std::string > &keys, const std::vector< std::optional< std::string > > &values, bool replace)
UpdateMap(LanceUpdateMap *map)
UpdateMap(UpdateMap &&) noexcept=default
UpdatedFragmentOffsets(LanceUpdatedFragmentOffsets *offsets)
UpdatedFragmentOffsets(UpdatedFragmentOffsets &&) noexcept=default
UpdatedFragmentOffsets(const std::vector< std::pair< uint64_t, std::vector< uint32_t > > > &entries)
Build from (fragment ID, offsets) entries in input order.
VectorIndexOptionsStorage & operator=(const VectorIndexOptionsStorage &)=delete
VectorIndexOptionsStorage(const VectorIndexOptionsStorage &)=delete
const LanceVectorIndexOptions * get() const
VectorIndexOptionsStorage(const VectorIndexOptions &options)
LanceErrorCode
Definition error.h:20
@ LANCE_ERR_INTERNAL
Definition error.h:27
struct LanceNamespace LanceNamespace
Definition fwd.h:78
struct LanceOperation LanceOperation
Definition fwd.h:66
struct LanceDatasetDelta LanceDatasetDelta
Definition fwd.h:42
struct LanceBatch LanceBatch
Definition fwd.h:30
struct LanceTag LanceTag
Definition fwd.h:36
struct LanceDataFile LanceDataFile
Definition fwd.h:61
struct LanceIndexSegmentResult LanceIndexSegmentResult
Definition fwd.h:53
struct LanceCompactionPlan LanceCompactionPlan
Definition fwd.h:46
struct LanceIvfModel LanceIvfModel
Definition fwd.h:76
struct LanceSchema LanceSchema
Definition fwd.h:77
struct LanceDataOverlayFile LanceDataOverlayFile
Definition fwd.h:67
struct LanceFragmentUpdateColumnsResult LanceFragmentUpdateColumnsResult
Definition fwd.h:70
struct LanceStorageOptionsAccessor LanceStorageOptionsAccessor
Definition fwd.h:20
struct LanceOptimizeIndexMerge LanceOptimizeIndexMerge
Definition fwd.h:52
struct LanceDataset LanceDataset
Definition fwd.h:28
struct LanceTransaction LanceTransaction
Definition fwd.h:65
struct LanceUpdatedFragmentOffsets LanceUpdatedFragmentOffsets
Definition fwd.h:71
struct LanceSqlQueryBuilder LanceSqlQueryBuilder
Definition fwd.h:43
struct LanceCommitLock LanceCommitLock
Definition fwd.h:80
struct LanceDatasetDeltaBuilder LanceDatasetDeltaBuilder
Definition fwd.h:41
struct LanceSession LanceSession
Definition fwd.h:31
struct LanceIndexSegmentBuilder LanceIndexSegmentBuilder
Definition fwd.h:54
struct LanceBlobDescriptorArrayBuilder LanceBlobDescriptorArrayBuilder
Definition fwd.h:60
struct LanceRewriteResult LanceRewriteResult
Definition fwd.h:48
struct LanceVersion LanceVersion
Definition fwd.h:33
struct LanceIndexSegmentMetadata LanceIndexSegmentMetadata
Definition fwd.h:55
struct LanceCleanupExplanation LanceCleanupExplanation
Definition fwd.h:39
struct LanceScanner LanceScanner
Definition fwd.h:29
struct LanceFragmentOverlayWriter LanceFragmentOverlayWriter
Definition fwd.h:69
struct LanceCompactionTask LanceCompactionTask
Definition fwd.h:47
struct LanceOptimizeIndicesOptions LanceOptimizeIndicesOptions
Definition fwd.h:49
struct LanceOptimizeIndicesPlan LanceOptimizeIndicesPlan
Definition fwd.h:50
struct LanceKeyExistenceFilter LanceKeyExistenceFilter
Definition fwd.h:72
struct LanceCompactionOptionsV2 LanceCompactionOptionsV2
Definition fwd.h:45
struct LanceSqlQuery LanceSqlQuery
Definition fwd.h:44
struct LanceFtsQueryContext LanceFtsQueryContext
Definition fwd.h:56
struct LanceRef LanceRef
Definition fwd.h:35
struct LanceFtsQuery LanceFtsQuery
Definition fwd.h:57
struct LanceFragment LanceFragment
Definition fwd.h:64
struct LanceDataOverlayGroup LanceDataOverlayGroup
Definition fwd.h:68
struct LanceRewrittenIndex LanceRewrittenIndex
Definition fwd.h:74
struct LanceBlobFile LanceBlobFile
Definition fwd.h:59
struct LanceFtsTokenList LanceFtsTokenList
Definition fwd.h:58
struct LanceDataReplacementGroup LanceDataReplacementGroup
Definition fwd.h:63
struct LanceRewriteGroup LanceRewriteGroup
Definition fwd.h:73
struct LanceRestAdapter LanceRestAdapter
Definition fwd.h:79
struct LanceOptimizeIndexTask LanceOptimizeIndexTask
Definition fwd.h:51
C API for the Lance columnar data format.
@ LANCE_FILE_CACHE_SESSION
Definition lance.h:10035
@ LANCE_FILE_CACHE_NONE
Definition lance.h:10034
struct LanceUpdateMap LanceUpdateMap
Definition lance.h:7192
LanceCompactionMode
Definition lance.h:2376
struct LanceMemWalShardingField LanceMemWalShardingField
Definition lance.h:11214
const char const char uint32_t max_fuzzy_distance
Definition lance.h:6238
const char const char * query
Definition lance.h:6237
@ LANCE_FIELD_REFERENCE_PATH
Definition lance.h:871
@ LANCE_FIELD_REFERENCE_ID
Definition lance.h:870
LANCE_API void lance_fragment_update_columns_result_close(LanceFragmentUpdateColumnsResult *result)
struct LanceStorageOptionsProvider LanceStorageOptionsProvider
Definition lance.h:9554
@ LANCE_CLEANUP_FILE_DATA
Definition lance.h:503
@ LANCE_CLEANUP_FILE_TRANSACTION
Definition lance.h:504
@ LANCE_CLEANUP_FILE_INDEX
Definition lance.h:505
@ LANCE_CLEANUP_FILE_MANIFEST
Definition lance.h:502
@ LANCE_CLEANUP_FILE_TEMPORARY_MANIFEST
Definition lance.h:507
@ LANCE_CLEANUP_FILE_DELETION
Definition lance.h:506
void(* LanceIndexBuildProgressCallback)(void *callback_ctx, int32_t event, const char *stage, uint64_t total, const char *unit, uint64_t completed)
Definition lance.h:4671
struct LanceMemWalShardSnapshot LanceMemWalShardSnapshot
Definition lance.h:11215
LanceSchedulerLiteMode
Definition lance.h:10091
@ LANCE_SCHEDULER_LITE_AUTO
Definition lance.h:10092
LanceMemWalShardingMode
Definition lance.h:11044
@ LANCE_MEM_WAL_SHARDING_MANUAL
Definition lance.h:11045
LanceApproxMode
Definition lance.h:83
LanceDataType
Definition lance.h:89
struct LanceFileWriter LanceFileWriter
Definition lance.h:10024
struct LanceLsmVectorSearchPlanner LanceLsmVectorSearchPlanner
Definition lance.h:11219
LanceVectorIndexType
Definition lance.h:53
@ LANCE_INDEX_IVF_FLAT
Definition lance.h:54
@ LANCE_METADATA_UPDATE_MERGE
Definition lance.h:798
@ LANCE_METADATA_UPDATE_REPLACE
Definition lance.h:800
LanceIndexRemapMode
Definition lance.h:2383
@ LANCE_WRITE_CREATE
Definition lance.h:6412
@ LANCE_WRITE_OVERWRITE
Definition lance.h:6414
@ LANCE_WRITE_APPEND
Definition lance.h:6413
@ LANCE_EXTERNAL_BLOB_INGEST
Definition lance.h:6681
@ LANCE_EXTERNAL_BLOB_REFERENCE
Definition lance.h:6680
struct LanceFileStatistics LanceFileStatistics
Definition lance.h:10028
@ LANCE_DATA_OVERLAY_COVERAGE_PER_FIELD
Definition lance.h:7553
@ LANCE_DATA_OVERLAY_COVERAGE_SHARED
Definition lance.h:7552
@ LANCE_OPERATION_UNKNOWN
Definition lance.h:7294
@ LANCE_OPERATION_APPEND
Definition lance.h:7295
@ LANCE_OPERATION_RESTORE
Definition lance.h:7303
@ LANCE_OPERATION_UPDATE_CONFIG
Definition lance.h:7307
@ LANCE_OPERATION_OVERWRITE
Definition lance.h:7297
@ LANCE_OPERATION_CREATE_INDEX
Definition lance.h:7298
@ LANCE_OPERATION_UPDATE
Definition lance.h:7305
@ LANCE_OPERATION_REWRITE
Definition lance.h:7299
@ LANCE_OPERATION_UPDATE_MEM_WAL_STATE
Definition lance.h:7308
@ LANCE_OPERATION_RESERVE_FRAGMENTS
Definition lance.h:7304
@ LANCE_OPERATION_DELETE
Definition lance.h:7296
@ LANCE_OPERATION_UPDATE_BASES
Definition lance.h:7310
@ LANCE_OPERATION_PROJECT
Definition lance.h:7306
@ LANCE_OPERATION_DATA_REPLACEMENT
Definition lance.h:7300
@ LANCE_OPERATION_DATA_OVERLAY
Definition lance.h:7301
@ LANCE_OPERATION_CLONE
Definition lance.h:7309
@ LANCE_OPERATION_MERGE
Definition lance.h:7302
const char const char uint32_t int32_t coverage_mode
Definition lance.h:6240
struct LanceDelimitedList LanceDelimitedList
Definition lance.h:10030
LANCE_API void lance_blob_descriptor_array_builder_close(LanceBlobDescriptorArrayBuilder *builder)
@ LANCE_SESSION_CACHE_SPEC_CONFIG
Definition lance.h:364
@ LANCE_SESSION_CACHE_SPEC_URI
Definition lance.h:362
@ LANCE_SESSION_CACHE_SPEC_DEFAULT
Definition lance.h:358
@ LANCE_SESSION_CACHE_SPEC_SIZE
Definition lance.h:360
LanceIndexFileVersion
Definition lance.h:115
@ LANCE_INDEX_FILE_VERSION_V3
Definition lance.h:116
LANCE_API void lance_updated_fragment_offsets_close(LanceUpdatedFragmentOffsets *offsets)
@ LANCE_FTS_MATCH_OPERATOR_AND
Definition lance.h:5993
@ LANCE_FTS_MATCH_OPERATOR_OR
Definition lance.h:5991
struct LanceLsmPointLookupPlanner LanceLsmPointLookupPlanner
Definition lance.h:11218
LanceMetricType
Definition lance.h:75
@ LANCE_METRIC_L2
Definition lance.h:76
struct LanceShardWriter LanceShardWriter
Definition lance.h:11216
LanceScalarIndexType
Definition lance.h:63
struct LanceDedicatedBlobWriter LanceDedicatedBlobWriter
Definition lance.h:10026
struct LanceByteBuffer LanceByteBuffer
Definition lance.h:10031
struct LancePackedBlobWriter LancePackedBlobWriter
Definition lance.h:10025
const char * column
Definition lance.h:6236
LanceColumnNullableMode
Definition lance.h:2849
@ LANCE_COLUMN_NULLABLE_UNCHANGED
Definition lance.h:2851
@ LANCE_MEM_WAL_DISTANCE_HAMMING
Definition lance.h:11061
@ LANCE_MEM_WAL_DISTANCE_L2
Definition lance.h:11058
@ LANCE_MEM_WAL_DISTANCE_COSINE
Definition lance.h:11059
@ LANCE_MEM_WAL_DISTANCE_DOT
Definition lance.h:11060
@ LANCE_COMMIT_TIMEOUT_DISABLED
Definition lance.h:7341
@ LANCE_COMMIT_TIMEOUT_EXPLICIT
Definition lance.h:7343
@ LANCE_COMMIT_TIMEOUT_DEFAULT
Definition lance.h:7339
LanceKeyExistenceFilterKind
Definition lance.h:8556
@ LANCE_FTS_COVERAGE_INDEX_ONLY
Definition lance.h:5985
@ LANCE_FTS_COVERAGE_STRICT
Definition lance.h:5983
struct LanceLsmScanner LanceLsmScanner
Definition lance.h:11217
struct LanceFileReader LanceFileReader
Definition lance.h:10023
struct LanceMemWalShardingSpec LanceMemWalShardingSpec
Definition lance.h:11213
struct LanceFileMetadata LanceFileMetadata
Definition lance.h:10027
@ LANCE_UPDATE_MODE_REWRITE_ROWS
Definition lance.h:8528
@ LANCE_UPDATE_MODE_REWRITE_COLUMNS
Definition lance.h:8529
struct LanceMemWalPlan LanceMemWalPlan
Definition lance.h:11220
LanceFileFormatVersion
Definition lance.h:10479
@ LANCE_FILE_FORMAT_V2_1
Definition lance.h:10482
@ LANCE_FILE_FORMAT_V2_0
Definition lance.h:10481
@ LANCE_FILE_FORMAT_V2_3
Definition lance.h:10484
@ LANCE_FILE_FORMAT_V1
Definition lance.h:10480
@ LANCE_FILE_FORMAT_V2_2
Definition lance.h:10483
@ LANCE_FTS_OCCUR_SHOULD
Definition lance.h:6009
@ LANCE_FTS_OCCUR_MUST_NOT
Definition lance.h:6013
@ LANCE_FTS_OCCUR_MUST
Definition lance.h:6011
struct LanceNativeWriteOptions LanceNativeWriteOptions
Definition lance.h:6671
@ LANCE_BLOB_ROWS_NONE
Definition lance.h:4465
@ LANCE_BLOB_ROWS_IDS
Definition lance.h:4466
@ LANCE_BLOB_ROWS_INDICES
Definition lance.h:4468
@ LANCE_BLOB_ROWS_ADDRESSES
Definition lance.h:4467
struct LancePathList LancePathList
Definition lance.h:10029
@ LANCE_FTS_DOCUMENT_GRANULARITY_LIST_ELEMENT
Definition lance.h:6003
@ LANCE_FTS_DOCUMENT_GRANULARITY_ROW
Definition lance.h:6001
@ LANCE_FTS_DOCUMENT_GRANULARITY_UNSPECIFIED
Definition lance.h:5999
@ LANCE_FILE_ENCODING_ABSENT
Definition lance.h:10508
@ LANCE_FILE_ENCODING_INDIRECT
Definition lance.h:10511
@ LANCE_FILE_ENCODING_NONE
Definition lance.h:10509
@ LANCE_FILE_ENCODING_DIRECT
Definition lance.h:10510
void set_callback_error(LanceCallbackError *target, int32_t code, const char *message) noexcept
int32_t get_fragment_trampoline(void *callback_ctx, uint32_t fragment_id, LanceOwnedString *out_json, LanceCallbackError *error) noexcept
int32_t get_batch_trampoline(void *callback_ctx, const LanceUDFBatchInfo *raw_info, ArrowArray *output, LanceCallbackError *error) noexcept
int32_t insert_fragment_trampoline(void *callback_ctx, uint64_t fragment_id, const char *fragment_json, LanceCallbackError *error) noexcept
void release_schema_after_exception(ArrowSchema *value) noexcept
int32_t get_batch_v2_trampoline(void *callback_ctx, const LanceUDFBatchInfo *raw_info, ArrowArray *output, ArrowSchema *output_schema, LanceCallbackError *error) noexcept
void release_owned_string(LanceOwnedString *value) noexcept
void release_array_after_exception(ArrowArray *value) noexcept
int32_t insert_batch_trampoline(void *callback_ctx, const LanceUDFBatchInfo *raw_info, ArrowArray *batch, ArrowSchema *batch_schema, LanceCallbackError *error) noexcept
int32_t mapper_trampoline(void *callback_ctx, const ArrowArray *input, const ArrowSchema *input_schema, ArrowArray *output, LanceCallbackError *error) noexcept
void destroy_lease_trampoline(void *, void *lease) noexcept
int32_t acquire_trampoline(void *callback_ctx, uint64_t version, void **out_lease, LanceCallbackError *error) noexcept
int32_t release_trampoline(void *, void *lease, bool success, LanceCallbackError *error) noexcept
void release_context_trampoline(void *callback_ctx) noexcept
std::unique_ptr< const char, FreeString > OwnedString
Owner of a string allocated by the C API.
std::vector< uint8_t > take_bytes(uint8_t *raw, size_t len)
std::unique_ptr< uint8_t, FreeBytes > OwnedBytes
Owner of a byte buffer allocated by the C API.
std::string take_string(const char *raw)
Take ownership of a string allocated by the C API.
void throw_error()
FileEncodingDescriptor encoding_descriptor(const LanceEncodingDescriptor &descriptor)
LanceFileReaderOptions reader_options(const FileReaderOptions &options, std::vector< const char * > &columns)
LanceFileWriterOptions writer_options(const FileWriterOptions &options)
FileBufferDescriptor buffer_descriptor(const LanceBufferDescriptor &descriptor)
std::pair< Fragment, LanceSchema > take_fragment_schema_pair(::LanceFragment *fragment, ::LanceSchema *schema)
DataReplacementGroup take_replacement_group(LanceDataReplacementGroup *group)
std::string json_string_object(const std::vector< std::pair< std::string, std::string > > &entries)
void free_owned_string(LanceOwnedString *value) noexcept
void set_owned_string(LanceOwnedString *out, std::string value)
std::string json_string_array(const std::vector< std::string > &values)
std::string json_string(std::string_view value)
std::string json_escape(std::string_view value)
void build_base_store_params(const std::optional< std::vector< DatasetBaseStoreParams > > &base_store_params, BaseStoreParamsHolder &holder)
int32_t invoke_fragment(const NativeWriteProgress::FragmentCallback &callback, const LanceWriteFragmentProgressInfo *info, LanceCallbackError *error, const char *context) noexcept
void write_stats_trampoline(void *callback_ctx, const LanceWriteStats *stats) noexcept
void build_initial_bases(const std::optional< std::vector< BasePath > > &initial_bases, BuildState &state)
int32_t begin_fragment_trampoline(void *callback_ctx, const LanceWriteFragmentProgressInfo *info, LanceCallbackError *error) noexcept
void release_progress_context(void *callback_ctx) noexcept
int32_t complete_fragment_trampoline(void *callback_ctx, const LanceWriteFragmentProgressInfo *info, LanceCallbackError *error) noexcept
void release_fetch_snapshot(void *raw) noexcept
int32_t fetch_impl(const StorageOptionsProvider::Fetch &fetch, LanceStorageOptionsFetchResult *out, LanceCallbackError *error, const char *context) noexcept
int32_t force_fetch_callback(void *callback_ctx, LanceStorageOptionsFetchResult *out, LanceCallbackError *error) noexcept
LanceStorageOptionsProvider * create_provider(const std::string &provider_id, StorageOptionsProvider::Fetch fetch, StorageOptionsProvider::Fetch force_fetch)
void provider_release(void *callback_ctx) noexcept
int32_t fetch_callback(void *callback_ctx, LanceStorageOptionsFetchResult *out, LanceCallbackError *error) noexcept
OverlayCoverageKind
Coverage layout of a native data overlay value.
std::string build_rq_model(uint32_t dimension, uint32_t num_bits=5)
LanceWriteOptions to_c_write_options(const WriteOptions &options, LanceAutoCleanupParams &cleanup)
UpdateMode
Native update mode of an Update operation.
BlobRowSelector
Row selector for planned whole-blob and range reads.
MemWalDistanceType
Native distance metric for MemWAL vector search.
FtsDocumentGranularity
std::function< void( uint64_t manifests_processed, std::optional< uint64_t > manifests_total)> TrackedFilesProgressCallback
void blob_field_with_options(const std::string &name, bool nullable, const BlobFieldOptions &options, ArrowSchema *out)
std::function< bool( const BatchUDFInfo &, ArrowArray &, ArrowSchema &)> BatchUDFGetBatchV2
void init_logging(std::string_view filter="info")
std::function< void( const ArrowArray &input, const ArrowSchema &input_schema, ArrowArray &output)> BatchUDFMapper
void check_error()
CleanupFileKind
Native cleanup file kinds.
std::string_view version() noexcept
void blob_field(const std::string &name, bool nullable, ArrowSchema *out)
void scanner_async_stream_free(ArrowArrayStream *stream) noexcept
ProcessIoCounters process_io_counters()
std::map< std::string, std::string > StorageOptions
std::string simd_info_json()
std::pair< std::string, std::optional< std::string > > ConfigUpdate
LanceNullOrder
Definition scanner.h:166
@ LANCE_ORDER_NULLS_LAST
Definition scanner.h:167
void(* LanceScanStatisticsCallback)(void *callback_ctx, const LanceScanStatistics *statistics)
Definition scanner.h:584
LanceOrderDirection
Definition scanner.h:160
@ LANCE_ORDER_ASCENDING
Definition scanner.h:161
LanceMaterializationStyle
Definition scanner.h:342
LanceBlobHandling
Definition scanner.h:304
void(* LanceCallback)(void *ctx, int32_t status, void *result)
Definition scanner.h:785
void(* release)(struct ArrowArrayStream *)
Definition arrow_abi.h:64
void(* release)(struct ArrowSchema *)
Definition arrow_abi.h:38
std::optional< std::vector< std::pair< std::string, std::string > > > transaction_properties
std::optional< std::string > name
BatchCommitResult(BatchCommitResult &&) noexcept=default
BatchCommitResult(Dataset &&dataset_value, Transaction &&transaction_value)
Schema-aware native BatchUDF declaration.
std::optional< UDFCheckpointStoreV2 > checkpoint_store
BatchUDFMapper mapper
std::optional< UDFCheckpointStore > checkpoint_store
BatchUDFMapper mapper
std::optional< size_t > dedicated_size_threshold
std::optional< size_t > inline_size_threshold
One row-specific blob-range request for Dataset::read_blob_ranges().
One blob-relative byte range for BlobFile::read_ranges().
std::optional< uint64_t > io_buffer_size
Bloom-filter parameters of a key-existence filter.
std::vector< uint8_t > bitmap
One copied cleanup candidate.
Fully copied native CleanupExplanation.
std::vector< CleanupCandidateFile > candidate_files
std::vector< CleanupReferencedBranch > referenced_branches
std::vector< std::string > warnings
Relative-duration inputs for Dataset::cleanup_old_versions.
std::optional< bool > error_if_tagged_old_versions
std::optional< bool > delete_unverified
std::optional< uint64_t > delete_concurrency
std::optional< uint64_t > max_candidate_files
std::optional< uint64_t > delete_rate_limit
std::optional< bool > error_if_tagged_old_versions
std::optional< uint64_t > before_version
std::optional< uint64_t > retain_versions
std::optional< CleanupTimestamp > before_timestamp
std::optional< bool > delete_unverified
std::optional< std::vector< uint64_t > > versions
std::optional< uint64_t > delete_rate_limit
std::optional< bool > clean_referenced_branches
One copied referenced child branch.
Whole seconds plus nanoseconds since the Unix epoch.
std::optional< std::string > rename
One native scanner ordering key. Entries are applied in vector order.
std::optional< CommitDuration > retry_timeout
std::optional< std::string > data_storage_version
CommitDuration timeout
std::optional< uint32_t > max_retries
std::optional< bool > enable_v2_manifest_paths
std::optional< bool > use_stable_row_ids
A compacted SSTable marker advanced atomically with a merge-insert commit.
::LanceCompactedSsTable to_c() const
static CompactedSsTable from_uuid(const std::string &shard_id, uint64_t generation)
std::optional< bool > use_constant_size_upload_parts
std::optional< bool > list_is_lexically_ordered
std::optional< uint64_t > block_size
std::optional< CommitDuration > s3_credentials_refresh_offset
std::optional< uint64_t > data_cache_bytes
std::optional< bool > keep_original_array
std::optional< uint64_t > max_page_bytes
std::optional< std::vector< DatasetBaseStoreParams > > base_store_params
std::vector< std::pair< std::string, std::optional< std::string > > > values
std::vector< FileBufferDescriptor > column_buffers
std::vector< FilePageMetadata > pages
FileEncodingDescriptor encoding
std::vector< uint8_t > direct_bytes
FileEncodingDescriptor encoding
std::vector< FileBufferDescriptor > buffers
std::optional< bool > inline_scheduling
std::optional< bool > cache_repetition_index
std::optional< uint64_t > batch_size_bytes
std::optional< bool > validate_on_decode
std::optional< std::vector< std::string > > columns
std::optional< uint64_t > read_chunk_size
std::optional< bool > keep_original_array
std::optional< uint64_t > max_page_bytes
std::optional< std::string > version
std::optional< uint64_t > data_cache_bytes
Native fragment progress payload.
std::optional< uint64_t > physical_rows
Options for FtsQuery::boost().
std::optional< std::vector< float > > boosts
std::optional< std::vector< float > > boosts
Options for FtsQuery::phrase().
One token produced by the native Lance analyzer chain.
Per-index HNSW build controls.
std::optional< uint32_t > ef_construction
std::optional< uint32_t > max_level
std::optional< uint32_t > num_edges
One index file recorded by a rewritten index.
std::optional< std::vector< std::array< uint8_t, 16 > > > index_segments
One file recorded in an index segment's native metadata.
bool operator==(const IndexSegmentFile &other) const
bool operator!=(const IndexSegmentFile &other) const
Whole seconds plus nanoseconds since the Unix epoch.
Additive standalone IVF/PQ trainer controls.
std::optional< uint64_t > max_iters
std::optional< uint64_t > sample_rate
Options for Dataset::initialize_mem_wal.
std::optional< ShardWriterConfig > writer_config
std::optional< std::vector< std::string > > maintained_indexes
std::optional< std::string > column
std::string namespace_id
Empty assigns a unique identity stable for this client's lifetime.
std::function< std::string(const std::string &)> describe_table_version
std::function< std::string(const std::string &)> list_table_versions
std::function< std::string(const std::string &)> create_table_version
std::function< std::string(const std::string &)> describe_table
std::string namespace_id
Empty assigns a unique identity stable for this client's lifetime.
std::function< std::string(const std::string &, const std::string &)> dispatch
Configuration for an owned NativeWriteOptions handle.
std::optional< std::vector< std::string > > target_base_names_or_paths
std::optional< DatasetFileWriterOptions > file_writer_options
std::optional< std::vector< std::pair< std::string, std::string > > > transaction_properties
std::optional< uint64_t > blob_pack_file_size_threshold
std::optional< std::vector< uint32_t > > target_bases
std::optional< bool > target_all_bases
std::optional< bool > enable_v2_manifest_paths
std::optional< std::vector< BasePath > > initial_bases
std::optional< std::vector< DatasetBaseStoreParams > > base_store_params
FragmentCallback begin_fragment
FragmentCallback complete_fragment
std::function< void(const FragmentWriteProgressInfo &)> FragmentCallback
std::function< void(const NativeWriteStats &)> StatsCallback
Cumulative native write statistics.
One read of both native process counters.
One ordered scanner projection entry. output_name may be an alias.
Copied native RemovalStats.
Additive scalar-index build controls.
std::optional< bool > train
static SessionCacheSpec default_cache()
std::vector< std::pair< std::string, std::string > > backend_options
static SessionCacheSpec from_config(std::string backend_kind, std::vector< std::pair< std::string, std::string > > backend_options={})
static SessionCacheSpec with_size(uint64_t capacity_bytes)
static SessionCacheSpec from_uri(std::string uri)
Snapshot of live MemTable and memory statistics.
std::optional< uint64_t > max_buffered_batch_position
std::optional< uint64_t > pending_wal_start_batch_position
std::optional< uint64_t > pending_wal_end_batch_position
Native put/delete batch-position range.
Snapshot of native shard-writer counters.
std::string expression
One SSTable referenced by a shard snapshot.
One Arrow schema plus a materialized batch list.
ArrowSchemaOwner schema
std::vector< Batch > batches
std::optional< std::string > branch
uint64_t manifest_size
std::map< std::string, std::string > metadata
std::string name
std::optional< int64_t > created_at_ns
std::optional< int64_t > updated_at_ns
std::optional< std::string > uuid
std::optional< std::string > tag
std::optional< std::vector< std::pair< std::string, std::string > > > transaction_properties
std::function< void(const BatchUDFInfo &, ArrowArray &, ArrowSchema &)> insert_batch
std::function< std::optional< std::string >(uint32_t)> get_fragment
std::function< void(uint64_t, const std::string &)> insert_fragment
std::function< void(const BatchUDFInfo &, ArrowArray &, ArrowSchema &)> insert_batch
std::function< std::optional< std::string >(uint32_t)> get_fragment
std::function< void(uint64_t, const std::string &)> insert_fragment
std::function< bool(const BatchUDFInfo &, ArrowArray &)> get_batch
std::optional< std::vector< std::pair< std::string, std::string > > > transaction_properties
std::map< int32_t, UpdateMap > field_metadata_updates
std::optional< UpdateMap > schema_metadata_updates
std::optional< UpdateMap > config_updates
std::optional< UpdateMap > table_metadata_updates
std::vector< const Fragment * > new_fragments
std::vector< const Fragment * > updated_fragments
std::optional< std::string > mem_wal_dir_id
std::optional< KeyExistenceFilter > inserted_rows_filter
std::optional< UpdateMode > update_mode
std::vector< uint32_t > fields_modified
std::vector< uint64_t > removed_fragment_ids
std::vector< CompactedSsTable > compacted_sstables
std::vector< uint32_t > fields_for_preserving_frag_bitmap
std::optional< UpdatedFragmentOffsets > updated_fragment_offsets
std::optional< uint64_t > streaming_sample_rate
std::optional< std::string > precomputed_partitions_file
std::optional< uint64_t > num_sub_vectors
std::optional< uint64_t > hnsw_m
std::optional< std::map< std::string, std::string > > storage_options
std::optional< uint64_t > hnsw_ef_construction
std::optional< uint64_t > shuffle_partition_concurrency
std::optional< uint64_t > hnsw_max_level
std::optional< uint64_t > num_partitions
VectorIndexOptions & accelerator(std::string device)
std::optional< std::pair< std::string, std::vector< std::string > > > precomputed_shuffle_buffers
std::optional< uint64_t > shuffle_partition_batches
std::optional< std::string > rabitq_model_json
std::optional< uint64_t > sample_rate
std::optional< uint64_t > target_partition_size
std::map< std::string, std::string > runtime_hints
std::optional< uint64_t > num_bits
std::optional< uint64_t > max_iters
std::optional< uint64_t > streaming_coreset_rate
std::optional< bool > train
A copied version snapshot with native-precision timestamp and metadata.
std::map< std::string, std::string > metadata
std::optional< AutoCleanupParams > auto_cleanup
std::optional< std::string > data_storage_version
Lance file format version, e.g. "2.0", "2.1", "stable", "legacy".
BatchUDFCall & operator=(BatchUDFCall &&)=delete
BatchUDFCall & operator=(const BatchUDFCall &)=delete
BatchUDFCall(BatchUDFCall &&)=delete
BatchUDFCall(const BatchUDFV2 &udf, std::optional< std::vector< std::string > > columns, std::optional< uint32_t > batch_size)
std::vector< const char * > read_column_ptrs
std::optional< std::vector< std::string > > read_columns
BatchUDFCall(const BatchUDFCall &)=delete
BatchUDFCall(const BatchUDF &udf, std::optional< std::vector< std::string > > columns, std::optional< uint32_t > batch_size)
std::unique_ptr< CommitLease > lease
Deleter for byte buffers allocated by the C API.
void operator()(uint8_t *ptr) const noexcept
Deleter for strings allocated by the C API.
void operator()(const char *ptr) const noexcept
std::vector< std::optional< std::string > > base_names
std::unique_ptr< ProgressContext > progress_ctx