Skip to content

Commit 5e5ba17

Browse files
committed
HHH-17357 Rename hibernate-types module to hibernate-vector
1 parent 6bbf589 commit 5e5ba17

File tree

14 files changed

+51
-57
lines changed

14 files changed

+51
-57
lines changed

Diff for: documentation/src/main/asciidoc/userguide/Hibernate_User_Guide.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ include::chapters/query/hql/QueryLanguage.adoc[]
3434
include::chapters/query/criteria/Criteria.adoc[]
3535
include::chapters/query/native/Native.adoc[]
3636
include::chapters/query/spatial/Spatial.adoc[]
37-
include::chapters/query/types/TypesModule.adoc[]
37+
include::chapters/query/extensions/Vector.adoc[]
3838
include::chapters/multitenancy/MultiTenancy.adoc[]
3939
include::chapters/envers/Envers.adoc[]
4040
include::chapters/beans/Beans.adoc[]

Diff for: documentation/src/main/asciidoc/userguide/chapters/query/types/TypesModule.adoc renamed to documentation/src/main/asciidoc/userguide/chapters/query/extensions/Vector.adoc

+40-46
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
1-
[[types-module]]
2-
== Hibernate Types module
1+
[[vector-module]]
2+
== Hibernate Vector module
33
:root-project-dir: ../../../../../../../..
4-
:types-project-dir: {root-project-dir}/hibernate-types
5-
:example-dir-types: {types-project-dir}/src/test/java/org/hibernate/types
4+
:vector-project-dir: {root-project-dir}/hibernate-vector
5+
:example-dir-vector: {vector-project-dir}/src/test/java/org/hibernate/vector
66
:extrasdir: extras
77

8-
[[types-module-overview]]
8+
[[vector-module-overview]]
99
=== Overview
1010

11-
The Hibernate ORM core module tries to be as minimal as possible and only model functionality
12-
that is somewhat "standard" in the SQL space or can only be modeled as part of the core module.
13-
To avoid growing that module further unnecessarily, support for certain special SQL types or functions
14-
is separated out into the Hibernate ORM types module.
11+
The Hibernate ORM Vector module contains support for mathematical vector types and functions.
12+
This is useful for AI/ML topics like vector similarity search.
13+
The module comes with support for a special `vector` data type that essentially represents an array of floats.
1514

16-
[[types-module-setup]]
15+
So far, only the PostgreSQL extension `pgvector` is supported, but in theory,
16+
the vector specific functions could be implemented to work with every database that supports arrays.
17+
18+
For further details, refer to the https://github.com/pgvector/pgvector#querying[pgvector documentation].
19+
20+
[[vector-module-setup]]
1721
=== Setup
1822

19-
You need to include the `hibernate-types` dependency in your build environment.
23+
You need to include the `hibernate-vector` dependency in your build environment.
2024
For Maven, you need to add the following dependency:
2125

22-
[[types-module-setup-maven-example]]
26+
[[vector-module-setup-maven-example]]
2327
.Maven dependency
2428
====
2529
[source,xml]
2630
----
2731
<dependency>
2832
<groupId>org.hibernate.orm</groupId>
29-
<artifactId>hibernate-types</artifactId>
33+
<artifactId>hibernate-vector</artifactId>
3034
<version>${hibernate.version}</version>
3135
</dependency>
3236
----
@@ -35,37 +39,27 @@ For Maven, you need to add the following dependency:
3539
The module contains service implementations that are picked up by the Java `ServiceLoader` automatically,
3640
so no further configuration is necessary to make the features available.
3741

38-
[[types-module-vector]]
39-
=== Vector type support
40-
41-
The Hibernate ORM types module comes with support for a special `vector` data type that essentially represents an array of floats.
42-
43-
So far, only the PostgreSQL extension `pgvector` is supported, but in theory,
44-
the vector specific functions could be implemented to work with every database that supports arrays.
45-
46-
For further details, refer to the https://github.com/pgvector/pgvector#querying[pgvector documentation].
47-
48-
[[types-module-vector-usage]]
42+
[[vector-module-usage]]
4943
==== Usage
5044

5145
Annotate a persistent attribute with `@JdbcTypeCode(SqlTypes.VECTOR)` and specify the vector length with `@Array(length = ...)`.
5246

53-
[[types-module-vector-usage-example]]
47+
[[vector-module-usage-example]]
5448
====
5549
[source, JAVA, indent=0]
5650
----
57-
include::{example-dir-types}/vector/PGVectorTest.java[tags=usage-example]
51+
include::{example-dir-vector}/PGVectorTest.java[tags=usage-example]
5852
----
5953
====
6054

