Current state: Accepted
Keywords: Query / Search / Vector
Released: Milvus 2.0rc3
This project is to use minimal memory, let query support to return vector field in output.
In Milvus 2.0rc1, query does not support return vector field in output. If query request's output fields contain float vector or binary vector, proxy will error out.
This is for the consideration of memory consumption, because vector field with big dimension will occupy hundreds of times of memory comparing with scalar
field. So generally load_collection or load_partition only load scalar fields' raw data into memory. Vector fields' raw data is loaded into memory only in 3 cases:
- streaming segment
- vector field's index type is FLAT
- vector field's index has not been created
Only if vector's raw data has been loaded into memory, query can return vector field in output.
But query need this capability to return vector's raw data, for example tester can use this to check the correctness of inserted data.
Currently search also does not support return vector field in output, but we don't plan to enhance search in this project. If users need to get the vector data after
search returns ID, they can call query to get it.
If there is real requirement from users to let search return vector in output, we can achieve this in SDK level.
Query supporting vector field in output can be divided into 2 steps:
- in load segment stage, create VectorFieldInfo for vector fields, and save it into segment struct
- in the end of query stage,
- load vector field's data if needed
- get vector data, fill in query result
- Add new field VectorFieldInfo into segment struct to return vector field related information
- Add new interface in segment_loader
- Add new interface in query_collection
We also enhanced query to support wildcard in output fields.
- "*" - means all scalar fields
- "%" - means all vector fields
For example, A/B are scalar fields, C/D are vector fields, duplicated fields are automatically removed.
- output_fields=["*"] ==> [A,B]
- output_fields=["%"] ==> [C,D]
- output_fields=["*","%"] ==> [A,B,C,D]
- output_fields=["*",A] ==> [A,B]
- output_fields=["*",C] ==> [A,B,C]
Original vector data storage public interface and struct
Public Interfaces. It may be discussed and changed in future.
A VectorFileManager implements FileManager interface and add a method to download vector file from remote and deserialize its content, finally save pure vector to local storage.
localChunkManager is responsible to local file manager. And can be implements with golang os library.
remoteChunkManager is responsible for cloud storage or remote server storage, and will be implemented with minio client now.
When the offset of vector is obtained, we can get origin vector data from local vector data file.
Get the vector the ID through the following process：
1.Get segment's id size in each binlog and vector file names when load_segment. The binlogs file will be sorted by file name's last id to guarantee the order is increasing. Suppose we get sizes are 300, 300, 400, 500.
2.Get the id offset in segment in C layer. Suppose we get an offset 700.
3.We can know the vector we want to get is in 3rd vector files. for 300+300 <700<300+300+400
4.Get the 3rd file in to memory and deserialize out pure vector. Save the vector to local storage. Release the memory usage.
5.Mmap the file to memory, and get the data of offset 100. The data length differs data type and dim.
Do query / search (with vector field in output fields) in all kinds of combinations of following scenarios, check the correctness of result.
- float vector or binary vector
- with/wo index
- all kinds of index type