func (s *normalStrategy) handle(rawData [][]byte, _ []ds.Property, key ds.Key, gc func() (ds.Cursor, error)) bool {
	rawKey := rawData[len(rawData)-1]
	if !s.dedup.add(string(rawKey)) {
		return true
	}

	rawEnt := s.head.Get(rawKey)
	if rawEnt == nil {
		// entity doesn't exist at head
		return true
	}
	pm, err := serialize.ReadPropertyMap(bytes.NewBuffer(rawEnt), serialize.WithoutContext, globalAppID, s.ns)
	memoryCorruption(err)

	return s.cb(key, pm, gc)
}
示例#2
0
func decodeItemValue(val []byte, ns, aid string) (ds.PropertyMap, error) {
	if len(val) == 0 {
		return nil, ds.ErrNoSuchEntity
	}
	buf := bytes.NewBuffer(val)
	compTypeByte, err := buf.ReadByte()
	if err != nil {
		return nil, err
	}

	if CompressionType(compTypeByte) == ZlibCompression {
		reader, err := zlib.NewReader(buf)
		if err != nil {
			return nil, err
		}
		defer reader.Close()
		data, err := ioutil.ReadAll(reader)
		if err != nil {
			return nil, err
		}
		buf = bytes.NewBuffer(data)
	}
	return serialize.ReadPropertyMap(buf, serialize.WithoutContext, ns, aid)
}
示例#3
0
func rpm(data []byte) (ds.PropertyMap, error) {
	return serialize.ReadPropertyMap(bytes.NewBuffer(data),
		serialize.WithContext, "", "")
}
示例#4
0
func rpmWoCtx(data []byte, ns string) (ds.PropertyMap, error) {
	return serialize.ReadPropertyMap(bytes.NewBuffer(data),
		serialize.WithoutContext, globalAppID, ns)
}