Esempio n. 1
0
// check if exists all primary keys in the item to write it.
func (t *DynamoTable) isExistPrimaryKeys(item *SDK.PutItemInput) bool {
	hashKey := t.GetHashKeyName()
	itemAttrs := item.Item
	_, ok := itemAttrs[hashKey]
	if !ok {
		log.Warn("[DynamoDB] No HashKey, table="+t.name, hashKey)
		return false
	}
	rangeKey := t.GetRangeKeyName()
	_, ok = itemAttrs[rangeKey]
	if rangeKey != "" && !ok {
		log.Warn("[DynamoDB] No RangeKey, table="+t.name, rangeKey)
		return false
	}
	return true
}
Esempio n. 2
0
func (f *FileBuffer) Read(p []byte) (int, error) {
	n, err := bytes.NewBuffer(f.Buffer.Bytes()[f.Index:]).Read(p)
	if err == nil {
		if f.Index+int64(len(p)) < int64(f.Buffer.Len()) {
			f.Index += int64(len(p))
		} else {
			f.Index = int64(f.Buffer.Len())
		}
	} else {
		log.Warn("[S3Object] error on read file", err.Error())
	}
	return n, err
}
Esempio n. 3
0
func (f *FileBuffer) Seek(offset int64, whence int) (int64, error) {
	var err error
	var Index int64 = 0
	switch whence {
	case 0:
		if offset >= int64(f.Buffer.Len()) || offset < 0 {
			err = errors.New("Seek: Invalid Offset")
		} else {
			f.Index = offset
			Index = offset
		}
	default:
		err = errors.New("Unsupported Seek Method.")
	}
	if err != nil {
		log.Warn("[S3Object] error on seek file", err.Error())
	}
	return Index, err
}