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

Add New Vector Functions #5120

Open
8 of 21 tasks
zhongzc opened this issue Dec 9, 2024 · 4 comments
Open
8 of 21 tasks

Add New Vector Functions #5120

zhongzc opened this issue Dec 9, 2024 · 4 comments
Labels
C-feature Category Features good first issue Good for newcomers tracking-issue A tracking issue for a feature.

Comments

@zhongzc
Copy link
Contributor

zhongzc commented Dec 9, 2024

What problem does the new feature solve?

We seek external contributors to help us implement various functions for vector operations in GreptimeDB. You can refer to this PR as a guide for implementing vec_scalar_add. Below is a list of functions we are considering. Each function comes with a brief description.

Please respond below with the function(s) you would like to contribute, ensuring to avoid overlap with other contributors. We look forward to your valuable contributions!

What does the feature do?

Vector Basic Functions:

  • VEC_SCALAR_ADD(f32, vec): Adds a scalar to each element of a vector (use negative scalar for subtraction), returns a vector. feat(vector): add scalar add function  #5119
  • VEC_SCALAR_MUL(f32, vec): Multiplies a scalar with each element of a vector (use 1/scalar for division), returns a vector. @linyihai feat: Add vector_scalar_mul function. #5166
  • VEC_ADD(vec0, vec1): Adds corresponding elements of two vectors, returns a vector. @wty4427300
  • VEC_SUB(vec0, vec1): Subtracts corresponding elements of two vectors, returns a vector.
  • VEC_MUL(vec0, vec1): Multiplies corresponding elements of two vectors, returns a vector.
  • VEC_DIV(vec0, vec1): Divides corresponding elements of two vectors, returns a vector.
  • VEC_SUM(col): Aggregates by summing elements across the same dimension, returns a vector.
  • VEC_PRODUCT(col): Aggregates by multiplying elements across the same dimension, returns a vector.
  • VEC_ELEM_SUM(vec): Sums all elements of the vector, returns a scalar.
  • VEC_ELEM_PRODUCT(vec): Multiplies all elements of the vector, returns a scalar.
  • VEC_NORM(vec): Normalizes the vector to length 1, effectively equivalent to VECTOR_SCALAR_MUL(1/SQRT(VECTOR_ELEM_SUM(VECTOR_MUL(v, v))), v), returns a vector.

Vector Properties/Access Functions:

  • VEC_DIM(vec): Returns the dimension of the vector.
  • VEC_KTH_ELEM(vec, k): Returns the k-th element of the vector.
  • VEC_SUBVECTOR(vec, start, end): Returns a subvector from start to end index.

Conversion Functions (JSON <-> Vector):

  • JSON_TO_VEC: Converts a JSON Array to a Vector.
  • VEC_TO_JSON: Converts a Vector to a JSON Array.

Conversion Functions (String <-> Vector):

Vector Distance Functions:

... Other possible functions

Implementation challenges

No response

@zhongzc zhongzc added good first issue Good for newcomers C-feature Category Features labels Dec 9, 2024
@killme2008 killme2008 added the tracking-issue A tracking issue for a feature. label Dec 9, 2024
@linyihai
Copy link
Contributor

I'd look into VEC_SCALAR_MUL(f32, vec) :)

@wty4427300
Copy link

I want to try VEC_ADD(vec0, vec1):

@killme2008
Copy link
Contributor

I'd look into VEC_SCALAR_MUL(f32, vec) :)

Cool, thank you!

@killme2008
Copy link
Contributor

I want to try VEC_ADD(vec0, vec1):

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category Features good first issue Good for newcomers tracking-issue A tracking issue for a feature.
Projects
None yet
Development

No branches or pull requests

4 participants