@@ -92,9 +92,6 @@ struct dummy_index {
9292 }
9393};
9494
95- // The catch2 check for exception doesn't seem to be working correctly
96- // @todo Fix this
97- #if 0
9895TEST_CASE (
9996 " ivf_flat_group: read constructor for non-existent group" ,
10097 " [ivf_flat_group]" ) {
@@ -104,7 +101,6 @@ TEST_CASE(
104101 ivf_flat_index_group (dummy_index{}, ctx, " I dont exist" ),
105102 " Group uri I dont exist does not exist." );
106103}
107- #endif
108104
109105TEST_CASE (" ivf_flat_group: write constructor - create" , " [ivf_flat_group]" ) {
110106 std::string tmp_uri = (std::filesystem::temp_directory_path () /
@@ -119,7 +115,6 @@ TEST_CASE("ivf_flat_group: write constructor - create", "[ivf_flat_group]") {
119115
120116 ivf_flat_index_group x =
121117 ivf_flat_index_group (dummy_index{}, ctx, tmp_uri, TILEDB_WRITE);
122- x.dump (" Write constructor - create" );
123118}
124119
125120TEST_CASE (
@@ -137,11 +132,9 @@ TEST_CASE(
137132
138133 ivf_flat_index_group x =
139134 ivf_flat_index_group (dummy_index{}, ctx, tmp_uri, TILEDB_WRITE);
140- x.dump (" Write constructor - create before open" );
141135
142136 ivf_flat_index_group y =
143137 ivf_flat_index_group (dummy_index{}, ctx, tmp_uri, TILEDB_WRITE);
144- x.dump (" Write constructor - open" );
145138}
146139
147140TEST_CASE (
@@ -159,11 +152,9 @@ TEST_CASE(
159152
160153 ivf_flat_index_group x =
161154 ivf_flat_index_group (dummy_index{}, ctx, tmp_uri, TILEDB_WRITE);
162- x.dump (" Write constructor - create before open" );
163155
164156 ivf_flat_index_group y =
165157 ivf_flat_index_group (dummy_index{}, ctx, tmp_uri, TILEDB_READ);
166- x.dump (" Write constructor - open for read" );
167158}
168159
169160TEST_CASE (
@@ -182,15 +173,12 @@ TEST_CASE(
182173
183174 ivf_flat_index_group x =
184175 ivf_flat_index_group (dummy_index{}, ctx, tmp_uri, TILEDB_WRITE);
185- x.dump (" Write constructor - create before open" );
186176
187177 ivf_flat_index_group y =
188178 ivf_flat_index_group (dummy_index{}, ctx, tmp_uri, TILEDB_WRITE);
189- x.dump (" Write constructor - open for write" );
190179
191180 ivf_flat_index_group z =
192181 ivf_flat_index_group (dummy_index{}, ctx, tmp_uri, TILEDB_READ);
193- x.dump (" Write constructor - open for read" );
194182}
195183
196184TEST_CASE (
@@ -365,3 +353,81 @@ TEST_CASE(
365353 CHECK (x.get_temp_size () == expected_temp_size + offset);
366354 CHECK (x.get_dimension () == expected_dimension + offset);
367355}
356+
357+ TEST_CASE (" ivf_flat_group: storage version" , " [ivf_flat_group]" ) {
358+ std::string tmp_uri =
359+ (std::filesystem::temp_directory_path () / " ivf_flat_group" ).string ();
360+
361+ tiledb::Context ctx;
362+ tiledb::VFS vfs (ctx);
363+ if (vfs.is_dir (tmp_uri)) {
364+ vfs.remove_dir (tmp_uri);
365+ }
366+
367+ size_t expected_ingestion = 23094 ;
368+ size_t expected_base = 9234 ;
369+ size_t expected_partitions = 200 ;
370+ size_t expected_temp_size = 11 ;
371+ size_t expected_dimension = 19238 ;
372+ auto offset = 2345 ;
373+
374+ ivf_flat_index_group x =
375+ ivf_flat_index_group (dummy_index{}, ctx, tmp_uri, TILEDB_WRITE);
376+
377+ SECTION (" 0.3" ) {
378+ x = ivf_flat_index_group (
379+ dummy_index{}, ctx, tmp_uri, TILEDB_WRITE, 0 , " 0.3" );
380+ }
381+
382+ SECTION (" current_storage_version" ) {
383+ x = ivf_flat_index_group (
384+ dummy_index{}, ctx, tmp_uri, TILEDB_WRITE, 0 , current_storage_version);
385+ }
386+
387+ x.set_ingestion_timestamp (expected_ingestion + offset);
388+ x.set_base_size (expected_base + offset);
389+ x.set_num_partitions (expected_partitions + offset);
390+ x.set_temp_size (expected_temp_size + offset);
391+ x.set_dimension (expected_dimension + offset);
392+
393+ CHECK (size (x.get_all_ingestion_timestamps ()) == 1 );
394+ CHECK (size (x.get_all_base_sizes ()) == 1 );
395+ CHECK (size (x.get_all_num_partitions ()) == 1 );
396+ CHECK (x.get_previous_ingestion_timestamp () == expected_ingestion + offset);
397+ CHECK (x.get_previous_base_size () == expected_base + offset);
398+ CHECK (x.get_previous_num_partitions () == expected_partitions + offset);
399+ CHECK (x.get_temp_size () == expected_temp_size + offset);
400+ CHECK (x.get_dimension () == expected_dimension + offset);
401+ }
402+
403+ TEST_CASE (" ivf_flat_group: invalid storage version" , " [ivf_flat_group]" ) {
404+ std::string tmp_uri =
405+ (std::filesystem::temp_directory_path () / " ivf_flat_group" ).string ();
406+
407+ tiledb::Context ctx;
408+ tiledb::VFS vfs (ctx);
409+ if (vfs.is_dir (tmp_uri)) {
410+ vfs.remove_dir (tmp_uri);
411+ }
412+ CHECK_THROWS (ivf_flat_index_group (
413+ dummy_index{}, ctx, tmp_uri, TILEDB_WRITE, 0 , " invalid" ));
414+ }
415+
416+ TEST_CASE (" ivf_flat_group: mismatched storage version" , " [ivf_flat_group]" ) {
417+ std::string tmp_uri =
418+ (std::filesystem::temp_directory_path () / " ivf_flat_group" ).string ();
419+
420+ tiledb::Context ctx;
421+ tiledb::VFS vfs (ctx);
422+ if (vfs.is_dir (tmp_uri)) {
423+ vfs.remove_dir (tmp_uri);
424+ }
425+
426+ ivf_flat_index_group x =
427+ ivf_flat_index_group (dummy_index{}, ctx, tmp_uri, TILEDB_WRITE, 0 , " 0.3" );
428+
429+ CHECK_THROWS_WITH (
430+ ivf_flat_index_group (
431+ dummy_index{}, ctx, tmp_uri, TILEDB_WRITE, 0 , " different_version" ),
432+ " Version mismatch. Requested different_version but found 0.3" );
433+ }
0 commit comments