通过librados读取Ceph对象的所有字节

时间:2018-07-11 17:21:38

标签: c ceph

CEPH_RADOS_API int rados_read(rados_ioctx_t io, const char * oid, char * buf, size_t len, uint64_t off)¶

   Read data from an object

   The io context determines the snapshot to read from, if any was set by rados_ioctx_snap_set_read().

   Return

      number of bytes read on success, negative error code on failure

   Parameters

      io: the context in which to perform the read
      oid: the name of the object to read from
      buf: where to store the results
      len: the number of bytes to read
      off: the offset to start reading from in the object

librados c同步读取功能询问要读取多少个字节,而没有显式的功能来读取整个对象。

如果我想读取对象的所有字节,则可以给它提供一个巨大的size_t值,假设到达对象末尾时它将被切断吗?还是会继续阅读?

在需要读取对象或将其存储在对象的元数据中之前,我可以确保知道对象的大小,但是如果可能的话,尽量避免执行那些不必要的步骤。

0 个答案:

没有答案