| Index: impl/memory/datastore_data.go
|
| diff --git a/impl/memory/datastore_data.go b/impl/memory/datastore_data.go
|
| index 95fe0daf8e6279311ae2e82e2fda84346648cab2..830e326b243907df5f9511e26c6a80dc293837c1 100644
|
| --- a/impl/memory/datastore_data.go
|
| +++ b/impl/memory/datastore_data.go
|
| @@ -27,6 +27,9 @@ type dataStoreData struct {
|
| txnFakeRetry int
|
| // true means that head always == snap
|
| consistent bool
|
| + // true means that queries with insufficent indexes will pause to add them
|
| + // and then continue instead of failing.
|
| + autoIndex bool
|
| }
|
|
|
| var (
|
| @@ -66,6 +69,39 @@ func (d *dataStoreData) setConsistent(always bool) {
|
| }
|
| }
|
|
|
| +func (d *dataStoreData) addIndexes(ns string, idxs []*ds.IndexDefinition) {
|
| + d.Lock()
|
| + defer d.Unlock()
|
| + addIndexes(d.head, ns, idxs)
|
| + if d.consistent {
|
| + d.snap = d.head.Snapshot()
|
| + }
|
| +}
|
| +
|
| +func (d *dataStoreData) setAutoIndex(enable bool) {
|
| + d.Lock()
|
| + defer d.Unlock()
|
| + d.autoIndex = enable
|
| +}
|
| +
|
| +func (d *dataStoreData) maybeAutoIndex(err error) bool {
|
| + mi, ok := err.(*ErrMissingIndex)
|
| + if !ok {
|
| + return false
|
| + }
|
| +
|
| + d.rwlock.RLock()
|
| + ai := d.autoIndex
|
| + d.rwlock.RUnlock()
|
| +
|
| + if !ai {
|
| + return false
|
| + }
|
| +
|
| + d.addIndexes(mi.ns, []*ds.IndexDefinition{mi.Missing})
|
| + return true
|
| +}
|
| +
|
| func (d *dataStoreData) getQuerySnaps(consistent bool) (idx, head *memStore) {
|
| d.rwlock.RLock()
|
| defer d.rwlock.RUnlock()
|
|
|