diff --git a/polydata-sqlite/src/main/java/com/unidev/polydata4/sqlite/PolydataSqlite.java b/polydata-sqlite/src/main/java/com/unidev/polydata4/sqlite/PolydataSqlite.java index 5628646..3220922 100644 --- a/polydata-sqlite/src/main/java/com/unidev/polydata4/sqlite/PolydataSqlite.java +++ b/polydata-sqlite/src/main/java/com/unidev/polydata4/sqlite/PolydataSqlite.java @@ -42,7 +42,9 @@ public class PolydataSqlite extends AbstractPolydata { private final File rootDir; private final ObjectMapper objectMapper; - private final Map connections = new ConcurrentHashMap<>(); + private final Map datasourcesMap = new ConcurrentHashMap<>(); + + private final Map connectionMap = new ConcurrentHashMap<>(); private static Set buildTagIndex(InsertRequest request) { Set indexToPersist = request.getIndexToPersist(); @@ -437,7 +439,11 @@ public BasicPolyList list() { @Override public void open() { - + BasicPolyList list = list(); + list.list().forEach(poly -> { + String name = poly._id(); + fetchConnection(name); + }); } @Override @@ -511,7 +517,7 @@ private Optional readInternal(String dataset, String id) { } private SQLiteDataSource fetchDataSource(String dataset) { - return connections.computeIfAbsent(dataset, k -> { + return datasourcesMap.computeIfAbsent(dataset, k -> { File dbFile = getDbFile(k); SQLiteDataSource sqLiteDataSource = new SQLiteDataSource(); sqLiteDataSource.setUrl("jdbc:sqlite:" + dbFile.getAbsolutePath()); @@ -524,8 +530,6 @@ private File getDbFile(String dataset) { return dbFile; } - private final Map connectionMap = new ConcurrentHashMap<>(); - private Connection fetchConnection(String dataset) { return connectionMap.computeIfAbsent(dataset, k -> { try {