@@ -16,6 +16,7 @@ public class Embeddings {
16
16
17
17
private Connection connection ;
18
18
private Gson gson ;
19
+ private PreparedStatement stmt ;
19
20
20
21
public Embeddings () {
21
22
this .gson = new Gson ();
@@ -28,10 +29,15 @@ public void loadEmbeddingsFromFile(String sqlitePath) throws IOException {
28
29
config .setReadOnly (true );
29
30
config .setOpenMode (SQLiteOpenMode .READONLY );
30
31
this .connection = DriverManager .getConnection ("jdbc:sqlite:" + sqlitePath , config .toProperties ());
32
+ this .stmt = this .connection .prepareStatement (
33
+ "SELECT embeddings FROM embeddings WHERE ontologyId = ? AND entityType = ? AND iri = ?"
34
+ );
35
+
31
36
} catch (SQLException e ) {
32
37
e .printStackTrace ();
33
38
return ;
34
39
}
40
+
35
41
}
36
42
37
43
public double [] getEmbeddings (String ontologyId , String entityType , String iri ) {
@@ -42,12 +48,10 @@ public double[] getEmbeddings(String ontologyId, String entityType, String iri)
42
48
43
49
try {
44
50
45
- var stmt = this .connection .prepareStatement ("SELECT embeddings FROM embeddings WHERE ontologyId = ? AND entityType = ? AND iri = ?" );
46
-
47
- stmt .setString (1 , ontologyId );
48
- stmt .setString (2 , entityType );
49
- stmt .setString (3 , iri );
50
- var rs = stmt .executeQuery ();
51
+ this .stmt .setString (1 , ontologyId );
52
+ this .stmt .setString (2 , entityType );
53
+ this .stmt .setString (3 , iri );
54
+ var rs = this .stmt .executeQuery ();
51
55
if (rs .next ()) {
52
56
String embeddingString = rs .getString ("embeddings" );
53
57
0 commit comments