2021-01-16 02:12:14 +00:00
|
|
|
package querynode
|
2020-08-28 09:29:26 +00:00
|
|
|
|
2020-09-02 02:38:08 +00:00
|
|
|
/*
|
|
|
|
|
2020-10-23 10:01:24 +00:00
|
|
|
#cgo CFLAGS: -I${SRCDIR}/../core/output/include
|
2020-09-02 02:38:08 +00:00
|
|
|
|
2020-10-31 07:11:47 +00:00
|
|
|
#cgo LDFLAGS: -L${SRCDIR}/../core/output/lib -lmilvus_segcore -Wl,-rpath=${SRCDIR}/../core/output/lib
|
2020-09-02 02:38:08 +00:00
|
|
|
|
2020-11-25 02:31:51 +00:00
|
|
|
#include "segcore/collection_c.h"
|
|
|
|
#include "segcore/segment_c.h"
|
2020-09-02 02:38:08 +00:00
|
|
|
|
|
|
|
*/
|
2020-08-28 09:29:26 +00:00
|
|
|
import "C"
|
2021-03-05 01:21:35 +00:00
|
|
|
import (
|
|
|
|
"go.uber.org/zap"
|
|
|
|
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/log"
|
|
|
|
)
|
2020-08-28 09:29:26 +00:00
|
|
|
|
|
|
|
type Partition struct {
|
2021-02-05 02:53:11 +00:00
|
|
|
collectionID UniqueID
|
|
|
|
partitionID UniqueID
|
|
|
|
segmentIDs []UniqueID
|
2021-02-06 03:35:35 +00:00
|
|
|
enable bool
|
2020-08-28 09:29:26 +00:00
|
|
|
}
|
|
|
|
|
2021-01-20 01:36:50 +00:00
|
|
|
func (p *Partition) ID() UniqueID {
|
2021-02-05 02:53:11 +00:00
|
|
|
return p.partitionID
|
2021-01-20 01:36:50 +00:00
|
|
|
}
|
|
|
|
|
2021-02-05 02:53:11 +00:00
|
|
|
func (p *Partition) addSegmentID(segmentID UniqueID) {
|
|
|
|
p.segmentIDs = append(p.segmentIDs, segmentID)
|
2020-08-28 09:29:26 +00:00
|
|
|
}
|
|
|
|
|
2021-02-05 02:53:11 +00:00
|
|
|
func (p *Partition) removeSegmentID(segmentID UniqueID) {
|
|
|
|
tmpIDs := make([]UniqueID, 0)
|
|
|
|
for _, id := range p.segmentIDs {
|
|
|
|
if id == segmentID {
|
|
|
|
tmpIDs = append(tmpIDs, id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p.segmentIDs = tmpIDs
|
|
|
|
}
|
|
|
|
|
|
|
|
func newPartition(collectionID UniqueID, partitionID UniqueID) *Partition {
|
2021-01-21 07:20:23 +00:00
|
|
|
var newPartition = &Partition{
|
2021-02-05 02:53:11 +00:00
|
|
|
collectionID: collectionID,
|
|
|
|
partitionID: partitionID,
|
2021-02-06 03:35:35 +00:00
|
|
|
enable: false,
|
2021-01-21 07:20:23 +00:00
|
|
|
}
|
|
|
|
|
2021-03-05 01:21:35 +00:00
|
|
|
log.Debug("create partition", zap.Int64("partitionID", partitionID))
|
2021-01-21 07:20:23 +00:00
|
|
|
return newPartition
|
|
|
|
}
|