Beispiel #1
0
        protected override async Task <object[]> GetItemById(long id)
        {
            var redisId = GetRedisID(id);
            var db      = RedisDatabase.GetDatabase();

            return(ConvertToTypedRow(await db.ListRangeAsync(redisId)));
        }
Beispiel #2
0
 public override void Connect(string name)
 {
     if (!RedisDatabase.DatasetExists(name))
     {
         throw new NonExistantDatastoreException(name);
     }
     RootNamespace = name;
 }
Beispiel #3
0
        protected override void CreateOrReplaceDatastore(string name)
        {
            if (RedisDatabase.DatasetExists(name))
            {
                RedisDatabase.DestroyDataset(name);
            }

            RootNamespace = name;
            CreateDatastore(name);
        }
Beispiel #4
0
        protected override void CreateDatastore(string name)
        {
            if (RedisDatabase.DatasetExists(name))
            {
                throw new DatastoreExistsException(name);
            }

            RootNamespace = name;
            RedisDatabase.CreateDataset(name, dataFormat);
        }
Beispiel #5
0
        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))));
            }));
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        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);
            }
        }
Beispiel #9
0
 public override bool Exists(string name)
 {
     return(RedisDatabase.DatasetExists(name));
 }
Beispiel #10
0
 public override void Clear()
 {
     RedisDatabase.DeleteDatabase();
 }