Skip to content

Commit 960d74e

Browse files
committed
HHH-19705 Carry array length through to allow fixed size vector type expressions for DB2
1 parent e87dc4f commit 960d74e

File tree

144 files changed

+2581
-403
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+2581
-403
lines changed

docker_db.sh

Lines changed: 110 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@ if command -v docker > /dev/null; then
44
CONTAINER_CLI=$(command -v docker)
55
HEALTCHECK_PATH="{{.State.Health.Status}}"
66
PRIVILEGED_CLI=""
7+
IS_PODMAN=false
8+
if [[ "$(docker version | grep Podman)" == "" ]]; then
9+
IS_DOCKER_RUNTIME=true
10+
else
11+
IS_DOCKER_RUNTIME=false
12+
fi
713
else
814
CONTAINER_CLI=$(command -v podman)
915
HEALTCHECK_PATH="{{.State.Healthcheck.Status}}"
16+
IS_PODMAN=true
17+
IS_DOCKER_RUNTIME=false
1018
# Only use sudo for podman
1119
if command -v sudo > /dev/null; then
1220
PRIVILEGED_CLI="sudo"
@@ -15,6 +23,12 @@ else
1523
fi
1624
fi
1725

26+
if [[ "$(uname -s)" == "Darwin" ]]; then
27+
IS_OSX=true
28+
else
29+
IS_OSX=false
30+
fi
31+
1832
mysql() {
1933
mysql_9_4
2034
}
@@ -292,29 +306,93 @@ db2() {
292306
}
293307

294308
db2_11_5() {
295-
$PRIVILEGED_CLI $CONTAINER_CLI rm -f db2 || true
296-
$PRIVILEGED_CLI $CONTAINER_CLI run --name db2 --privileged -e DB2INSTANCE=orm_test -e DB2INST1_PASSWORD=orm_test -e DBNAME=orm_test -e LICENSE=accept -e AUTOCONFIG=false -e ARCHIVE_LOGS=false -e TO_CREATE_SAMPLEDB=false -e REPODB=false -p 50000:50000 -d ${DB_IMAGE_DB2_11_5:-icr.io/db2_community/db2:11.5.9.0}
309+
CONTAINER_OPTIONS=""
310+
if [[ "$IS_OSX" == "true" ]]; then
311+
# Thanks to Mohamed Asfour https://community.ibm.com/community/user/discussion/db2-luw-115xx-mac-m1-ready#bm017584d2-8d76-42a6-8f76-018dac8e78f2
312+
# This SO post explains what goes wrong on OSX: https://stackoverflow.com/questions/70175677/ibmcom-db2-docker-image-fails-on-m1
313+
# Also, use the $HOME directory as base directory to make volume mounts work on Colima on Mac
314+
db2install=$HOME/db2install.sh
315+
rm -f ${db2install} || true
316+
cat <<'EOF' >${db2install}
317+
#!/bin/bash
318+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - db2inst1 -c '/su - db2inst1 -c '. .profile \&\& /g" {} +
319+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - db2inst1 -c \"/su - db2inst1 -c \". .profile \&\& /g" {} +
320+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${DB2INSTANCE?} -c '/su - \${DB2INSTANCE?} -c '. .profile \&\& /g" {} +
321+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${DB2INSTANCE?} -c \"/su - \${DB2INSTANCE?} -c \". .profile \&\& /g" {} +
322+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${instance?} -c '/su - \${instance?} -c '. .profile \&\& /g" {} +
323+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${instance?} -c \"/su - \${instance?} -c \". .profile \&\& /g" {} +
324+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${instance_name?} -c '/su - \${instance_name?} -c '. .profile \&\& /g" {} +
325+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${instance_name?} -c \"/su - \${instance_name?} -c \". .profile \&\& /g" {} +
326+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - db2inst1 -c \\\\\"/su - db2inst1 -c \\\". .profile \&\& /g" {} +
327+
. /var/db2_setup/lib/setup_db2_instance.sh
328+
EOF
329+
chmod 777 ${db2install}
330+
if [[ "$IS_PODMAN" == "true" ]]; then
331+
CONTAINER_OPTIONS='--platform=linux/amd64 -e IS_OSXFS=true -v '${db2install}':/db2install.sh --entrypoint=["/bin/bash","-c","/db2install.sh"]'
332+
CONTAINER_ARGS=
333+
else
334+
CONTAINER_OPTIONS='--platform=linux/amd64 -e IS_OSXFS=true -v '${db2install}':/db2install.sh --entrypoint=/bin/bash'
335+
CONTAINER_ARGS=" -c /db2install.sh"
336+
fi
337+
if [[ "$IS_PODMAN" == "false" ]]; then
338+
export DOCKER_DEFAULT_PLATFORM=linux/amd64
339+
fi
340+
fi
341+
$CONTAINER_CLI rm -f db2 || true
342+
$CONTAINER_CLI run --name db2 --privileged -e DB2INSTANCE=orm_test -e DB2INST1_PASSWORD=orm_test -e DBNAME=orm_test -e LICENSE=accept -e AUTOCONFIG=false -e ARCHIVE_LOGS=false -e TO_CREATE_SAMPLEDB=false -e REPODB=false -e BLU=false -e ENABLE_ORACLE_COMPATIBILITY=false -e UPDATEAVAIL=NO -e PERSISTENT_HOME=true -e HADR_ENABLED=false -p 50000:50000 $CONTAINER_OPTIONS -d ${DB_IMAGE_DB2_11_5:-icr.io/db2_community/db2:11.5.9.0} $CONTAINER_ARGS
297343
# Give the container some time to start
298344
OUTPUT=
299345
while [[ $OUTPUT != *"INSTANCE"* ]]; do
300346
echo "Waiting for DB2 to start..."
301347
sleep 10
302-
OUTPUT=$($PRIVILEGED_CLI $CONTAINER_CLI logs db2 2>&1)
348+
OUTPUT=$($CONTAINER_CLI logs db2 2>&1)
303349
done
304-
$PRIVILEGED_CLI $CONTAINER_CLI exec -t db2 su - orm_test bash -c ". /database/config/orm_test/sqllib/db2profile; /database/config/orm_test/sqllib/bin/db2 'connect to orm_test'; /database/config/orm_test/sqllib/bin/db2 'CREATE USER TEMPORARY TABLESPACE usr_tbsp MANAGED BY AUTOMATIC STORAGE'"
350+
$CONTAINER_CLI exec -t db2 su - orm_test bash -c ". /database/config/orm_test/sqllib/db2profile; /database/config/orm_test/sqllib/bin/db2 'connect to orm_test'; /database/config/orm_test/sqllib/bin/db2 'CREATE USER TEMPORARY TABLESPACE usr_tbsp MANAGED BY AUTOMATIC STORAGE'"
305351
}
306352

