func (sp *StriperPool) Read(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_read(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)) } }
// Read data from a striped object func (rso *RadosStripedObject) Read(p []byte) (n int, err error) { obj := C.CString(rso.ObjectName) defer C.free(unsafe.Pointer(obj)) ret := C.rados_striper_read(rso.Striper, obj, (*C.char)(unsafe.Pointer(&p[0])), C.size_t(len(p)), C.uint64_t(rso.Read_offset)) if ret < 0 { return int(ret), errors.New("read failed") } else { // update offset value for next read rso.Read_offset = rso.Read_offset + int64(ret) // if actual read was less than buffer size than reached end of object if int(ret) < len(p) { err = io.EOF } else { err = nil } return int(ret), err } }