6155
To cast the string representation of a vector to the vector data type, simply use an HQL cast i.e. `cast('[1,2,3]' as vector)`.
6256

63-
[[types-module-vector-functions]]
57+
[[vector-module-functions]]
6458
==== Functions
6559

6660
Expressions of the vector type can be used with various vector functions.
6761

68-
[[types-module-vector-functions-overview]]
62+
[[vector-module-functions-overview]]
6963
|===
7064
| Function | Purpose
7165

@@ -88,89 +82,89 @@ In addition to these special vector functions, it is also possible to use vector
8882
`sum(<vector1>) = <vector2>`:: Aggregate function support for element-wise summation of vectors.
8983
`avg(<vector1>) = <vector2>`:: Aggregate function support for element-wise average of vectors.
9084

91-
[[types-module-vector-functions-cosine-distance]]
85+
[[vector-module-functions-cosine-distance]]
9286
===== `cosine_distance()`
9387

9488
Computes the https://en.wikipedia.org/wiki/Cosine_similarity[cosine distance] between two vectors,
9589
which is `1 - inner_product( v1, v2 ) / ( vector_norm( v1 ) * vector_norm( v2 ) )`. Maps to the `<``=``>` pgvector operator.
9690

97-
[[types-module-vector-functions-cosine-distance-example]]
91+
[[vector-module-functions-cosine-distance-example]]
9892
====
9993
[source, JAVA, indent=0]
10094
----
101-
include::{example-dir-types}/vector/PGVectorTest.java[tags=cosine-distance-example]
95+
include::{example-dir-vector}/PGVectorTest.java[tags=cosine-distance-example]
10296
----
10397
====
10498

105-
[[types-module-vector-functions-euclidean-distance]]
99+
[[vector-module-functions-euclidean-distance]]
106100
===== `euclidean_distance()` and `l2_distance()`
107101

108102
Computes the https://en.wikipedia.org/wiki/Euclidean_distance[euclidean distance] between two vectors,
109103
which is `sqrt( sum( (v1_i - v2_i)^2 ) )`. Maps to the `<``-``>` pgvector operator.
110104
The `l2_distance()` function is an alias.
111105

112-
[[types-module-vector-functions-euclidean-distance-example]]
106+
[[vector-module-functions-euclidean-distance-example]]
113107
====
114108
[source, JAVA, indent=0]
115109
----
116-
include::{example-dir-types}/vector/PGVectorTest.java[tags=euclidean-distance-example]
110+
include::{example-dir-vector}/PGVectorTest.java[tags=euclidean-distance-example]
117111
----
118112
====
119113

120-
[[types-module-vector-functions-taxicab-distance]]
114+
[[vector-module-functions-taxicab-distance]]
121115
===== `taxicab_distance()` and `l1_distance()`
122116

123117
Computes the https://en.wikipedia.org/wiki/Taxicab_geometry[taxicab distance] between two vectors,
124118
which is `vector_norm(v1) - vector_norm(v2)`.
125119
The `l1_distance()` function is an alias.
126120

127-
[[types-module-vector-functions-taxicab-distance-example]]
121+
[[vector-module-functions-taxicab-distance-example]]
128122
====
129123
[source, JAVA, indent=0]
130124
----
131-
include::{example-dir-types}/vector/PGVectorTest.java[tags=taxicab-distance-example]
125+
include::{example-dir-vector}/PGVectorTest.java[tags=taxicab-distance-example]
132126
----
133127
====
134128

135-
[[types-module-vector-functions-inner-product]]
129+
[[vector-module-functions-inner-product]]
136130
===== `inner_product()` and `negative_inner_product()`
137131

138132
Computes the https://en.wikipedia.org/wiki/Inner_product_space[inner product] between two vectors,
139133
which is `sum( v1_i * v2_i )`. The `negative_inner_product()` function maps to the `<``#``>` pgvector operator,
140134
and the `inner_product()` function as well, but multiplies the result time `-1`.
141135

142-
[[types-module-vector-functions-inner-product-example]]
136+
[[vector-module-functions-inner-product-example]]
143137
====
144138
[source, JAVA, indent=0]
145139
----
146-
include::{example-dir-types}/vector/PGVectorTest.java[tags=inner-product-example]
140+
include::{example-dir-vector}/PGVectorTest.java[tags=inner-product-example]
147141
----
148142
====
149143

150-
[[types-module-vector-functions-vector-dims]]
144+
[[vector-module-functions-vector-dims]]
151145
===== `vector_dims()`
152146

