add SupportsVisitor in the markset env interface
This commit is contained in:
parent
79f348a01c
commit
742c85bf81
@ -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
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user