307353
db2_12_1() {
308-
$PRIVILEGED_CLI $CONTAINER_CLI rm -f db2 || true
309-
$PRIVILEGED_CLI $CONTAINER_CLI run --name db2 --privileged -e DB2INSTANCE=orm_test -e DB2INST1_PASSWORD=orm_test -e DBNAME=orm_test -e LICENSE=accept -e AUTOCONFIG=false -e ARCHIVE_LOGS=false -e TO_CREATE_SAMPLEDB=false -e REPODB=false -p 50000:50000 -d ${DB_IMAGE_DB2_11_5:-icr.io/db2_community/db2:12.1.2.0}
354+
CONTAINER_OPTIONS=""
355+
if [[ "$IS_OSX" == "true" ]]; then
356+
# Thanks to Mohamed Asfour https://community.ibm.com/community/user/discussion/db2-luw-115xx-mac-m1-ready#bm017584d2-8d76-42a6-8f76-018dac8e78f2
357+
# This SO post explains what goes wrong on OSX: https://stackoverflow.com/questions/70175677/ibmcom-db2-docker-image-fails-on-m1
358+
# Also, use the $HOME directory as base directory to make volume mounts work on Colima on Mac
359+
db2install=$HOME/db2install.sh
360+
rm -f ${db2install} || true
361+
cat <<'EOF' >${db2install}
362+
#!/bin/bash
363+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - db2inst1 -c '/su - db2inst1 -c '. .profile \&\& /g" {} +
364+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - db2inst1 -c \"/su - db2inst1 -c \". .profile \&\& /g" {} +
365+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${DB2INSTANCE?} -c '/su - \${DB2INSTANCE?} -c '. .profile \&\& /g" {} +
366+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${DB2INSTANCE?} -c \"/su - \${DB2INSTANCE?} -c \". .profile \&\& /g" {} +
367+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${instance?} -c '/su - \${instance?} -c '. .profile \&\& /g" {} +
368+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${instance?} -c \"/su - \${instance?} -c \". .profile \&\& /g" {} +
369+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${instance_name?} -c '/su - \${instance_name?} -c '. .profile \&\& /g" {} +
370+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - \${instance_name?} -c \"/su - \${instance_name?} -c \". .profile \&\& /g" {} +
371+
find /var/db2_setup -type f -not -path '*/\.*' -exec sed -i "s/su - db2inst1 -c \\\\\"/su - db2inst1 -c \\\". .profile \&\& /g" {} +
372+
. /var/db2_setup/lib/setup_db2_instance.sh
373+
EOF
374+
chmod 777 ${db2install}
375+
if [[ "$IS_PODMAN" == "true" ]]; then
376+
CONTAINER_OPTIONS='--platform=linux/amd64 -e IS_OSXFS=true -v '${db2install}':/db2install.sh --entrypoint=["/bin/bash","-c","/db2install.sh"]'
377+
CONTAINER_ARGS=
378+
else
379+
CONTAINER_OPTIONS='--platform=linux/amd64 -e IS_OSXFS=true -v '${db2install}':/db2install.sh --entrypoint=/bin/bash'
380+
CONTAINER_ARGS=" -c /db2install.sh"
381+
fi
382+
if [[ "$IS_PODMAN" == "false" ]]; then
383+
export DOCKER_DEFAULT_PLATFORM=linux/amd64
384+
fi
385+
fi
386+
$CONTAINER_CLI rm -f db2 || true
387+
$CONTAINER_CLI run --name db2 --privileged -e DB2INSTANCE=orm_test -e DB2INST1_PASSWORD=orm_test -e DBNAME=orm_test -e LICENSE=accept -e AUTOCONFIG=false -e ARCHIVE_LOGS=false -e TO_CREATE_SAMPLEDB=false -e REPODB=false -e BLU=false -e ENABLE_ORACLE_COMPATIBILITY=false -e UPDATEAVAIL=NO -e PERSISTENT_HOME=true -e HADR_ENABLED=false -p 50000:50000 $CONTAINER_OPTIONS -d ${DB_IMAGE_DB2_12_1:-icr.io/db2_community/db2:12.1.2.0} $CONTAINER_ARGS
310388
# Give the container some time to start
311389
OUTPUT=
312390
while [[ $OUTPUT != *"INSTANCE"* ]]; do
313391
echo "Waiting for DB2 to start..."
314392
sleep 10
315-
OUTPUT=$($PRIVILEGED_CLI $CONTAINER_CLI logs db2 2>&1)
393+
OUTPUT=$($CONTAINER_CLI logs db2 2>&1)
316394
done
317-
$PRIVILEGED_CLI $CONTAINER_CLI exec -t db2 su - orm_test bash -c ". /database/config/orm_test/sqllib/db2profile; /database/config/orm_test/sqllib/bin/db2 'connect to orm_test'; /database/config/orm_test/sqllib/bin/db2 'CREATE USER TEMPORARY TABLESPACE usr_tbsp MANAGED BY AUTOMATIC STORAGE'"
395+
$CONTAINER_CLI exec -t db2 su - orm_test bash -c ". /database/config/orm_test/sqllib/db2profile; /database/config/orm_test/sqllib/bin/db2 'connect to orm_test'; /database/config/orm_test/sqllib/bin/db2 'CREATE USER TEMPORARY TABLESPACE usr_tbsp MANAGED BY AUTOMATIC STORAGE'"
318396
}
319397

