2023-10-18 19:34:08 +08:00
|
|
|
package iterator
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/cockroachdb/errors"
|
|
|
|
|
|
|
|
"github.com/milvus-io/milvus/internal/storage"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/typeutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// ErrNoMoreRecord is the error that the iterator does not have next record.
|
|
|
|
ErrNoMoreRecord = errors.New("no more record")
|
|
|
|
// ErrDisposed is the error that the iterator is disposed.
|
|
|
|
ErrDisposed = errors.New("iterator is disposed")
|
|
|
|
)
|
|
|
|
|
|
|
|
const InvalidID int64 = -1
|
|
|
|
|
2023-11-30 14:30:28 +08:00
|
|
|
type Row interface {
|
|
|
|
GetPk() storage.PrimaryKey
|
|
|
|
GetTimestamp() uint64
|
|
|
|
}
|
2023-10-18 19:34:08 +08:00
|
|
|
|
|
|
|
type InsertRow struct {
|
|
|
|
ID int64
|
2023-11-30 14:30:28 +08:00
|
|
|
Pk storage.PrimaryKey
|
2023-10-18 19:34:08 +08:00
|
|
|
Timestamp typeutil.Timestamp
|
|
|
|
Value map[storage.FieldID]interface{}
|
|
|
|
}
|
|
|
|
|
2023-11-30 14:30:28 +08:00
|
|
|
func (r *InsertRow) GetPk() storage.PrimaryKey {
|
|
|
|
return r.Pk
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *InsertRow) GetTimestamp() uint64 {
|
|
|
|
return r.Timestamp
|
|
|
|
}
|
|
|
|
|
2023-10-18 19:34:08 +08:00
|
|
|
type DeltalogRow struct {
|
|
|
|
Pk storage.PrimaryKey
|
|
|
|
Timestamp typeutil.Timestamp
|
|
|
|
}
|
|
|
|
|
2023-11-30 14:30:28 +08:00
|
|
|
func (r *DeltalogRow) GetPk() storage.PrimaryKey {
|
|
|
|
return r.Pk
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *DeltalogRow) GetTimestamp() uint64 {
|
|
|
|
return r.Timestamp
|
|
|
|
}
|
|
|
|
|
2023-10-18 19:34:08 +08:00
|
|
|
type Label struct {
|
|
|
|
segmentID typeutil.UniqueID
|
|
|
|
}
|
|
|
|
|
|
|
|
type LabeledRowData struct {
|
|
|
|
label *Label
|
|
|
|
data Row
|
|
|
|
}
|
|
|
|
|
2023-11-30 14:30:28 +08:00
|
|
|
func (l *LabeledRowData) GetLabel() *Label {
|
|
|
|
return l.label
|
|
|
|
}
|
2023-10-18 19:34:08 +08:00
|
|
|
|
2023-11-30 14:30:28 +08:00
|
|
|
func (l *LabeledRowData) GetPk() storage.PrimaryKey {
|
|
|
|
return l.data.GetPk()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LabeledRowData) GetTimestamp() uint64 {
|
|
|
|
return l.data.GetTimestamp()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LabeledRowData) GetSegmentID() typeutil.UniqueID {
|
2023-10-18 19:34:08 +08:00
|
|
|
return l.label.segmentID
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewLabeledRowData(data Row, label *Label) *LabeledRowData {
|
|
|
|
return &LabeledRowData{
|
|
|
|
label: label,
|
|
|
|
data: data,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type Iterator interface {
|
|
|
|
HasNext() bool
|
|
|
|
Next() (*LabeledRowData, error)
|
|
|
|
Dispose()
|
|
|
|
WaitForDisposed() // wait until the iterator is disposed
|
|
|
|
}
|