Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upload --0.3.0 schema update script #437

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
374 changes: 187 additions & 187 deletions sql/install/vectors--0.2.1.sql

Large diffs are not rendered by default.

1,806 changes: 1,806 additions & 0 deletions sql/install/vectors--0.3.0.sql

Large diffs are not rendered by default.

911 changes: 911 additions & 0 deletions sql/upgrade/vectors--0.2.1--0.3.0.sql

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/datatype/binary_bvecf32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use pgrx::datum::Internal;
use pgrx::datum::IntoDatum;
use pgrx::pg_sys::Oid;

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_bvecf32_send(vector: BVecf32Input<'_>) -> Bytea {
use pgrx::pg_sys::StringInfoData;
unsafe {
Expand All @@ -21,8 +21,9 @@ fn _vectors_bvecf32_send(vector: BVecf32Input<'_>) -> Bytea {
}
}

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
fn _vectors_bvecf32_recv(internal: Internal, _oid: Oid, _typmod: i32) -> BVecf32Output {
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_bvecf32_recv(internal: Internal, oid: Oid, typmod: i32) -> BVecf32Output {
let _ = (oid, typmod);
use pgrx::pg_sys::StringInfo;
unsafe {
let buf: StringInfo = internal.into_datum().unwrap().cast_mut_ptr();
Expand Down
7 changes: 4 additions & 3 deletions src/datatype/binary_svecf32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use pgrx::datum::IntoDatum;
use pgrx::pg_sys::Oid;
use std::ffi::c_char;

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_svecf32_send(vector: SVecf32Input<'_>) -> Bytea {
use pgrx::pg_sys::StringInfoData;
unsafe {
Expand All @@ -27,8 +27,9 @@ fn _vectors_svecf32_send(vector: SVecf32Input<'_>) -> Bytea {
}
}

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
fn _vectors_svecf32_recv(internal: Internal, _oid: Oid, _typmod: i32) -> SVecf32Output {
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_svecf32_recv(internal: Internal, oid: Oid, typmod: i32) -> SVecf32Output {
let _ = (oid, typmod);
use pgrx::pg_sys::StringInfo;
unsafe {
let buf: StringInfo = internal.into_datum().unwrap().cast_mut_ptr();
Expand Down
7 changes: 4 additions & 3 deletions src/datatype/binary_vecf16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use pgrx::datum::IntoDatum;
use pgrx::pg_sys::Oid;
use std::ffi::c_char;

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_vecf16_send(vector: Vecf16Input<'_>) -> Bytea {
use pgrx::pg_sys::StringInfoData;
unsafe {
Expand All @@ -21,8 +21,9 @@ fn _vectors_vecf16_send(vector: Vecf16Input<'_>) -> Bytea {
}
}

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
fn _vectors_vecf16_recv(internal: Internal, _oid: Oid, _typmod: i32) -> Vecf16Output {
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_vecf16_recv(internal: Internal, oid: Oid, typmod: i32) -> Vecf16Output {
let _ = (oid, typmod);
use pgrx::pg_sys::StringInfo;
unsafe {
let buf: StringInfo = internal.into_datum().unwrap().cast_mut_ptr();
Expand Down
7 changes: 4 additions & 3 deletions src/datatype/binary_vecf32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use pgrx::datum::IntoDatum;
use pgrx::pg_sys::Oid;
use std::ffi::c_char;

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_vecf32_send(vector: Vecf32Input<'_>) -> Bytea {
use pgrx::pg_sys::StringInfoData;
unsafe {
Expand All @@ -21,8 +21,9 @@ fn _vectors_vecf32_send(vector: Vecf32Input<'_>) -> Bytea {
}
}

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
fn _vectors_vecf32_recv(internal: Internal, _oid: Oid, _typmod: i32) -> Vecf32Output {
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_vecf32_recv(internal: Internal, oid: Oid, typmod: i32) -> Vecf32Output {
let _ = (oid, typmod);
use pgrx::pg_sys::StringInfo;
unsafe {
let buf: StringInfo = internal.into_datum().unwrap().cast_mut_ptr();
Expand Down
7 changes: 4 additions & 3 deletions src/datatype/binary_veci8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use pgrx::datum::IntoDatum;
use pgrx::pg_sys::Oid;
use std::ffi::c_char;

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_veci8_send(vector: Veci8Input<'_>) -> Bytea {
use pgrx::pg_sys::StringInfoData;
unsafe {
Expand All @@ -29,8 +29,9 @@ fn _vectors_veci8_send(vector: Veci8Input<'_>) -> Bytea {
}
}

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
fn _vectors_veci8_recv(internal: Internal, _oid: Oid, _typmod: i32) -> Veci8Output {
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_veci8_recv(internal: Internal, oid: Oid, typmod: i32) -> Veci8Output {
let _ = (oid, typmod);
use pgrx::pg_sys::StringInfo;
unsafe {
let buf: StringInfo = internal.into_datum().unwrap().cast_mut_ptr();
Expand Down
27 changes: 12 additions & 15 deletions src/datatype/casts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ use base::scalar::*;
use base::vector::*;
use num_traits::Zero;

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_cast_array_to_vecf32(
array: pgrx::Array<f32>,
_typmod: i32,
typmod: i32,
_explicit: bool,
) -> Vecf32Output {
let _ = typmod;
check_value_dims_65535(array.len());
let mut slice = vec![F32::zero(); array.len()];
for (i, x) in array.iter().enumerate() {
Expand All @@ -22,7 +23,7 @@ fn _vectors_cast_array_to_vecf32(
Vecf32Output::new(Vecf32Borrowed::new(&slice))
}

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_cast_vecf32_to_array(
vector: Vecf32Input<'_>,
_typmod: i32,
Expand All @@ -31,29 +32,27 @@ fn _vectors_cast_vecf32_to_array(
vector.slice().iter().map(|x| x.to_f32()).collect()
}

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_cast_vecf32_to_vecf16(
vector: Vecf32Input<'_>,
_typmod: i32,
_explicit: bool,
) -> Vecf16Output {
let slice: Vec<F16> = vector.slice().iter().map(|&x| F16::from_f(x)).collect();

Vecf16Output::new(Vecf16Borrowed::new(&slice))
}

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_cast_vecf16_to_vecf32(
vector: Vecf16Input<'_>,
_typmod: i32,
_explicit: bool,
) -> Vecf32Output {
let slice: Vec<F32> = vector.slice().iter().map(|&x| x.to_f()).collect();

Vecf32Output::new(Vecf32Borrowed::new(&slice))
}

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_cast_vecf32_to_svecf32(
vector: Vecf32Input<'_>,
_typmod: i32,
Expand All @@ -78,18 +77,17 @@ fn _vectors_cast_vecf32_to_svecf32(
))
}

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_cast_svecf32_to_vecf32(
vector: SVecf32Input<'_>,
_typmod: i32,
_explicit: bool,
) -> Vecf32Output {
let slice = vector.for_borrow().to_vec();

Vecf32Output::new(Vecf32Borrowed::new(&slice))
}

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_cast_vecf32_to_bvecf32(
vector: Vecf32Input<'_>,
_typmod: i32,
Expand All @@ -103,11 +101,10 @@ fn _vectors_cast_vecf32_to_bvecf32(
_ => bad_literal("The vector contains a non-binary value."),
}
}

BVecf32Output::new(values.for_borrow())
}

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_cast_bvecf32_to_vecf32(
vector: BVecf32Input<'_>,
_typmod: i32,
Expand All @@ -121,7 +118,7 @@ fn _vectors_cast_bvecf32_to_vecf32(
Vecf32Output::new(Vecf32Borrowed::new(&data))
}

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_cast_veci8_to_vecf32(
vector: Veci8Input<'_>,
_typmod: i32,
Expand All @@ -133,7 +130,7 @@ fn _vectors_cast_veci8_to_vecf32(
Vecf32Output::new(Vecf32Borrowed::new(&data))
}

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_cast_vecf32_to_veci8(
vector: Vecf32Input<'_>,
_typmod: i32,
Expand Down
3 changes: 1 addition & 2 deletions src/datatype/functions_bvecf32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ use super::memory_vecf32::Vecf32Input;
use base::scalar::*;
use base::vector::*;

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_binarize(vector: Vecf32Input<'_>) -> BVecf32Output {
let mut values = BVecf32Owned::new_zeroed(vector.len() as u16);
for (i, &F32(x)) in vector.slice().iter().enumerate() {
if x > 0. {
values.set(i, true);
}
}

BVecf32Output::new(values.for_borrow())
}
2 changes: 1 addition & 1 deletion src/datatype/functions_svecf32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::error::*;
use base::scalar::*;
use base::vector::*;

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_to_svector(
dims: i32,
index: pgrx::Array<i32>,
Expand Down
2 changes: 1 addition & 1 deletion src/datatype/functions_veci8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::error::*;
use base::scalar::*;
use base::vector::*;

#[pgrx::pg_extern(immutable, parallel_safe, strict)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_to_veci8(len: i32, alpha: f32, offset: f32, values: pgrx::Array<i32>) -> Veci8Output {
check_value_dims_65535(len as usize);
if (len as usize) != values.len() {
Expand Down
26 changes: 13 additions & 13 deletions src/datatype/operators_bvecf32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use base::scalar::*;
use base::vector::*;
use std::ops::Deref;

#[pgrx::pg_extern(immutable, parallel_safe)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_bvecf32_operator_and(lhs: BVecf32Input<'_>, rhs: BVecf32Input<'_>) -> BVecf32Output {
let n = check_matched_dims(lhs.dims() as _, rhs.dims() as _);
let mut results = BVecf32Owned::new_zeroed(n.try_into().unwrap());
Expand All @@ -16,7 +16,7 @@ fn _vectors_bvecf32_operator_and(lhs: BVecf32Input<'_>, rhs: BVecf32Input<'_>) -
BVecf32Output::new(results.for_borrow())
}

#[pgrx::pg_extern(immutable, parallel_safe)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_bvecf32_operator_or(lhs: BVecf32Input<'_>, rhs: BVecf32Input<'_>) -> BVecf32Output {
check_matched_dims(lhs.dims() as _, rhs.dims() as _);
let mut results = BVecf32Owned::new_zeroed(lhs.dims().try_into().unwrap());
Expand All @@ -27,7 +27,7 @@ fn _vectors_bvecf32_operator_or(lhs: BVecf32Input<'_>, rhs: BVecf32Input<'_>) ->
BVecf32Output::new(results.for_borrow())
}

#[pgrx::pg_extern(immutable, parallel_safe)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_bvecf32_operator_xor(lhs: BVecf32Input<'_>, rhs: BVecf32Input<'_>) -> BVecf32Output {
check_matched_dims(lhs.dims() as _, rhs.dims() as _);
let mut results = BVecf32Owned::new_zeroed(lhs.dims().try_into().unwrap());
Expand All @@ -38,61 +38,61 @@ fn _vectors_bvecf32_operator_xor(lhs: BVecf32Input<'_>, rhs: BVecf32Input<'_>) -
BVecf32Output::new(results.for_borrow())
}

#[pgrx::pg_extern(immutable, parallel_safe)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_bvecf32_operator_lt(lhs: BVecf32Input<'_>, rhs: BVecf32Input<'_>) -> bool {
check_matched_dims(lhs.dims() as _, rhs.dims() as _);
lhs.deref().for_borrow() < rhs.deref().for_borrow()
}

#[pgrx::pg_extern(immutable, parallel_safe)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_bvecf32_operator_lte(lhs: BVecf32Input<'_>, rhs: BVecf32Input<'_>) -> bool {
check_matched_dims(lhs.dims() as _, rhs.dims() as _);
lhs.deref().for_borrow() <= rhs.deref().for_borrow()
}

#[pgrx::pg_extern(immutable, parallel_safe)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_bvecf32_operator_gt(lhs: BVecf32Input<'_>, rhs: BVecf32Input<'_>) -> bool {
check_matched_dims(lhs.dims() as _, rhs.dims() as _);
lhs.deref().for_borrow() > rhs.deref().for_borrow()
}

#[pgrx::pg_extern(immutable, parallel_safe)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_bvecf32_operator_gte(lhs: BVecf32Input<'_>, rhs: BVecf32Input<'_>) -> bool {
check_matched_dims(lhs.dims() as _, rhs.dims() as _);
lhs.deref().for_borrow() >= rhs.deref().for_borrow()
}

#[pgrx::pg_extern(immutable, parallel_safe)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_bvecf32_operator_eq(lhs: BVecf32Input<'_>, rhs: BVecf32Input<'_>) -> bool {
check_matched_dims(lhs.dims() as _, rhs.dims() as _);
lhs.deref().for_borrow() == rhs.deref().for_borrow()
}

#[pgrx::pg_extern(immutable, parallel_safe)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_bvecf32_operator_neq(lhs: BVecf32Input<'_>, rhs: BVecf32Input<'_>) -> bool {
check_matched_dims(lhs.dims() as _, rhs.dims() as _);
lhs.deref().for_borrow() != rhs.deref().for_borrow()
}

#[pgrx::pg_extern(immutable, parallel_safe)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_bvecf32_operator_cosine(lhs: BVecf32Input<'_>, rhs: BVecf32Input<'_>) -> f32 {
check_matched_dims(lhs.dims() as _, rhs.dims() as _);
BVecf32Cos::distance(lhs.for_borrow(), rhs.for_borrow()).to_f32()
}

#[pgrx::pg_extern(immutable, parallel_safe)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_bvecf32_operator_dot(lhs: BVecf32Input<'_>, rhs: BVecf32Input<'_>) -> f32 {
check_matched_dims(lhs.dims() as _, rhs.dims() as _);
BVecf32Dot::distance(lhs.for_borrow(), rhs.for_borrow()).to_f32()
}

#[pgrx::pg_extern(immutable, parallel_safe)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_bvecf32_operator_l2(lhs: BVecf32Input<'_>, rhs: BVecf32Input<'_>) -> f32 {
check_matched_dims(lhs.dims() as _, rhs.dims() as _);
BVecf32L2::distance(lhs.for_borrow(), rhs.for_borrow()).to_f32()
}

#[pgrx::pg_extern(immutable, parallel_safe)]
#[pgrx::pg_extern(immutable, strict, parallel_safe)]
fn _vectors_bvecf32_operator_jaccard(lhs: BVecf32Input<'_>, rhs: BVecf32Input<'_>) -> f32 {
check_matched_dims(lhs.dims() as _, rhs.dims() as _);
BVecf32Jaccard::distance(lhs.for_borrow(), rhs.for_borrow()).to_f32()
Expand Down
Loading
Loading