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

feat: support more vector item metadata value types #972

Merged
merged 3 commits into from
Oct 20, 2023

Conversation

malandis
Copy link
Contributor

@malandis malandis commented Oct 20, 2023

In the previous version of the service, we only supported
string-valued metadata. In the latest version, we support the
following value types:

  • string
  • int
  • double
  • bool
  • list of strings

We update the VectorItem and SearchHit interfaces to support
metadata of these types (where int and float are both represented as
number).

We update sendUpsertItemBatch to serialize the metadata
appropriately. We distinguish numbers that are integers vs
floating point.

Similarly we update sendSearch to deserialize the metadata
appropriately.

We add an extra integration test to ensure each of the metadata value
types are stored and retrieved properly.

In the previous version of the service, we only supported
string-valued metadata. In the latest version, we support the
following value types:

- string
- int
- double
- bool
- list of strings

We update the `VectorItem` and `SearchHit` interfaces to support
metadata of these types (where int and float are both represented as
`number`).

We update `sendUpsertItemBatch` to serialize the metadata
appropriately. We distinguish numbers that are integers vs
floating-point.

Similarly we update `sendSearch` to deserialize the metadata
appropriately.

We add an extra integration test to ensure each of the metadata value
types are stored and retrieved properly.
Comment on lines +106 to +107
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
metadata.setIntegerValue(value);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unclear why some of these modifiers have unsafe call warnings and others do not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled this down locally to test this. I don't think that you need any of these eslint-disable lines actually. The js protobuf dependecies trip up some IDEs. I suspect that your IDE is operating off of some stale data, and that it thinks that item is of type any or unknown. I think if you remove all of the eslint-disable lines, and rebuild in your terminal it will pass. (Verified this :onmybox: ). Sometimes if you rebuild on your terminal, and then open up the project inside your IDE, it will pickup the latest changes. :skeletor_fist_shake: caching issues :skeletor_fist_shake:

@malandis
Copy link
Contributor Author

malandis commented Oct 20, 2023

I regenerated the package-lock.json files in a6683b6. The patch is hefty.

Copy link
Contributor

@cprice404 cprice404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor questions / nits, no blockers

string_value: value,
});
} else if (typeof value === 'number') {
if (Number.isInteger(value)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol @ javascript

acc[metadata.getField()] = metadata.getStringValue();
const field = metadata.getField();
switch (metadata.getValueCase()) {
case vectorindex._Metadata.ValueCase.STRING_VALUE:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious if there is a reason you are able to use constants here but you had to use string literals for the earlier case statement

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That appears to be a grpc-js vs grpc-web thing. grpc-js uses string literals and grpc-web constants. 🤸‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool. bonus points for defining our own constants for it in the near future but definitely not a blocker.

return acc;
}, {} as Record<string, string>),
}, {} as Record<string, string | number | boolean | Array<string>>),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious if you tried a type alias for this in JS too, and observed the same issue where the IDEs didn't expand it in a helpful way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing in the sense that if we make a type alias T that is used in a function signature for foo, then if you type foo you will only see T, unless you manually click the function, go to definition, and then hover over T.

@malandis malandis merged commit 2b7b326 into main Oct 20, 2023
13 checks passed
@malandis malandis deleted the feat/more-vector-index-item-metadata-value-types branch October 20, 2023 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants