public (DataPage <TPrimaryKey, TRow> NewValue, TRow PreviousValue) Update(TRow newValue) { var key = _keySelector(newValue); if (!_map.TryGet(key, out var page)) { throw new Exception($"Failed to row to update at key: '{key}'"); } var previous = page.Value.Row; page.Value.Update(newValue); return(page.Value, previous); }
public void Remove(TIndexKey key, TPrimaryKey primaryKey) { if (!_map.TryGet(key, out var group)) { throw new Exception($"Unable to find group at key: '{key}'"); } if (!group.Value.Remove(DataPage <TPrimaryKey, TRow> .SurrogateForKey(primaryKey), out _)) { throw new Exception($"Attempted to remove non-existent row with primary key: '{primaryKey}' from group at key '{key}'"); } _map.Remove(key, out _); }