]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: update naming for new object list methods
authorJohn Spray <john.spray@redhat.com>
Tue, 24 Nov 2015 12:56:27 +0000 (12:56 +0000)
committerJohn Spray <john.spray@redhat.com>
Thu, 3 Dec 2015 14:57:39 +0000 (14:57 +0000)
Signed-off-by: John Spray <john.spray@redhat.com>
src/include/rados/librados.h
src/librados/librados.cc
src/test/librados/list.cc

index c7e279a40b7f7ab1d2d66e276ea34abb01f58d58..e9b5c91c0f502d9f76a926047e56cac34c9a25fe 100644 (file)
@@ -190,14 +190,14 @@ typedef void *rados_ioctx_t;
 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;
 
@@ -206,7 +206,7 @@ typedef struct rados_enumerate_item {
 
   size_t locator_length;
   char *locator;
-} rados_enumerate_item;
+} rados_object_list_item;
 
 /**
  * @typedef rados_snap_t
@@ -975,39 +975,52 @@ CEPH_RADOS_API int rados_nobjects_list_next(rados_list_ctx_t ctx,
  */
 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 */
index 593545aa2ddb6b5fdbebd5a4eb0ad8a765ddb71a..ea0661beaec09675683b90785f21291e2a4f3d9c 100644 (file)
@@ -3579,59 +3579,59 @@ extern "C" int rados_exec(rados_ioctx_t io, const char *o, const char *cls, cons
   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;
@@ -3662,7 +3662,7 @@ extern "C" int rados_enumerate_objects(rados_ioctx_t io,
   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);
@@ -3673,9 +3673,9 @@ extern "C" int rados_enumerate_objects(rados_ioctx_t io,
   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);
 
@@ -5079,14 +5079,14 @@ std::ostream& librados::operator<<(std::ostream& out, const librados::ListObject
   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;
 
index 4f7897f17727dd8f4f8861b4fadcc6e45277cf8b..c4b28bd25cdc6b4eb9bfc43d7a9cc306a02cd82c 100644 (file)
@@ -685,14 +685,14 @@ TEST_F(LibRadosList, EnumerateObjects) {
   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) {
@@ -703,10 +703,10 @@ TEST_F(LibRadosList, EnumerateObjects) {
       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))) {
@@ -733,17 +733,17 @@ TEST_F(LibRadosList, EnumerateObjectsSplit) {
   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,
@@ -755,13 +755,13 @@ TEST_F(LibRadosList, EnumerateObjectsSplit) {
                << *(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);
@@ -773,14 +773,14 @@ TEST_F(LibRadosList, EnumerateObjectsSplit) {
           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))) {