| Index: impl/memory/datastore_data.go
|
| diff --git a/impl/memory/datastore_data.go b/impl/memory/datastore_data.go
|
| index b0613e6defa409ea8f70fe6cc285e1fa5ad979fc..ff06a4722099e6dbd770ea2ca067ad5bd5a888a9 100644
|
| --- a/impl/memory/datastore_data.go
|
| +++ b/impl/memory/datastore_data.go
|
| @@ -7,6 +7,7 @@ package memory
|
| import (
|
| "bytes"
|
| "fmt"
|
| + "strings"
|
| "sync"
|
| "sync/atomic"
|
|
|
| @@ -79,10 +80,10 @@ func (d *dataStoreData) setConsistent(always bool) {
|
| }
|
| }
|
|
|
| -func (d *dataStoreData) addIndexes(ns string, idxs []*ds.IndexDefinition) {
|
| +func (d *dataStoreData) addIndexes(idxs []*ds.IndexDefinition) {
|
| d.Lock()
|
| defer d.Unlock()
|
| - addIndexes(d.head, d.aid, ns, idxs)
|
| + addIndexes(d.head, d.aid, idxs)
|
| }
|
|
|
| func (d *dataStoreData) setAutoIndex(enable bool) {
|
| @@ -105,7 +106,7 @@ func (d *dataStoreData) maybeAutoIndex(err error) bool {
|
| return false
|
| }
|
|
|
| - d.addIndexes(mi.ns, []*ds.IndexDefinition{mi.Missing})
|
| + d.addIndexes([]*ds.IndexDefinition{mi.Missing})
|
| return true
|
| }
|
|
|
| @@ -165,6 +166,13 @@ func (d *dataStoreData) catchupIndexes() {
|
| d.snap = d.head.Snapshot()
|
| }
|
|
|
| +func (d *dataStoreData) namespaces() []string {
|
| + d.rwlock.Lock()
|
| + defer d.rwlock.Unlock()
|
| +
|
| + return namespaces(d.head)
|
| +}
|
| +
|
| /////////////////////////// indexes(dataStoreData) ////////////////////////////
|
|
|
| func groupMetaKey(key *ds.Key) []byte {
|
| @@ -570,3 +578,25 @@ func rpm(data []byte) (ds.PropertyMap, error) {
|
| return serialize.ReadPropertyMap(bytes.NewBuffer(data),
|
| serialize.WithContext, "", "")
|
| }
|
| +
|
| +func namespaces(store *memStore) []string {
|
| + var namespaces []string
|
| + for _, c := range store.GetCollectionNames() {
|
| + ns, has := trimPrefix(c, "ents:")
|
| + if !has {
|
| + if len(namespaces) > 0 {
|
| + break
|
| + }
|
| + continue
|
| + }
|
| + namespaces = append(namespaces, ns)
|
| + }
|
| + return namespaces
|
| +}
|
| +
|
| +func trimPrefix(v, p string) (string, bool) {
|
| + if strings.HasPrefix(v, p) {
|
| + return v[len(p):], true
|
| + }
|
| + return v, false
|
| +}
|
|
|