Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions index/scorch/scorch.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ type trainer interface {
// trainer specific file transfer operations
copyFileLOCKED(file string, d index.IndexDirectory) error
updateBolt(snapshotsBucket *util.BoltBucketImpl, key []byte, value []byte) error

dropFileWriterIDs(ids map[string]struct{}) error
fileWriterIDsInUse() (map[string]struct{}, error)
}

type ScorchErrorType string
Expand Down Expand Up @@ -1116,10 +1119,12 @@ func (s *Scorch) SetPathInBolt(key []byte, value []byte) error {
return err
}

// currently this is specific to trained index file update
err = s.trainer.updateBolt(snapshotsBucket, key, value)
if err != nil {
return err
if s.trainer != nil {
// currently this is specific to trained index file update
err = s.trainer.updateBolt(snapshotsBucket, key, value)
if err != nil {
return err
}
}

err = tx.Commit()
Expand Down Expand Up @@ -1332,6 +1337,16 @@ func (s *Scorch) FileWriterIDsInUse() (map[string]struct{}, error) {
}
}

if s.trainer != nil {
trainerKeys, err := s.trainer.fileWriterIDsInUse()
if err != nil {
return nil, err
}
for k, _ := range trainerKeys {
keyMap[k] = struct{}{}
}
}

boltKeys, err := s.boltFileWriterIDsInUse()
if err != nil {
return nil, err
Expand All @@ -1354,6 +1369,13 @@ func (s *Scorch) DropFileWriterIDs(ids map[string]struct{}) error {
return err
}

if s.trainer != nil {
err := s.trainer.dropFileWriterIDs(ids)
if err != nil {
return err
}
}

s.rootLock.Lock()
// create a done channel to ensure success of merge
ctx := context.Background()
Expand Down
8 changes: 8 additions & 0 deletions index/scorch/train_noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,11 @@ func (t *noopTrainer) copyFileLOCKED(file string, d index.IndexDirectory) error
func (t *noopTrainer) updateBolt(snapshotsBucket *util.BoltBucketImpl, key []byte, value []byte) error {
return nil
}

func (t *noopTrainer) dropFileWriterIDs(ids map[string]struct{}) error {
return nil
}

func (t *noopTrainer) fileWriterIDsInUse() (map[string]struct{}, error) {
return nil, nil
}
Loading
Loading