func (s *DynamoStore) Root() hash.Hash { result, err := s.ddbsvc.GetItem(&dynamodb.GetItemInput{ TableName: aws.String(s.table), Key: map[string]*dynamodb.AttributeValue{ refAttr: {B: s.rootKey}, }, }) d.PanicIfError(err) itemLen := len(result.Item) if itemLen == 0 { return hash.Hash{} } d.Chk.True(itemLen == 2 || itemLen == 3, "Root should have 2 or three attributes on it: %+v", result.Item) if itemLen == 3 { d.Chk.True(result.Item[compAttr] != nil) d.Chk.True(result.Item[compAttr].S != nil) d.Chk.True(noneValue == *result.Item[compAttr].S) } return hash.FromSlice(result.Item[chunkAttr].B) }
func (s *DynamoStore) processResponses(responses []map[string]*dynamodb.AttributeValue, batch ReadBatch) { for _, item := range responses { p := item[refAttr] d.Chk.True(p != nil) r := hash.FromSlice(s.removeNamespace(p.B)) p = item[chunkAttr] d.Chk.True(p != nil) b := p.B if p = item[compAttr]; p != nil && *p.S == gzipValue { gr, err := gzip.NewReader(bytes.NewReader(b)) d.Chk.NoError(err) buf := &bytes.Buffer{} _, err = io.Copy(buf, gr) d.Chk.NoError(err) b = buf.Bytes() } c := NewChunkWithHash(r, b) for _, reqChan := range batch[r] { reqChan.Satisfy(c) } delete(batch, r) } }