320398
db2_spatial() {
@@ -710,28 +788,30 @@ EOF\""
710788
}
711789

712790
disable_userland_proxy() {
713-
if [[ "$HEALTCHECK_PATH" == "{{.State.Health.Status}}" ]]; then
714-
if [[ ! -f /etc/docker/daemon.json ]]; then
715-
echo "Didn't find /etc/docker/daemon.json but need to disable userland-proxy..."
716-
echo "Stopping docker..."
717-
sudo service docker stop
718-
echo "Creating /etc/docker/daemon.json..."
719-
sudo bash -c "echo '{\"userland-proxy\": false}' > /etc/docker/daemon.json"
720-
echo "Starting docker..."
721-
sudo service docker start
722-
echo "Docker successfully started with userland proxies disabled"
723-
elif ! grep -q userland-proxy /etc/docker/daemon.json; then
724-
echo "Userland proxy is still enabled in /etc/docker/daemon.json, but need to disable it..."
725-
export docker_daemon_json=$(</etc/docker/daemon.json)
726-
echo "Stopping docker..."
727-
sudo service docker stop
728-
echo "Updating /etc/docker/daemon.json..."
729-
sudo bash -c "export docker_daemon_json='$docker_daemon_json'; echo \"\${docker_daemon_json/\}/,}\\\"userland-proxy\\\": false}\" > /etc/docker/daemon.json"
730-
echo "Starting docker..."
731-
sudo service docker start
732-
echo "Service status:"
733-
sudo journalctl -xeu docker.service
734-
echo "Docker successfully started with userland proxies disabled"
791+
if [[ "$IS_DOCKER_RUNTIME" == "true" ]]; then
792+
if [[ "$HEALTCHECK_PATH" == "{{.State.Health.Status}}" ]]; then
793+
if [[ ! -f /etc/docker/daemon.json ]]; then
794+
echo "Didn't find /etc/docker/daemon.json but need to disable userland-proxy..."
795+
echo "Stopping docker..."
796+
sudo service docker stop
797+
echo "Creating /etc/docker/daemon.json..."
798+
sudo bash -c "echo '{\"userland-proxy\": false}' > /etc/docker/daemon.json"
799+
echo "Starting docker..."
800+
sudo service docker start
801+
echo "Docker successfully started with userland proxies disabled"
802+
elif ! grep -q userland-proxy /etc/docker/daemon.json; then
803+
echo "Userland proxy is still enabled in /etc/docker/daemon.json, but need to disable it..."
804+
export docker_daemon_json=$(</etc/docker/daemon.json)
805+
echo "Stopping docker..."
806+
sudo service docker stop
807+
echo "Updating /etc/docker/daemon.json..."
808+
sudo bash -c "export docker_daemon_json='$docker_daemon_json'; echo \"\${docker_daemon_json/\}/,}\\\"userland-proxy\\\": false}\" > /etc/docker/daemon.json"
809+
echo "Starting docker..."
810+
sudo service docker start
811+
echo "Service status:"
812+
sudo journalctl -xeu docker.service
813+
echo "Docker successfully started with userland proxies disabled"
814+
fi
735815
fi
736816
fi
737817
}

