protected override async Task <object[]> GetItemById(long id) { var redisId = GetRedisID(id); var db = RedisDatabase.GetDatabase(); return(ConvertToTypedRow(await db.ListRangeAsync(redisId))); }
private Task <IEnumerable <object[]> > GetRowsFromIndex(RedisKey indexKey) { var db = RedisDatabase.GetDatabase(); return(db.SetMembersAsync(indexKey).ContinueWith( (labelledKeysTask) => { var labelledKeys = labelledKeysTask.Result.Select(k => (long)k); return labelledKeys.Select(k => ConvertToTypedRow(db.ListRange(GetRedisID(k)))); })); }
public override async Task AddUnlabelledRow(object[] unlabelled) { long id = dataFormat.GetID(unlabelled); RedisKey idKey = GetRedisID(id); IEnumerable <RedisValue> featureValues = unlabelled.Select(d => (RedisValue)(d.ToString())); var db = RedisDatabase.GetDatabase(); long listLength = await db.ListRightPushAsync(idKey, featureValues.ToArray()); await db.SetAddAsync(GetUnlabelledIndexKey(), id); }
public override async Task AddLabelledRow(object[] labelled) { long id = dataFormat.GetID(labelled); //we assume by convention that ID is the first element in the array RedisKey idKey = GetRedisID(id); //the remaining information is the list of feature values IEnumerable <RedisValue> featureValues = labelled.Select(d => (RedisValue)(d.ToString())); var db = RedisDatabase.GetDatabase(); //create a list using ListRightPush to store the data long listLength = await db.ListRightPushAsync(idKey, featureValues.ToArray()); await db.SetAddAsync(GetLabelledIndexKey(), id); }
public override async Task AddLabels(IDictionary <long, string> idLabelLookups) { var db = RedisDatabase.GetDatabase(); foreach (var kvp in idLabelLookups) { long id = kvp.Key; string label = kvp.Value; RedisKey idKey = GetRedisID(id); await db.ListRightPushAsync(idKey, label); await db.SetRemoveAsync(GetUnlabelledIndexKey(), id); await db.SetAddAsync(GetLabelledIndexKey(), id); } }