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

Consider removing class constraint for IVectorizer #444

Open
abbottdev opened this issue Apr 15, 2024 · 2 comments
Open

Consider removing class constraint for IVectorizer #444

abbottdev opened this issue Apr 15, 2024 · 2 comments

Comments

@abbottdev
Copy link
Contributor

Hi.

So I have some types which have their own precomputed embeddings, for example, a PDQ hash. I have implemented these data structures using structs in my code. I have no facility however to be able to use Redis OM for these types.

I tried implementing a custom Vector (and re-implement Vector<T>) without the class constraint but there is an internal prop which I can't override due to it's accessibility.

If I could re-use the existing Vector<T> without the class constraint, I can then build my own vectorizer attributes to extract the relevant embeddings as needed.

@slorello89
Copy link
Member

Hi @abbottdev,

You're really supposed to have a IVectorizer<T> actually do the work of embedding the T in your Vector<T>, so I'm not entirely sure why you would need a non-generic version of Vector, if you really did though, you could always just implement the abstract class and ignore the object, dropping your embedding directly into it's place.

@abbottdev
Copy link
Contributor Author

abbottdev commented Apr 16, 2024

@slorello89 - Thanks for the reply - It doesn't need to be non-generic, what I'm saying is that I'm working with structs due to performance reasons I can keep allocations on the heap to a minimum that way - unfortunately as the type constraint on Vector<T> has a class constraint I'm unable to use it:

    public sealed class Vector<T> : Vector, IEquatable<Vector<T>>
    where T : class

https://github.com/redis/redis-om-dotnet/blob/cd8919a9052affdf60cf22504864b3cdd4d8f708/src/Redis.OM/Vector.cs#L55C1-L56C20

I tried to implement the base abstract class, but unfortunately there is aObj variable that's defined internally that I'm unable to override, which means I can't implement the base abstract class:

        internal override object? Obj => Value;

https://github.com/redis/redis-om-dotnet/blob/cd8919a9052affdf60cf22504864b3cdd4d8f708/src/Redis.OM/Vector.cs#L26C1-L30C1

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

No branches or pull requests

2 participants