documentation/src/main/asciidoc/userguide/chapters/query/extensions/Vector.adoc

Lines changed: 116 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,25 @@ so no further configuration is necessary to make the features available.
5353
[[vector-module-usage]]
5454
==== Usage
5555

56-
Annotate a persistent attribute with `@JdbcTypeCode(SqlTypes.VECTOR)` and specify the vector length with `@Array(length = ...)`.
56+
Annotate a persistent attribute with one of the various vector type codes `@JdbcTypeCode` and specify the vector length with `@Array(length = ...)`.
57+
Possible vector type codes and the compatible Java types are:
58+
59+
* `@JdbcTypeCode(SqlTypes.VECTOR_BINARY)` for `byte[]`
60+
* `@JdbcTypeCode(SqlTypes.VECTOR_INT8)` for `byte[]`
61+
* `@JdbcTypeCode(SqlTypes.VECTOR_FLOAT16)` for `float[]`
62+
* `@JdbcTypeCode(SqlTypes.VECTOR_FLOAT32)` for `float[]`
63+
* `@JdbcTypeCode(SqlTypes.VECTOR_FLOAT64)` for `double[]`
64+
* `@JdbcTypeCode(SqlTypes.VECTOR)` for `float[]`
65+
66+
Hibernate ORM also provides support for sparse vectors through dedicated Java types:
67+
68+
* `@JdbcTypeCode(SqlTypes.SPARSE_VECTOR_INT8)` for `SparseByteVector`
69+
* `@JdbcTypeCode(SqlTypes.SPARSE_VECTOR_FLOAT32)` for `SparseFloatVector`
70+
* `@JdbcTypeCode(SqlTypes.SPARSE_VECTOR_FLOAT64)` for `SparseDoubleVector`
5771

5872
[WARNING]
5973
====
60-
As Oracle AI Vector Search supports different types of elements (to ensure better performance and compatibility with embedding models), you can also use:
61-
62-
- `@JdbcTypeCode(SqlTypes.VECTOR_INT8)` for `byte[]`
63-
- `@JdbcTypeCode(SqlTypes.VECTOR_FLOAT32)` for `float[]`
64-
- `@JdbcTypeCode(SqlTypes.VECTOR_FLOAT64)` for `double[]`.
74+
Vector data type support depends on native support of the underlying database.
6575
====
6676

