File tree Expand file tree Collapse file tree 5 files changed +16
-22
lines changed
Expand file tree Collapse file tree 5 files changed +16
-22
lines changed Original file line number Diff line number Diff line change 11## 0.1.5 (unreleased)
22
33- Added support for ` halfvec ` , ` bit ` , and ` sparsevec ` types
4+ - Added ` registerTypes ` function
45
56## 0.1.4 (2023-12-08)
67
Original file line number Diff line number Diff line change @@ -100,14 +100,4 @@ public String getValue() {
100100 public float [] toArray () {
101101 return vec ;
102102 }
103-
104- /**
105- * Registers the halfvec type
106- *
107- * @param conn connection
108- * @throws SQLException exception
109- */
110- public static void addHalfvecType (Connection conn ) throws SQLException {
111- conn .unwrap (PGConnection .class ).addDataType ("halfvec" , PGhalfvec .class );
112- }
113103}
Original file line number Diff line number Diff line change @@ -278,14 +278,4 @@ public int[] getIndices() {
278278 public float [] getValues () {
279279 return values ;
280280 }
281-
282- /**
283- * Registers the sparsevec type
284- *
285- * @param conn connection
286- * @throws SQLException exception
287- */
288- public static void addSparsevecType (Connection conn ) throws SQLException {
289- conn .unwrap (PGConnection .class ).addDataType ("sparsevec" , PGsparsevec .class );
290- }
291281}
Original file line number Diff line number Diff line change @@ -149,4 +149,17 @@ public float[] toArray() {
149149 public static void addVectorType (Connection conn ) throws SQLException {
150150 conn .unwrap (PGConnection .class ).addDataType ("vector" , PGvector .class );
151151 }
152+
153+ /**
154+ * Registers the vector, halfvec, and sparsevec types
155+ *
156+ * @param conn connection
157+ * @throws SQLException exception
158+ */
159+ public static void registerTypes (Connection conn ) throws SQLException {
160+ // bit type should be registered separately
161+ addVectorType (conn );
162+ conn .unwrap (PGConnection .class ).addDataType ("halfvec" , PGhalfvec .class );
163+ conn .unwrap (PGConnection .class ).addDataType ("sparsevec" , PGsparsevec .class );
164+ }
152165}
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ void halfvecExample(boolean readBinary) throws SQLException {
9090 setupStmt .executeUpdate ("CREATE EXTENSION IF NOT EXISTS vector" );
9191 setupStmt .executeUpdate ("DROP TABLE IF EXISTS jdbc_items" );
9292
93- PGhalfvec . addHalfvecType (conn );
93+ PGvector . registerTypes (conn );
9494
9595 Statement createStmt = conn .createStatement ();
9696 createStmt .executeUpdate ("CREATE TABLE jdbc_items (id bigserial PRIMARY KEY, embedding halfvec(3))" );
@@ -191,7 +191,7 @@ void sparsevecExample(boolean readBinary) throws SQLException {
191191 setupStmt .executeUpdate ("CREATE EXTENSION IF NOT EXISTS vector" );
192192 setupStmt .executeUpdate ("DROP TABLE IF EXISTS jdbc_items" );
193193
194- PGsparsevec . addSparsevecType (conn );
194+ PGvector . registerTypes (conn );
195195
196196 Statement createStmt = conn .createStatement ();
197197 createStmt .executeUpdate ("CREATE TABLE jdbc_items (id bigserial PRIMARY KEY, embedding sparsevec(3))" );
You can’t perform that action at this time.
0 commit comments