153147
Determines the dimensions of a vector.
154148

155-
[[types-module-vector-functions-vector-dims-example]]
149+
[[vector-module-functions-vector-dims-example]]
156150
====
157151
[source, JAVA, indent=0]
158152
----
159-
include::{example-dir-types}/vector/PGVectorTest.java[tags=vector-dims-example]
153+
include::{example-dir-vector}/PGVectorTest.java[tags=vector-dims-example]
160154
----
161155
====
162156

163-
[[types-module-vector-functions-vector-norm]]
157+
[[vector-module-functions-vector-norm]]
164158
===== `vector_norm()`
165159

166160
Computes the https://en.wikipedia.org/wiki/Euclidean_space#Euclidean_norm[Euclidean norm] of a vector,
167161
which is `sqrt( sum( v_i^2 ) )`.
168162

169-
[[types-module-vector-functions-vector-norm-example]]
163+
[[vector-module-functions-vector-norm-example]]
170164
====
171165
[source, JAVA, indent=0]
172166
----
173-
include::{example-dir-types}/vector/PGVectorTest.java[tags=vector-norm-example]
167+
include::{example-dir-vector}/PGVectorTest.java[tags=vector-norm-example]
174168
----
175169
====
176170

Diff for: hibernate-types/src/main/resources/META-INF/services/org.hibernate.boot.model.FunctionContributor

-1
This file was deleted.

Diff for: hibernate-types/src/main/resources/META-INF/services/org.hibernate.boot.model.TypeContributor

-1
This file was deleted.

Diff for: hibernate-types/hibernate-types.gradle renamed to hibernate-vector/hibernate-vector.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
66
*/
77

8-
description = 'Hibernate\'s type extensions'
8+
description = 'Hibernate\'s extensions for vector support'
99

1010
apply from: rootProject.file( 'gradle/published-java-module.gradle' )
1111

Diff for: hibernate-types/src/main/java/org/hibernate/types/vector/PGVectorFunctionContributor.java renamed to hibernate-vector/src/main/java/org/hibernate/vector/PGVectorFunctionContributor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
55
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
66
*/
7-
package org.hibernate.types.vector;
7+
package org.hibernate.vector;
88

99
import org.hibernate.boot.model.FunctionContributions;
1010
import org.hibernate.boot.model.FunctionContributor;

Diff for: hibernate-types/src/main/java/org/hibernate/types/vector/PGVectorTypeContributor.java renamed to hibernate-vector/src/main/java/org/hibernate/vector/PGVectorTypeContributor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
55
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
66
*/
7-
package org.hibernate.types.vector;
7+
package org.hibernate.vector;
88

99
import java.lang.reflect.Type;
1010

Diff for: hibernate-types/src/main/java/org/hibernate/types/vector/VectorArgumentTypeResolver.java renamed to hibernate-vector/src/main/java/org/hibernate/vector/VectorArgumentTypeResolver.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
55
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
66
*/
7-
package org.hibernate.types.vector;
7+
package org.hibernate.vector;
88

99
import java.util.List;
1010

Diff for: hibernate-types/src/main/java/org/hibernate/types/vector/VectorArgumentValidator.java renamed to hibernate-vector/src/main/java/org/hibernate/vector/VectorArgumentValidator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
55
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
66
*/
7-
package org.hibernate.types.vector;
7+
package org.hibernate.vector;
88

99
import java.util.List;
1010

Diff for: hibernate-types/src/main/java/org/hibernate/types/vector/VectorJdbcType.java renamed to hibernate-vector/src/main/java/org/hibernate/vector/VectorJdbcType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
55
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
66
*/
7-
package org.hibernate.types.vector;
7+
package org.hibernate.vector;
88

99
import java.sql.CallableStatement;
1010
import java.sql.ResultSet;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.hibernate.vector.PGVectorFunctionContributor
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.hibernate.vector.PGVectorTypeContributor

Diff for: hibernate-types/src/test/java/org/hibernate/types/vector/PGVectorTest.java renamed to hibernate-vector/src/test/java/org/hibernate/vector/PGVectorTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
55
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
66
*/
7-
package org.hibernate.types.vector;
7+
package org.hibernate.vector;
88

99
import java.util.List;
1010

Diff for: settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ include 'hibernate-spatial'
300300
include 'hibernate-platform'
301301

302302
include 'hibernate-community-dialects'
303-
include 'hibernate-types'
303+
include 'hibernate-vector'
304304

305305
include 'hibernate-c3p0'
306306
include 'hibernate-proxool'

0 commit comments

Comments
 (0)