Add Snapshot interface methods for moss child collections feature
This commit is contained in:
parent
501913b2eb
commit
04d428656e
@ -107,6 +107,7 @@ type llSnapshot struct {
|
|||||||
|
|
||||||
m sync.Mutex // Protects fields that follow.
|
m sync.Mutex // Protects fields that follow.
|
||||||
refs int
|
refs int
|
||||||
|
childSnapshots map[string]*llSnapshot
|
||||||
}
|
}
|
||||||
|
|
||||||
// llIterator represents a lower-level iterator, wrapping a bleve
|
// llIterator represents a lower-level iterator, wrapping a bleve
|
||||||
@ -316,6 +317,29 @@ func (llss *llSnapshot) decRef() {
|
|||||||
llss.m.Unlock()
|
llss.m.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ChildCollectionNames returns an array of child collection name strings.
|
||||||
|
func (llss *llSnapshot) ChildCollectionNames() ([]string, error) {
|
||||||
|
var childCollections = make([]string, len(llss.childSnapshots))
|
||||||
|
idx := 0
|
||||||
|
for name, _ := range llss.childSnapshots {
|
||||||
|
childCollections[idx] = name
|
||||||
|
idx++
|
||||||
|
}
|
||||||
|
return childCollections, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChildCollectionSnapshot returns a Snapshot on a given child
|
||||||
|
// collection by its name.
|
||||||
|
func (llss *llSnapshot) ChildCollectionSnapshot(childCollectionName string) (
|
||||||
|
moss.Snapshot, error) {
|
||||||
|
childSnapshot, exists := llss.childSnapshots[childCollectionName]
|
||||||
|
if !exists {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
childSnapshot.addRef()
|
||||||
|
return childSnapshot, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (llss *llSnapshot) Close() error {
|
func (llss *llSnapshot) Close() error {
|
||||||
llss.decRef()
|
llss.decRef()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user