Exemple #1
0
        public async Task <KeyedItems <SerializedItemDescriptor> > GetAllAsync(DataKind kind)
        {
            var ret = new List <KeyValuePair <string, SerializedItemDescriptor> >();
            var req = MakeQueryForKind(kind);
            await DynamoDBHelpers.IterateQuery(_client, req,
                                               item =>
            {
                var itemOut = UnmarshalItem(kind, item);
                if (itemOut.HasValue)
                {
                    var itemKey = item[DynamoDB.DataStoreSortKey].S;
                    ret.Add(new KeyValuePair <string, SerializedItemDescriptor>(itemKey, itemOut.Value));
                }
            });

            return(new KeyedItems <SerializedItemDescriptor>(ret));
        }
Exemple #2
0
        private async Task <HashSet <Tuple <string, string> > > ReadExistingKeys(IEnumerable <DataKind> kinds)
        {
            var keys = new HashSet <Tuple <string, string> >();

            foreach (var kind in kinds)
            {
                var req = MakeQueryForKind(kind);
                req.ProjectionExpression     = "#namespace, #key";
                req.ExpressionAttributeNames = new Dictionary <string, string>()
                {
                    { "#namespace", DynamoDB.DataStorePartitionKey },
                    { "#key", DynamoDB.DataStoreSortKey }
                };
                await DynamoDBHelpers.IterateQuery(_client, req,
                                                   item => keys.Add(new Tuple <string, string>(
                                                                        item[DynamoDB.DataStorePartitionKey].S,
                                                                        item[DynamoDB.DataStoreSortKey].S))
                                                   );
            }
            return(keys);
        }