Files
milvus-io--milvus/internal/flushcommon/writebuffer/delta_buffer.go
T
wehub-resource-sync 498b235461
Build and test / Build and test AMD64 Ubuntu 22.04 (push) Failing after 0s
Publish Builder / amazonlinux2023 (push) Failing after 1s
Build and test / UT for Go (push) Has been skipped
Publish KRTE Images / KRTE (push) Failing after 1s
Build and test / Integration Test (push) Has been skipped
Build and test / Upload Code Coverage (push) Has been skipped
Publish Builder / rockylinux9 (push) Failing after 1s
Publish Builder / ubuntu22.04 (push) Failing after 0s
Publish Builder / ubuntu24.04 (push) Failing after 0s
Publish Gpu Builder / publish-gpu-builder (push) Failing after 1s
Publish Test Images / PyTest (push) Failing after 0s
Build and test / UT for Cpp (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:31:17 +08:00

68 lines
1.4 KiB
Go

package writebuffer
import (
"math"
"github.com/milvus-io/milvus-proto/go-api/v3/msgpb"
"github.com/milvus-io/milvus/internal/storage"
"github.com/milvus-io/milvus/pkg/v3/util/paramtable"
"github.com/milvus-io/milvus/pkg/v3/util/typeutil"
)
type DeltaBuffer struct {
BufferBase
buffer *storage.DeleteData
}
func NewDeltaBuffer() *DeltaBuffer {
return &DeltaBuffer{
BufferBase: BufferBase{
rowLimit: noLimit,
sizeLimit: paramtable.Get().DataNodeCfg.FlushDeleteBufferBytes.GetAsInt64(),
TimestampFrom: math.MaxUint64,
TimestampTo: 0,
},
buffer: &storage.DeleteData{},
}
}
func (ib *DeltaBuffer) getTimestampRange(tss []typeutil.Timestamp) TimeRange {
tr := TimeRange{
timestampMin: math.MaxUint64,
timestampMax: 0,
}
for _, data := range tss {
if data < tr.timestampMin {
tr.timestampMin = data
}
if data > tr.timestampMax {
tr.timestampMax = data
}
}
return tr
}
func (db *DeltaBuffer) Yield() *storage.DeleteData {
if db.IsEmpty() {
return nil
}
return db.buffer
}
func (db *DeltaBuffer) Buffer(pks []storage.PrimaryKey, tss []typeutil.Timestamp, startPos, endPos *msgpb.MsgPosition) (bufSize int64) {
beforeSize := db.buffer.Size()
rowCount := len(pks)
for i := 0; i < rowCount; i++ {
db.buffer.Append(pks[i], tss[i])
}
bufSize = db.buffer.Size() - beforeSize
db.UpdateStatistics(int64(rowCount), bufSize, db.getTimestampRange(tss), startPos, endPos)
return bufSize
}