MCPcopy Create free account
hub / github.com/couchbase/moss / openCollection

Method openCollection

store.go:640–685  ·  view source on GitHub ↗

--------------------------------------------------------

(
	options StoreOptions,
	persistOptions StorePersistOptions)

Source from the content-addressed store, hash-verified

638// --------------------------------------------------------
639
640func (s *Store) openCollection(
641 options StoreOptions,
642 persistOptions StorePersistOptions) (Collection, error) {
643 storeSnapshotInit, err := s.Snapshot()
644 if err != nil {
645 return nil, err
646 }
647
648 co := options.CollectionOptions
649 co.LowerLevelInit = storeSnapshotInit
650 co.LowerLevelUpdate = func(higher Snapshot) (Snapshot, error) {
651 var ss Snapshot
652 var erro error
653 ss, erro = s.Persist(higher, persistOptions)
654 if erro != nil {
655 return nil, erro
656 }
657
658 if storeSnapshotInit != nil {
659 storeSnapshotInit.Close()
660 storeSnapshotInit = nil
661 }
662
663 return ss, erro
664 }
665
666 storeFooter, ok := storeSnapshotInit.(*Footer)
667 if !ok {
668 storeSnapshotInit.Close()
669 return nil, fmt.Errorf("store: wrong storeSnapshotInit type")
670 }
671
672 coll, err := restoreCollection(&co, storeFooter)
673 if err != nil {
674 storeSnapshotInit.Close()
675 return nil, err
676 }
677
678 err = coll.Start()
679 if err != nil {
680 storeSnapshotInit.Close()
681 return nil, err
682 }
683
684 return coll, nil
685}
686
687// statsReporter interface represents stats reporting methods.
688type statsReporter interface {

Callers 1

OpenCollectionMethod · 0.95

Calls 5

SnapshotMethod · 0.95
PersistMethod · 0.95
restoreCollectionFunction · 0.85
CloseMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected