mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-05 05:18:52 +08:00
81775dff3e
* [skip ci]Add segment_interface in segcore doc Signed-off-by: xiaofan-luan <xiaofan.luan@zilliz.com> * [skip ci]Add segment_interface in segcore doc Signed-off-by: xiaofan-luan <xiaofan.luan@zilliz.com>
3.4 KiB
3.4 KiB
Segment Interface
External Interface
get_row_count
: Get the number of entities in the segmentget_schema
: Get the corresponding collection schema in the segmentGetMemoryUsageInBytes
: Get memory usage of a segmentSearch(plan, placeholderGroup, timestamp) -> QueryResult
: Perform search operations according to the plan containing search parameters and predicate condition, and return search results. Ensure that the time of all search result is before specified timestamp(MVCC)FillTargetEntry(plan, &queryResult)
: Fill the missing column data for search results based on target columns in the plan
See design details ${milvus_root}/internal/core/src/segcore/SegmentInterface.h
Basic Concepts:
- Segment: Data sharded into segment based on written timestamp , and the sharded logic is controlled by data coordinator.
- chunk: further division of segment data, chunk is continuous data for each column
- There will be only one chunk in each sealed segment.
- In growing segment, chunks are currently divided by a fixed number of rows. With data ingestion, the number of chunks will increase
- Span: similar to std::span, point to continuous data in memory
- SystemField: Extra field stored system info, currently including RowID and Timestamp field.
- SegOffset: The entity identifier in the segment
SegmentInternalInterface internal functions
num_chunk()
: total chunk numbersize_per_chunk()
: length of each chunkget_active_count(Timestamp)
: entity count after filter by Timestampchunk_data(FieldOffset, chunk_id) -> Span<T>
: return continous data for specified column and chunkchunk_scalar_index(FieldOffset, chunk_id) -> const StructuredIndex<T>&
: return the inverted index of specified column and chunknum_chunk_index
: The number of indexes (including scalar and vector indexes) that have been created- In growing segment, this value is the number of chunks for which the inverted index has been created. In these chunks, the index can be used to speed up the calculation.
- SealedSegment must be 1
debug()
: Debug is used to print extra information while debuggingvector_search(vec_count, query..., timestamp, bitset, output)
: Search the vector columnvec_count
: Specifies how many entities participate in the vector search calculation, rest of the segments are filterd out because it's timestamp is larger than specified timestamp. This function is mainly used in growing segment as multi version control(MVCC)query...
Multiple variables jointly specify the parameters and search vectortimestamp
: Timestamp is used for time travelling, filter out data with timestamp. mainly for sealed segmentbitset
: calculated bit mask value as a outputoutput
output QueryResult
bulk_subscript(FieldOffset|SystemField, seg_offsets..., output)
:- given seg_offsets, calculate
results[i] = FieldData[seg_offsets[i]]
, for GetEntityByIds - FieldData is defined by FieldOffset or SystemField
- given seg_offsets, calculate
search_ids(IdArray, timestamp) -> pair<IdArray, SegOffsets>
:- Find the corresponding segoffset according to the primary key in idarray
- The returned order is not guaranteed, but the two returned fields must correspond to each other one by one.
- Entities without PKs will not be returned
check_search(Plan)
: check if the Plan is valid- It mainly checks whether the columns used in the plan have been loaded