11// SPDX-License-Identifier: Apache-2.0
22// SPDX-FileCopyrightText: Copyright the Vortex contributors
33
4- use std:: path:: PathBuf ;
54use std:: time:: { Duration , Instant } ;
65
76use anyhow:: Result ;
@@ -31,7 +30,6 @@ impl DuckDBObject {
3130pub struct DuckDBCtx {
3231 pub db : Database ,
3332 pub connection : Connection ,
34- pub db_path : Option < PathBuf > ,
3533}
3634
3735impl DuckDBCtx {
@@ -53,40 +51,17 @@ impl DuckDBCtx {
5351 if delete_database {
5452 std:: fs:: remove_file ( & db_path) ?;
5553 }
56- let db = Database :: open ( & db_path) ?;
54+ let db = Database :: open ( db_path) ?;
5755 let connection = db. connect ( ) ?;
5856 vortex_duckdb:: register_table_functions ( & connection) ?;
59-
60- Ok ( Self {
61- db,
62- connection,
63- db_path : Some ( db_path) ,
64- } )
65- }
66-
67- pub fn reopen ( & mut self ) -> Result < ( ) > {
68- let mut db = match & self . db_path {
69- Some ( path) => Database :: open ( path) ,
70- None => Database :: open_in_memory ( ) ,
71- } ?;
72- let mut connection = db. connect ( ) ?;
73- vortex_duckdb:: register_table_functions ( & connection) ?;
74-
75- std:: mem:: swap ( & mut self . connection , & mut connection) ;
76- std:: mem:: swap ( & mut self . db , & mut db) ;
77-
78- Ok ( ( ) )
57+ Ok ( Self { db, connection } )
7958 }
8059
8160 pub fn new_in_memory ( ) -> Result < Self > {
8261 let db = Database :: open_in_memory ( ) ?;
8362 let connection = db. connect ( ) ?;
8463 vortex_duckdb:: register_table_functions ( & connection) ?;
85- Ok ( Self {
86- db,
87- connection,
88- db_path : None ,
89- } )
64+ Ok ( Self { db, connection } )
9065 }
9166
9267 /// Execute DuckDB queries for benchmarks using the internal connection
0 commit comments