typedef void *rados_list_ctx_t;
/**
- * @typedef rados_enumerate_cursor
+ * @typedef rados_object_list_cursor
*
* The cursor used with rados_enumerate_objects
* and accompanying methods.
*/
-typedef void * rados_enumerate_cursor;
+typedef void * rados_object_list_cursor;
-typedef struct rados_enumerate_item {
+typedef struct rados_object_list_item {
size_t oid_length;
char *oid;
size_t locator_length;
char *locator;
-} rados_enumerate_item;
+} rados_object_list_item;
/**
* @typedef rados_snap_t
*/
CEPH_RADOS_API void rados_nobjects_list_close(rados_list_ctx_t ctx);
-CEPH_RADOS_API rados_enumerate_cursor rados_enumerate_objects_begin(rados_ioctx_t io);
-CEPH_RADOS_API rados_enumerate_cursor rados_enumerate_objects_end(rados_ioctx_t io);
+CEPH_RADOS_API rados_object_list_cursor rados_object_list_begin(rados_ioctx_t io);
+CEPH_RADOS_API rados_object_list_cursor rados_object_list_end(rados_ioctx_t io);
-CEPH_RADOS_API int rados_enumerate_objects_is_end(rados_ioctx_t io,
- rados_enumerate_cursor cur);
+CEPH_RADOS_API int rados_object_list_is_end(rados_ioctx_t io,
+ rados_object_list_cursor cur);
-CEPH_RADOS_API void rados_enumerate_cursor_free(rados_ioctx_t io,
- rados_enumerate_cursor cur);
+CEPH_RADOS_API void rados_object_list_cursor_free(rados_ioctx_t io,
+ rados_object_list_cursor cur);
-CEPH_RADOS_API int rados_enumerate_cursor_cmp(rados_ioctx_t io,
- rados_enumerate_cursor lhs, rados_enumerate_cursor rhs);
+CEPH_RADOS_API int rados_object_list_cursor_cmp(rados_ioctx_t io,
+ rados_object_list_cursor lhs, rados_object_list_cursor rhs);
/**
* @return the number of items set in the result array
*/
-CEPH_RADOS_API int rados_enumerate_objects(rados_ioctx_t io,
- const rados_enumerate_cursor start,
- const rados_enumerate_cursor finish,
+CEPH_RADOS_API int rados_object_list(rados_ioctx_t io,
+ const rados_object_list_cursor start,
+ const rados_object_list_cursor finish,
const size_t result_size,
- rados_enumerate_item *results,
- rados_enumerate_cursor *next);
+ rados_object_list_item *results,
+ rados_object_list_cursor *next);
-CEPH_RADOS_API void rados_enumerate_objects_free(
+CEPH_RADOS_API void rados_object_list_free(
const size_t result_size,
- rados_enumerate_item *results);
+ rados_object_list_item *results);
-CEPH_RADOS_API void rados_enumerate_objects_split(rados_ioctx_t io,
- const rados_enumerate_cursor start,
- const rados_enumerate_cursor finish,
+/**
+ * Obtain cursors delineating a subset of a range. Use this
+ * when you want to split up the work of iterating over the
+ * global namespace. Expected use case is when you are iterating
+ * in parallel, with `m` workers, and each worker taking an id `n`.
+ *
+ * @param start start of the range to be sliced up (inclusive)
+ * @param finish end of the range to be sliced up (exclusive)
+ * @param m how many chunks to divide start-finish into
+ * @param n which of the m chunks you would like to get cursors for
+ * @param split_start cursor populated with start of the subrange (inclusive)
+ * @param split_finish cursor populated with end of the subrange (exclusive)
+ */
+CEPH_RADOS_API void rados_object_list_slice(rados_ioctx_t io,
+ const rados_object_list_cursor start,
+ const rados_object_list_cursor finish,
const size_t n,
const size_t m,
- rados_enumerate_cursor *split_start,
- rados_enumerate_cursor *split_finish);
+ rados_object_list_cursor *split_start,
+ rados_object_list_cursor *split_finish);
/** @} New Listing Objects */
return ret;
}
-extern "C" rados_enumerate_cursor rados_enumerate_objects_begin(rados_ioctx_t io)
+extern "C" rados_object_list_cursor rados_object_list_begin(rados_ioctx_t io)
{
librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
hobject_t *result = new hobject_t(ctx->objecter->enumerate_objects_begin());
- return (rados_enumerate_cursor)result;
+ return (rados_object_list_cursor)result;
}
-extern "C" rados_enumerate_cursor rados_enumerate_objects_end(rados_ioctx_t io)
+extern "C" rados_object_list_cursor rados_object_list_end(rados_ioctx_t io)
{
librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
hobject_t *result = new hobject_t(ctx->objecter->enumerate_objects_end());
- return (rados_enumerate_cursor)result;
+ return (rados_object_list_cursor)result;
}
-extern "C" int rados_enumerate_objects_is_end(
- rados_ioctx_t io, rados_enumerate_cursor cur)
+extern "C" int rados_object_list_is_end(
+ rados_ioctx_t io, rados_object_list_cursor cur)
{
hobject_t *hobj = (hobject_t*)cur;
return hobj->is_max();
}
-extern "C" void rados_enumerate_cursor_free(
- rados_ioctx_t io, rados_enumerate_cursor cur)
+extern "C" void rados_object_list_cursor_free(
+ rados_ioctx_t io, rados_object_list_cursor cur)
{
hobject_t *hobj = (hobject_t*)cur;
delete hobj;
}
-extern "C" int rados_enumerate_cursor_cmp(
+extern "C" int rados_object_list_cursor_cmp(
rados_ioctx_t io,
- rados_enumerate_cursor lhs_cur,
- rados_enumerate_cursor rhs_cur)
+ rados_object_list_cursor lhs_cur,
+ rados_object_list_cursor rhs_cur)
{
hobject_t *lhs = (hobject_t*)lhs_cur;
hobject_t *rhs = (hobject_t*)rhs_cur;
return cmp_bitwise(*lhs, *rhs);
}
-extern "C" int rados_enumerate_objects(rados_ioctx_t io,
- const rados_enumerate_cursor start,
- const rados_enumerate_cursor finish,
+extern "C" int rados_object_list(rados_ioctx_t io,
+ const rados_object_list_cursor start,
+ const rados_object_list_cursor finish,
const size_t result_item_count,
- rados_enumerate_item *result_items,
- rados_enumerate_cursor *next)
+ rados_object_list_item *result_items,
+ rados_object_list_cursor *next)
{
assert(next);
librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
// Zero out items so that they will be safe to free later
- //memset(result_items, 0, sizeof(rados_enumerate_item) * result_item_count);
+ memset(result_items, 0, sizeof(rados_object_list_item) * result_item_count);
std::list<librados::ListObjectImpl> result;
hobject_t next_hash;
int k = 0;
for (std::list<librados::ListObjectImpl>::iterator i = result.begin();
i != result.end(); ++i) {
- rados_enumerate_item &item = result_items[k++];
+ rados_object_list_item &item = result_items[k++];
do_out_buffer(i->oid, &item.oid, &item.oid_length);
do_out_buffer(i->nspace, &item.nspace, &item.nspace_length);
do_out_buffer(i->locator, &item.locator, &item.locator_length);
return result.size();
}
-extern "C" void rados_enumerate_objects_free(
+extern "C" void rados_object_list_free(
const size_t result_size,
- rados_enumerate_item *results)
+ rados_object_list_item *results)
{
assert(results);
return out;
}
-CEPH_RADOS_API void rados_enumerate_objects_split(
+CEPH_RADOS_API void rados_object_list_slice(
rados_ioctx_t io,
- const rados_enumerate_cursor start,
- const rados_enumerate_cursor finish,
+ const rados_object_list_cursor start,
+ const rados_object_list_cursor finish,
const size_t n,
const size_t m,
- rados_enumerate_cursor *split_start,
- rados_enumerate_cursor *split_finish)
+ rados_object_list_cursor *split_start,
+ rados_object_list_cursor *split_finish)
{
librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
ASSERT_TRUE(err_str.empty());
std::set<std::string> saw_obj;
- rados_enumerate_cursor c = rados_enumerate_objects_begin(ioctx);
- rados_enumerate_cursor end = rados_enumerate_objects_end(ioctx);
- while(!rados_enumerate_objects_is_end(ioctx, c))
+ rados_object_list_cursor c = rados_object_list_begin(ioctx);
+ rados_object_list_cursor end = rados_object_list_end(ioctx);
+ while(!rados_object_list_is_end(ioctx, c))
{
- rados_enumerate_item results[12];
- memset(results, 0, sizeof(rados_enumerate_item) * 12);
- int r = rados_enumerate_objects(ioctx,
- c, rados_enumerate_objects_end(ioctx),
+ rados_object_list_item results[12];
+ memset(results, 0, sizeof(rados_object_list_item) * 12);
+ int r = rados_object_list(ioctx,
+ c, rados_object_list_end(ioctx),
12, results, &c);
ASSERT_GE(r, 0);
for (int i = 0; i < r; ++i) {
ASSERT_FALSE(saw_obj.count(oid));
saw_obj.insert(oid);
}
- rados_enumerate_objects_free(12, results);
+ rados_object_list_free(12, results);
}
- rados_enumerate_cursor_free(ioctx, c);
- rados_enumerate_cursor_free(ioctx, end);
+ rados_object_list_cursor_free(ioctx, c);
+ rados_object_list_cursor_free(ioctx, end);
for (unsigned i=0; i<n_objects; ++i) {
if (!saw_obj.count(stringify(i))) {
std::string err_str = set_pg_num(&s_cluster, pool_name, 11);
ASSERT_TRUE(err_str.empty());
- rados_enumerate_cursor begin = rados_enumerate_objects_begin(ioctx);
- rados_enumerate_cursor end = rados_enumerate_objects_end(ioctx);
+ rados_object_list_cursor begin = rados_object_list_begin(ioctx);
+ rados_object_list_cursor end = rados_object_list_end(ioctx);
// Step through an odd number of shards
unsigned m = 5;
std::set<std::string> saw_obj;
for (unsigned n = 0; n < m; ++n) {
- rados_enumerate_cursor shard_start = rados_enumerate_objects_begin(ioctx);;
- rados_enumerate_cursor shard_end = rados_enumerate_objects_end(ioctx);;
+ rados_object_list_cursor shard_start = rados_object_list_begin(ioctx);;
+ rados_object_list_cursor shard_end = rados_object_list_end(ioctx);;
- rados_enumerate_objects_split(
+ rados_object_list_slice(
ioctx,
begin,
end,
<< *(hobject_t*)shard_start << " "
<< *(hobject_t*)shard_end << std::endl;
- rados_enumerate_cursor c = shard_start;
+ rados_object_list_cursor c = shard_start;
//while(c < shard_end)
- while(rados_enumerate_cursor_cmp(ioctx, c, shard_end) == -1)
+ while(rados_object_list_cursor_cmp(ioctx, c, shard_end) == -1)
{
- rados_enumerate_item results[12];
- memset(results, 0, sizeof(rados_enumerate_item) * 12);
- int r = rados_enumerate_objects(ioctx,
+ rados_object_list_item results[12];
+ memset(results, 0, sizeof(rados_object_list_item) * 12);
+ int r = rados_object_list(ioctx,
c, shard_end,
12, results, &c);
ASSERT_GE(r, 0);
ASSERT_FALSE(saw_obj.count(oid));
saw_obj.insert(oid);
}
- rados_enumerate_objects_free(12, results);
+ rados_object_list_free(12, results);
}
- rados_enumerate_cursor_free(ioctx, shard_start);
- rados_enumerate_cursor_free(ioctx, shard_end);
+ rados_object_list_cursor_free(ioctx, shard_start);
+ rados_object_list_cursor_free(ioctx, shard_end);
}
- rados_enumerate_cursor_free(ioctx, begin);
- rados_enumerate_cursor_free(ioctx, end);
+ rados_object_list_cursor_free(ioctx, begin);
+ rados_object_list_cursor_free(ioctx, end);
for (unsigned i=0; i<n_objects; ++i) {
if (!saw_obj.count(stringify(i))) {