Skip to content

Commit d9bc472

Browse files
authored
Do not create default tiledb::Config objects in C++ (#350)
1 parent 83552bc commit d9bc472

File tree

6 files changed

+32
-38
lines changed

6 files changed

+32
-38
lines changed

src/include/api/ivf_flat_index.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ class IndexIVFFlat {
150150
{"id_datatype", &id_datatype_, TILEDB_UINT32, "ids_array_name"},
151151
{"px_datatype", &px_datatype_, TILEDB_UINT32, "index_array_name"}};
152152

153-
tiledb::Config cfg;
154-
tiledb::Group read_group(ctx, group_uri, TILEDB_READ, cfg);
153+
tiledb::Group read_group(ctx, group_uri, TILEDB_READ, ctx.config());
155154

156155
// Get the storage_version in case the metadata is not present on read_group
157156
// and we need to read the individual arrays.

src/include/api/vamana_index.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ class IndexVamana {
137137
&adjacency_row_index_datatype_,
138138
TILEDB_UINT32}};
139139

140-
tiledb::Config cfg;
141-
tiledb::Group read_group(ctx, group_uri, TILEDB_READ, cfg);
140+
tiledb::Group read_group(ctx, group_uri, TILEDB_READ, ctx.config());
142141

143142
for (auto& [name, value, datatype] : metadata) {
144143
if (!read_group.has_metadata(name, &datatype)) {

src/include/index/flatpq_index.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,7 @@ class flatpq_index {
343343
* Load constructor
344344
*/
345345
flatpq_index(tiledb::Context ctx, const std::string& group_uri) {
346-
tiledb::Config cfg;
347-
auto read_group = tiledb::Group(ctx, group_uri, TILEDB_READ, cfg);
346+
auto read_group = tiledb::Group(ctx, group_uri, TILEDB_READ, ctx.config());
348347

349348
for (auto& [name, value, datatype] : metadata) {
350349
if (!read_group.has_metadata(name, &datatype)) {
@@ -643,9 +642,9 @@ class flatpq_index {
643642
auto write_index(const std::string& group_uri) {
644643
tiledb::Context ctx;
645644

646-
tiledb::Config cfg;
647645
tiledb::Group::create(ctx, group_uri);
648-
auto write_group = tiledb::Group(ctx, group_uri, TILEDB_WRITE, cfg);
646+
auto write_group =
647+
tiledb::Group(ctx, group_uri, TILEDB_WRITE, ctx.config());
649648

650649
for (auto&& [name, value, type] : metadata) {
651650
write_group.put_metadata(name, type, 1, value);

src/include/index/index_group.h

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,13 @@ class base_index_group {
149149
*
150150
* @param ctx
151151
*/
152-
void init_for_open(const tiledb::Config& cfg) {
152+
void init_for_open() {
153153
if (!exists(cached_ctx_)) {
154154
throw std::runtime_error(
155155
"Group uri " + std::string(group_uri_) + " does not exist.");
156156
}
157-
auto read_group = tiledb::Group(cached_ctx_, group_uri_, TILEDB_READ, cfg);
157+
auto read_group = tiledb::Group(
158+
cached_ctx_, group_uri_, TILEDB_READ, cached_ctx_.config());
158159

159160
// Load the metadata and check the version. We need to do this before
160161
// we can check the array names.
@@ -193,8 +194,8 @@ class base_index_group {
193194
}
194195
}
195196

196-
void open_for_read(const tiledb::Config& cfg) {
197-
init_for_open(cfg);
197+
void open_for_read() {
198+
init_for_open();
198199

199200
if (size(metadata_.ingestion_timestamps_) == 0) {
200201
throw std::runtime_error("No ingestion timestamps found.");
@@ -235,10 +236,10 @@ class base_index_group {
235236
* @param uri
236237
* @param version
237238
*/
238-
void open_for_write(const tiledb::Config& cfg) {
239+
void open_for_write() {
239240
if (exists(cached_ctx_)) {
240241
/** Load the current group metadata */
241-
init_for_open(cfg);
242+
init_for_open();
242243
if (!metadata_.ingestion_timestamps_.empty() &&
243244
index_timestamp_ < metadata_.ingestion_timestamps_.back()) {
244245
throw std::runtime_error(
@@ -249,7 +250,7 @@ class base_index_group {
249250
}
250251
} else {
251252
/** Create a new group */
252-
create_default(cfg);
253+
create_default();
253254
}
254255
}
255256

@@ -260,8 +261,8 @@ class base_index_group {
260261
*
261262
* @todo Process the "base group" metadata here.
262263
*/
263-
void create_default(const tiledb::Config& cfg) {
264-
static_cast<group_type*>(this)->create_default_impl(cfg);
264+
void create_default() {
265+
static_cast<group_type*>(this)->create_default_impl();
265266
}
266267

267268
/** Convert an array key to a uri. */
@@ -307,20 +308,19 @@ class base_index_group {
307308
uint64_t dimension,
308309
tiledb_query_type_t rw = TILEDB_READ,
309310
size_t timestamp = 0,
310-
const std::string& version = std::string{""},
311-
const tiledb::Config& cfg = tiledb::Config{})
311+
const std::string& version = std::string{""})
312312
: cached_ctx_(ctx)
313313
, group_uri_(uri)
314314
, index_timestamp_(timestamp)
315315
, version_(version)
316316
, opened_for_(rw) {
317317
switch (opened_for_) {
318318
case TILEDB_READ:
319-
open_for_read(cfg);
319+
open_for_read();
320320
break;
321321
case TILEDB_WRITE:
322322
set_dimension(dimension);
323-
open_for_write(cfg);
323+
open_for_write();
324324
break;
325325
case TILEDB_MODIFY_EXCLUSIVE:
326326
break;
@@ -340,9 +340,8 @@ class base_index_group {
340340
*/
341341
~base_index_group() {
342342
if (opened_for_ == TILEDB_WRITE) {
343-
auto cfg = tiledb::Config();
344-
auto write_group =
345-
tiledb::Group(cached_ctx_, group_uri_, TILEDB_WRITE, cfg);
343+
auto write_group = tiledb::Group(
344+
cached_ctx_, group_uri_, TILEDB_WRITE, cached_ctx_.config());
346345
metadata_.store_metadata(write_group);
347346
}
348347
}
@@ -489,8 +488,8 @@ class base_index_group {
489488
}
490489
std::cout << "-------------------------------------------------------\n";
491490
std::cout << "Stored in " + group_uri_ + ":" << std::endl;
492-
auto cfg = tiledb::Config();
493-
auto read_group = tiledb::Group(cached_ctx_, group_uri_, TILEDB_READ, cfg);
491+
auto read_group = tiledb::Group(
492+
cached_ctx_, group_uri_, TILEDB_READ, cached_ctx_.config());
494493
for (size_t i = 0; i < read_group.member_count(); ++i) {
495494
auto member = read_group.member(i);
496495
auto name = member.name();

src/include/index/ivf_flat_group.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ class ivf_flat_index_group
8787
const std::string& uri,
8888
tiledb_query_type_t rw = TILEDB_READ,
8989
size_t timestamp = 0,
90-
const std::string& version = std::string{""},
91-
const tiledb::Config& cfg = tiledb::Config{})
92-
: Base(ctx, uri, index.dimension(), rw, timestamp, version, cfg) {
90+
const std::string& version = std::string{""})
91+
: Base(ctx, uri, index.dimension(), rw, timestamp, version) {
9392
}
9493

9594
public:
@@ -145,7 +144,7 @@ class ivf_flat_index_group
145144
return this->array_key_to_array_name("index_array_name");
146145
}
147146

148-
void create_default_impl(const tiledb::Config& cfg) {
147+
void create_default_impl() {
149148
if (empty(this->version_)) {
150149
this->version_ = current_storage_version;
151150
}
@@ -158,8 +157,8 @@ class ivf_flat_index_group
158157
string_to_filter(storage_formats[version_]["default_attr_filters"])};
159158

160159
tiledb::Group::create(cached_ctx_, group_uri_);
161-
auto write_group =
162-
tiledb::Group(cached_ctx_, group_uri_, TILEDB_WRITE, cfg);
160+
auto write_group = tiledb::Group(
161+
cached_ctx_, group_uri_, TILEDB_WRITE, cached_ctx_.config());
163162

164163
this->metadata_.storage_version_ = version_;
165164

src/include/index/vamana_group.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,8 @@ class vamana_index_group : public base_index_group<vamana_index_group<Index>> {
110110
const std::string& uri,
111111
tiledb_query_type_t rw = TILEDB_READ,
112112
size_t timestamp = 0,
113-
const std::string& version = std::string{""},
114-
const tiledb::Config& cfg = tiledb::Config{})
115-
: Base(ctx, uri, index.dimension(), rw, timestamp, version, cfg) {
113+
const std::string& version = std::string{""})
114+
: Base(ctx, uri, index.dimension(), rw, timestamp, version) {
116115
}
117116

118117
public:
@@ -209,7 +208,7 @@ class vamana_index_group : public base_index_group<vamana_index_group<Index>> {
209208
return this->array_key_to_array_name("adjacency_row_index_array_name");
210209
}
211210

212-
void create_default_impl(const tiledb::Config& cfg) {
211+
void create_default_impl() {
213212
if (empty(this->version_)) {
214213
this->version_ = current_storage_version;
215214
}
@@ -222,8 +221,8 @@ class vamana_index_group : public base_index_group<vamana_index_group<Index>> {
222221
string_to_filter(storage_formats[version_]["default_attr_filters"])};
223222

224223
tiledb::Group::create(cached_ctx_, group_uri_);
225-
auto write_group =
226-
tiledb::Group(cached_ctx_, group_uri_, TILEDB_WRITE, cfg);
224+
auto write_group = tiledb::Group(
225+
cached_ctx_, group_uri_, TILEDB_WRITE, cached_ctx_.config());
227226

228227
/**************************************************************************
229228
* Base group metadata setup

0 commit comments

Comments
 (0)