コード例 #1
0
// Write data to a striped object at the specified offset
// Implements the WriterAt interface
func (rso *RadosStripedObject) WriteAt(p []byte, off int64) (n int, err error) {
	obj := C.CString(rso.ObjectName)
	defer C.free(unsafe.Pointer(obj))
	c_offset := C.uint64_t(off)
	c_data := (*C.char)(unsafe.Pointer(&p[0]))
	c_size := C.size_t(len(p))
	ret := C.rados_striper_write(rso.Striper, obj, c_data, c_size, c_offset)
	if ret < 0 {
		return int(ret), errors.New("Unable to write")
	} else {
		return len(p), nil
	}
}
コード例 #2
0
ファイル: striper.go プロジェクト: wenjianhn/radoshttpd
func (sp *StriperPool) Write(oid string, data []byte, offset uint64) (int, error) {
	if len(data) == 0 {
		return 0, nil
	}

	c_oid := C.CString(oid)
	defer C.free(unsafe.Pointer(c_oid))

	ret := C.rados_striper_write(sp.striper, c_oid,
		(*C.char)(unsafe.Pointer(&data[0])),
		C.size_t(len(data)),
		C.uint64_t(offset))
	if ret >= 0 {
		return int(ret), nil
	} else {
		return 0, RadosError(int(ret))
	}

}