Query returns a an iterator for the supplied query.
(q *query.Query, local, internal bool)
| 68 | |
| 69 | // Query returns a an iterator for the supplied query. |
| 70 | func (s *StorageInterface) Query(q *query.Query, local, internal bool) (*iterator.Iterator, error) { |
| 71 | // Parse key and check if valid. |
| 72 | mapName, _ := parseDBKey(q.DatabaseKeyPrefix()) |
| 73 | if mapName == "" { |
| 74 | return nil, storage.ErrNotFound |
| 75 | } |
| 76 | |
| 77 | // Get map. |
| 78 | m, ok := getMapForAPI(mapName) |
| 79 | if !ok { |
| 80 | return nil, storage.ErrNotFound |
| 81 | } |
| 82 | |
| 83 | // Start query worker. |
| 84 | it := iterator.New() |
| 85 | module.mgr.Go("map query", func(_ *mgr.WorkerCtx) error { |
| 86 | s.processQuery(m, q, it) |
| 87 | return nil |
| 88 | }) |
| 89 | |
| 90 | return it, nil |
| 91 | } |
| 92 | |
| 93 | func (s *StorageInterface) processQuery(m *Map, q *query.Query, it *iterator.Iterator) { |
| 94 | // Return all matching pins. |
nothing calls this directly
no test coverage detected