Skip to content

Commit

Permalink
Release 0.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
syvb committed Nov 19, 2024
1 parent 213d2dc commit 38e0085
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pgvectorscale/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vectorscale"
version = "0.6.0-dev"
version = "0.5.1"
edition = "2021"

[lib]
Expand Down
1 change: 1 addition & 0 deletions pgvectorscale/sql/vectorscale--0.0.2--0.5.1.sql
1 change: 1 addition & 0 deletions pgvectorscale/sql/vectorscale--0.2.0--0.5.1.sql
1 change: 1 addition & 0 deletions pgvectorscale/sql/vectorscale--0.3.0--0.5.1.sql
1 change: 1 addition & 0 deletions pgvectorscale/sql/vectorscale--0.4.0--0.5.1.sql
105 changes: 105 additions & 0 deletions pgvectorscale/sql/vectorscale--0.5.0--0.5.1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/* <begin connected objects> */
/*
This file is auto generated by pgrx.
The ordering of items is not stable, it is driven by a dependency graph.
*/
/* </end connected objects> */

/* <begin connected objects> */
-- pgvectorscale/src/access_method/mod.rs:29
-- vectorscale::access_method::amhandler

CREATE OR REPLACE FUNCTION diskann_amhandler(internal) RETURNS index_am_handler PARALLEL SAFE IMMUTABLE STRICT COST 0.0001 LANGUAGE c AS '$libdir/vectorscale-0.5.1', 'amhandler_wrapper';

DO $$
DECLARE
c int;
BEGIN
SELECT count(*)
INTO c
FROM pg_catalog.pg_am a
WHERE a.amname = 'diskann';

IF c = 0 THEN
CREATE ACCESS METHOD diskann TYPE INDEX HANDLER diskann_amhandler;
END IF;
END;
$$;
/* </end connected objects> */

/* <begin connected objects> */
-- pgvectorscale/src/access_method/distance.rs:42
-- vectorscale::access_method::distance::distance_type_cosine
CREATE OR REPLACE FUNCTION "distance_type_cosine"() RETURNS smallint /* i16 */
IMMUTABLE STRICT PARALLEL SAFE
LANGUAGE c /* Rust */
AS '$libdir/vectorscale-0.5.1', 'distance_type_cosine_wrapper';
/* </end connected objects> */

/* <begin connected objects> */
-- pgvectorscale/src/access_method/distance.rs:47
-- vectorscale::access_method::distance::distance_type_l2
CREATE OR REPLACE FUNCTION "distance_type_l2"() RETURNS smallint /* i16 */
IMMUTABLE STRICT PARALLEL SAFE
LANGUAGE c /* Rust */
AS '$libdir/vectorscale-0.5.1', 'distance_type_l2_wrapper';
/* </end connected objects> */

/* <begin connected objects> */
-- pgvectorscale/src/access_method/mod.rs:163
-- requires:
-- amhandler
-- distance_type_cosine
-- distance_type_l2


DO $$
DECLARE
have_cos_ops int;
have_l2_ops int;
BEGIN
-- Has cosine operator class been installed previously?
SELECT count(*)
INTO have_cos_ops
FROM pg_catalog.pg_opclass c
WHERE c.opcname = 'vector_cosine_ops'
AND c.opcmethod = (SELECT oid FROM pg_catalog.pg_am am WHERE am.amname = 'diskann')
AND c.opcnamespace = (SELECT oid FROM pg_catalog.pg_namespace where nspname='@extschema@');

-- Has L2 operator class been installed previously?
SELECT count(*)
INTO have_l2_ops
FROM pg_catalog.pg_opclass c
WHERE c.opcname = 'vector_l2_ops'
AND c.opcmethod = (SELECT oid FROM pg_catalog.pg_am am WHERE am.amname = 'diskann')
AND c.opcnamespace = (SELECT oid FROM pg_catalog.pg_namespace where nspname='@extschema@');

IF have_cos_ops = 0 THEN
-- Fresh install from scratch
CREATE OPERATOR CLASS vector_cosine_ops DEFAULT
FOR TYPE vector USING diskann AS
OPERATOR 1 <=> (vector, vector) FOR ORDER BY float_ops,
FUNCTION 1 distance_type_cosine();

CREATE OPERATOR CLASS vector_l2_ops
FOR TYPE vector USING diskann AS
OPERATOR 1 <-> (vector, vector) FOR ORDER BY float_ops,
FUNCTION 1 distance_type_l2();
ELSIF have_l2_ops = 0 THEN
-- Upgrade to add L2 distance support and update cosine opclass to
-- include the distance_type_cosine function
INSERT INTO pg_amproc (oid, amprocfamily, amproclefttype, amprocrighttype, amprocnum, amproc)
SELECT (select (max(oid)::int + 1)::oid from pg_amproc), c.opcfamily, c.opcintype, c.opcintype, 1, '@extschema@.distance_type_l2'::regproc
FROM pg_opclass c, pg_am a
WHERE a.oid = c.opcmethod AND c.opcname = 'vector_cosine_ops' AND a.amname = 'diskann';

CREATE OPERATOR CLASS vector_l2_ops
FOR TYPE vector USING diskann AS
OPERATOR 1 <-> (vector, vector) FOR ORDER BY float_ops,
FUNCTION 1 distance_type_l2();
END IF;
END;
$$;
/* </end connected objects> */

7 changes: 7 additions & 0 deletions pgvectorscale/src/access_method/upgrade_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,11 @@ pub mod tests {
fn test_upgrade_from_0_4_0() {
test_upgrade_base("0.4.0", "0.12.5", "pgvectorscale", "vectorscale", "diskann");
}

#[ignore]
#[serial]
#[test]
fn test_upgrade_from_0_5_0() {
test_upgrade_base("0.5.0", "0.12.5", "pgvectorscale", "vectorscale", "diskann");
}
}

0 comments on commit 38e0085

Please sign in to comment.