memStoreImpl implements the MemStore interface.
| 74 | |
| 75 | // memStoreImpl implements the MemStore interface. |
| 76 | type memStoreImpl struct { |
| 77 | // memStoreImpl mutex is used to protect the TableShards and TableSchemas maps. |
| 78 | // |
| 79 | // For Shard access: |
| 80 | // Readers/writers must call TableShard.liveStore.Users.Add(1) |
| 81 | // before releasing this mutex, and call |
| 82 | // TableShard.liveStore.Users.Done() after their businesses. |
| 83 | // |
| 84 | // Table Shard deleter must detach the Shard first, and then call |
| 85 | // TableShard.liveStore.Users.Wait() before deleting the Shard. |
| 86 | // |
| 87 | // For schema access: |
| 88 | // User should lock the TableSchema before releasing this mutex. |
| 89 | // |
| 90 | sync.RWMutex |
| 91 | // Table name and Shard ID as the map keys. |
| 92 | TableShards map[string]map[int]*TableShard |
| 93 | // Schema for all tables in the system. Schemas are not deleted for simplicity |
| 94 | TableSchemas map[string]*common.TableSchema |
| 95 | |
| 96 | HostMemManager common.HostMemoryManager |
| 97 | |
| 98 | // reference to metaStore for registering watchers, |
| 99 | // fetch latest schema and store Shard versions. |
| 100 | metaStore metaCom.MetaStore |
| 101 | diskStore diskstore.DiskStore |
| 102 | options Options |
| 103 | |
| 104 | // each MemStore should only have one scheduler instance. |
| 105 | scheduler Scheduler |
| 106 | } |
| 107 | |
| 108 | func getTableShardKey(tableName string, shardID int) string { |
| 109 | return fmt.Sprintf("%s_%d", tableName, shardID) |
nothing calls this directly
no outgoing calls
no test coverage detected