Serialising dynamic arrays in SQL; read-only SQLite connection in SQL Dataset

Summary:
1. We may need to store arrays of unknown shape in the database. It implements and tests serialisation.

2. Previously, when an inexisting metadata file was passed to SqlIndexDataset, it would try to open it and create an empty file, then crash. We now open the file in a read-only mode, so the error message is more intuitive. Note that the implementation is SQLite specific.

Reviewed By: bottler

Differential Revision: D46047857

fbshipit-source-id: 3064ae4f8122b4fc24ad3d6ab696572ebe8d0c26
This commit is contained in:
Roman Shapovalov
2023-05-22 02:24:49 -07:00
committed by Facebook GitHub Bot
parent ff80183fdb
commit d2119c285f
3 changed files with 60 additions and 5 deletions

View File

@@ -142,8 +142,10 @@ class SqlIndexDataset(DatasetBase, ReplaceableBase): # pyre-ignore
run_auto_creation(self)
self.frame_data_builder.path_manager = self.path_manager
# pyre-ignore
self._sql_engine = sa.create_engine(f"sqlite:///{self.sqlite_metadata_file}")
# pyre-ignore # NOTE: sqlite-specific args (read-only mode).
self._sql_engine = sa.create_engine(
f"sqlite:///file:{self.sqlite_metadata_file}?mode=ro&uri=true"
)
sequences = self._get_filtered_sequences_if_any()