6777
[[vector-module-usage-example]]
@@ -88,14 +98,21 @@ Expressions of the vector type can be used with various vector functions.
8898
| `euclidean_distance()` | Computes the https://en.wikipedia.org/wiki/Euclidean_distance[euclidean distance] between two vectors. Maps to the `<``-``>` operator for `pgvector` and maps to the
8999
`vector_distance(v1, v2, EUCLIDEAN)` function for `Oracle AI Vector Search`.
90100

101+
| `euclidean_squared_distance()` | Computes the https://en.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance[squared euclidean distance] between two vectors.
102+
91103
| `l2_distance()` | Alias for `euclidean_distance()`
92104

105+
| `l2_squared_distance()` | Alias for `euclidean_squared_distance()`
106+
93107
| `taxicab_distance()` | Computes the https://en.wikipedia.org/wiki/Taxicab_geometry[taxicab distance] between two vectors. Maps to `vector_distance(v1, v2, MANHATTAN)` function for `Oracle AI Vector Search`.
94108

95109
| `l1_distance()` | Alias for `taxicab_distance()`
96110

97111
| `hamming_distance()` | Computes the https://en.wikipedia.org/wiki/Hamming_distance[hamming distance] between two vectors. Maps to `vector_distance(v1, v2, HAMMING)` function for `Oracle AI Vector Search`.
98112

113+
| `jaccard_distance()` | Computes the https://en.wikipedia.org/wiki/Jaccard_index[jaccard distance] between two vectors. Maps to the `<``%``>` operator for `pgvector` and maps to the
114+
`vector_distance(v1, v2, JACCARD)` function for `Oracle AI Vector Search`.
115+
99116
| `inner_product()` | Computes the https://en.wikipedia.org/wiki/Inner_product_space[inner product] between two vectors
100117

101118
| `negative_inner_product()` | Computes the negative inner product. Maps to the `<``#``>` operator for `pgvector` and maps to the
@@ -104,6 +121,14 @@ Expressions of the vector type can be used with various vector functions.
104121
| `vector_dims()` | Determines the dimensions of a vector
105122

106123
| `vector_norm()` | Computes the https://en.wikipedia.org/wiki/Euclidean_space#Euclidean_norm[Euclidean norm] of a vector
124+
125+
| `l2_norm()` | Alias for `vector_norm()`
126+
127+
| `l2_normalize()` | Normalizes each component of a vector by dividing it with the https://en.wikipedia.org/wiki/Euclidean_space#Euclidean_norm[Euclidean norm] of the vector.
128+
129+
| `binary_quantize()` | Reduces a vector of size N to a binary vector with N bits, using 0 for values <= 0 and 1 for values > 0.
130+
131+
| `subvector()` | Creates a subvector from a given vector, a 1-based start index and a count.
107132
|===
108133

