Ejemplo n.º 1
0
// Append appends len(data) bytes to the object with key oid.
// The object is appended with the provided data. If the object exists,
// it is atomically appended to. It returns an error, if any.
func (ioctx *IOContext) Append(oid string, data []byte) error {
	c_oid := C.CString(oid)
	defer C.free(unsafe.Pointer(c_oid))

	ret := C.rados_append(ioctx.ioctx, c_oid,
		(*C.char)(unsafe.Pointer(&data[0])),
		(C.size_t)(len(data)))
	return GetRadosError(ret)
}
Ejemplo n.º 2
0
func (r *RadosIoCtx) Append(oid string, bin []byte) error {
	coid := C.CString(oid)
	defer func() {
		C.free(unsafe.Pointer(coid))
	}()
	cerr := C.rados_append(*r.ctx, coid, (*C.char)(unsafe.Pointer(&bin[0])), C.size_t(len(bin)))
	if cerr < 0 {
		return errors.New("append data failed")
	}
	return nil
}
Ejemplo n.º 3
0
// Append appends new data to the object
func (o *Object) Append(data io.Reader) error {
	oid := C.CString(o.name)
	defer freeString(oid)
	bufAddr, length := readerToBuf(data)
	ret := C.rados_append(o.ioContext, oid, bufAddr, length)
	if err := toRadosError(ret); err != nil {
		err.Message = fmt.Sprintf("Unable to append data to object %s", o.name)
		return err
	}
	return nil
}
Ejemplo n.º 4
0
// Append writes the given data to the end of the named object
// in the pool referenced by the given context.
func (c *Context) Append(name string, data []byte) error {
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))

	cdata, cdatalen := byteSliceToBuffer(data)

	if cerr := C.rados_append(c.ctx, cname, cdata, cdatalen); cerr < 0 {
		return fmt.Errorf("RADOS put %s: %s", name, strerror(cerr))
	}

	return nil
}
Ejemplo n.º 5
0
// Append writes the given data to the end of the named object
// in the pool referenced by the given context.
func (c *Context) Append(name string, data []byte) error {
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))

	cdata, cdatalen := byteSliceToBuffer(data)

	if cerr := C.rados_append(c.ctx, cname, cdata, cdatalen); cerr < 0 {
		return radosReturnCodeError(cerr)
	}

	return nil
}