Skip to content

Commit

Permalink
add SupportsVisitor in the markset env interface
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed Aug 10, 2021
1 parent 79f348a commit 742c85b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions blockstore/splitstore/markset.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type MarkSetEnv interface {
// CreateVisitor is like Create, but returns a wider interface that supports atomic visits.
// It may not be supported by some markset types (e.g. bloom).
CreateVisitor(name string, sizeHint int64) (MarkSetVisitor, error)
// SupportsVisitor returns true if the marksets created by this environment support the visitor interface.
SupportsVisitor() bool
Close() error
}

Expand Down
2 changes: 2 additions & 0 deletions blockstore/splitstore/markset_badger.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func (e *BadgerMarkSetEnv) CreateVisitor(name string, sizeHint int64) (MarkSetVi
return e.create(name, sizeHint)
}

func (e *BadgerMarkSetEnv) SupportsVisitor() bool { return true }

func (e *BadgerMarkSetEnv) Close() error {
return os.RemoveAll(e.path)
}
Expand Down
2 changes: 2 additions & 0 deletions blockstore/splitstore/markset_bloom.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ func (e *BloomMarkSetEnv) CreateVisitor(name string, sizeHint int64) (MarkSetVis
return nil, xerrors.Errorf("bloom mark set does not support visitors due to false positives")
}

func (e *BloomMarkSetEnv) SupportsVisitor() bool { return false }

func (e *BloomMarkSetEnv) Close() error {
return nil
}
Expand Down
2 changes: 2 additions & 0 deletions blockstore/splitstore/markset_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func (e *MapMarkSetEnv) CreateVisitor(name string, sizeHint int64) (MarkSetVisit
return e.create(name, sizeHint)
}

func (e *MapMarkSetEnv) SupportsVisitor() bool { return true }

func (e *MapMarkSetEnv) Close() error {
return nil
}
Expand Down
4 changes: 4 additions & 0 deletions blockstore/splitstore/splitstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ func Open(path string, ds dstore.Datastore, hot, cold bstore.Blockstore, cfg *Co
return nil, err
}

if !markSetEnv.SupportsVisitor() {
return nil, xerrors.Errorf("markset type does not support atomic visitors")
}

// and now we can make a SplitStore
ss := &SplitStore{
cfg: cfg,
Expand Down

0 comments on commit 742c85b

Please sign in to comment.