109134
In addition to these special vector functions, it is also possible to use vectors with the following builtin `pgvector` operators:
@@ -143,6 +168,21 @@ include::{example-dir-vector}/FloatVectorTest.java[tags=euclidean-distance-examp
143168
----
144169
====
145170

171+
[[vector-module-functions-euclidean-squared-distance]]
172+
===== `euclidean_squared_distance()` and `l2_squared_distance()`
173+
174+
Computes the https://en.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance[squared euclidean distance] between two vectors,
175+
which is `sum( (v1_i - v2_i)^2 )`, just like the regular `euclidean_distance`, but without the `sqrt`.
176+
The `l2_squared_distance()` function is an alias.
177+
178+
[[vector-module-functions-euclidean-squared-distance-example]]
179+
====
180+
[source, java, indent=0]
181+
----
182+
include::{example-dir-vector}/FloatVectorTest.java[tags=euclidean-squared-distance-example]
183+
----
184+
====
185+
146186
[[vector-module-functions-taxicab-distance]]
147187
===== `taxicab_distance()` and `l1_distance()`
148188

@@ -158,6 +198,36 @@ include::{example-dir-vector}/FloatVectorTest.java[tags=taxicab-distance-example
158198
----
159199
====
160200

201+
[[vector-module-functions-hamming-distance]]
202+
===== `hamming_distance()`
203+
204+
Computes the https://en.wikipedia.org/wiki/Hamming_distance[hamming distance] between two binary vectors,
205+
which is `bit_count(v1 ^ v2)` i.e. the amount of bits where two vectors differ.
206+
Maps to the `<``~``>` operator for `pgvector`.
207+
208+
[[vector-module-functions-taxicab-distance-example]]
209+
====
210+
[source, java, indent=0]
211+
----
212+
include::{example-dir-vector}/BinaryVectorTest.java[tags=hamming-distance-example]
213+
----
214+
====
215+
216+
[[vector-module-functions-jaccard-distance]]
217+
===== `jaccard_distance()`
218+
219+
Computes the https://en.wikipedia.org/wiki/Jaccard_index[jaccard distance] between two binary vectors,
220+
which is `1 - bit_count(v1 & v2) / bit_count(v1 | v2)`.
221+
Maps to the `<``%``>` operator for `pgvector`.
222+
223+
[[vector-module-functions-taxicab-distance-example]]
224+
====
225+
[source, java, indent=0]
226+
----
227+
include::{example-dir-vector}/BinaryVectorTest.java[tags=jaccard-distance-example]
228+
----
229+
====
230+
161231
[[vector-module-functions-inner-product]]
162232
===== `inner_product()` and `negative_inner_product()`
163233

@@ -187,10 +257,11 @@ include::{example-dir-vector}/FloatVectorTest.java[tags=vector-dims-example]
187257
====
188258

189259
[[vector-module-functions-vector-norm]]
190-
===== `vector_norm()`
260+
===== `vector_norm()` and `l2_norm()`
191261

192262
Computes the https://en.wikipedia.org/wiki/Euclidean_space#Euclidean_norm[Euclidean norm] of a vector,
193263
which is `sqrt( sum( v_i^2 ) )`.
264+
The `l2_norm()` function is an alias.
194265

195266
[[vector-module-functions-vector-norm-example]]
196267
====
@@ -200,6 +271,44 @@ include::{example-dir-vector}/FloatVectorTest.java[tags=vector-norm-example]
200271
----
201272
====
202273

274+
[[vector-module-functions-l2-normalize]]
275+
===== `l2_normalize()`
276+
277+
Normalizes each component of a vector by dividing it with the https://en.wikipedia.org/wiki/Euclidean_space#Euclidean_norm[Euclidean norm] of the vector.
278+
279+
[[vector-module-functions-l2-normalize-example]]
280+
====
281+
[source, java, indent=0]
282+
----
283+
include::{example-dir-vector}/FloatVectorTest.java[tags=l2-normalize-example]
284+
----
285+
====
286+
287+
[[vector-module-functions-binary-quantize]]
288+
===== `binary_quantize()`
289+
290+
Reduces a vector of size N to a binary vector with N bits, using 0 for values <= 0 and 1 for values > 0.
291+
292+
[[vector-module-functions-binary-quantize-example]]
293+
====
294+
[source, java, indent=0]
295+
----
296+
include::{example-dir-vector}/FloatVectorTest.java[tags=binary-quantize-example]
297+
----
298+
====
299+
300+
[[vector-module-functions-subvector]]
301+
===== `binary_quantize()`
302+
303+
Creates a subvector from a given vector, a 1-based start index and a count.
304+
305+
[[vector-module-functions-subvector-example]]
306+
====
307+
[source, java, indent=0]
308+
----
309+
include::{example-dir-vector}/FloatVectorTest.java[tags=subvector-example]
310+
----
311+
====
203312

204313

205314

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/DB2LegacyDialect.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.hibernate.boot.model.TypeContributions;
1313
import org.hibernate.community.dialect.sequence.LegacyDB2SequenceSupport;
1414
import org.hibernate.community.dialect.temptable.DB2LegacyLocalTemporaryTableStrategy;
15+
import org.hibernate.dialect.DB2Dialect;
1516
import org.hibernate.dialect.DB2GetObjectExtractor;
1617
import org.hibernate.dialect.DatabaseVersion;
1718
import org.hibernate.dialect.Dialect;
@@ -183,7 +184,7 @@ public DB2LegacyDialect() {
183184
}
184185

185186
public DB2LegacyDialect(DialectResolutionInfo info) {
186-
super( info );
187+
this( DB2Dialect.determinFullDatabaseVersion( info ) );
187188
lockingSupport = buildLockingSupport();
188189
}
189190

0 commit comments

Comments
 (0)