mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-05 05:18:52 +08:00
2c9bb4dfa3
issue: #33744 This PR includes the following changes: 1. Added a new task type to the task scheduler in datacoord: stats task, which sorts segments by primary key. 2. Implemented segment sorting in indexnode. 3. Added a new field `FieldStatsLog` to SegmentInfo to store token index information. --------- Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
41 lines
702 B
Go
41 lines
702 B
Go
package compaction
|
|
|
|
import "github.com/milvus-io/milvus/internal/storage"
|
|
|
|
type PQItem struct {
|
|
Value *storage.Value
|
|
Index int
|
|
Pos int
|
|
}
|
|
|
|
type PriorityQueue []*PQItem
|
|
|
|
func (pq PriorityQueue) Len() int { return len(pq) }
|
|
|
|
func (pq PriorityQueue) Less(i, j int) bool {
|
|
return pq[i].Value.PK.LT(pq[j].Value.PK)
|
|
}
|
|
|
|
func (pq PriorityQueue) Swap(i, j int) {
|
|
pq[i], pq[j] = pq[j], pq[i]
|
|
pq[i].Pos = i
|
|
pq[j].Pos = j
|
|
}
|
|
|
|
func (pq *PriorityQueue) Push(x interface{}) {
|
|
n := len(*pq)
|
|
item := x.(*PQItem)
|
|
item.Pos = n
|
|
*pq = append(*pq, item)
|
|
}
|
|
|
|
func (pq *PriorityQueue) Pop() interface{} {
|
|
old := *pq
|
|
n := len(old)
|
|
item := old[n-1]
|
|
old[n-1] = nil
|
|
item.Pos = -1
|
|
*pq = old[0 : n-1]
|
|
return item
|
|
}
|