]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common: drop get_contiguous() from ceph::bufferlist.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Sun, 7 Oct 2018 21:53:36 +0000 (23:53 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 8 Oct 2018 10:54:37 +0000 (12:54 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/common/buffer.cc
src/include/buffer.h
src/os/ObjectStore.h
src/test/bufferlist.cc
src/test/perf_local.cc

index c0c23f4bedc03d1ed4bc2c7afe8e2eace889be67..a96ff9844a2095039898ecb457cd2a4f7bb3e476 100644 (file)
@@ -1740,48 +1740,6 @@ using namespace ceph;
     return s;
   }
 
-  char *buffer::list::get_contiguous(unsigned orig_off, unsigned len)
-  {
-    if (orig_off + len > length())
-      throw end_of_buffer();
-
-    if (len == 0) {
-      return 0;
-    }
-
-    unsigned off = orig_off;
-    std::list<ptr>::iterator curbuf = _buffers.begin();
-    while (off > 0 && off >= curbuf->length()) {
-      off -= curbuf->length();
-      ++curbuf;
-    }
-
-    if (off + len > curbuf->length()) {
-      bufferlist tmp;
-      unsigned l = off + len;
-
-      do {
-       if (l >= curbuf->length())
-         l -= curbuf->length();
-       else
-         l = 0;
-       tmp.append(*curbuf);
-       curbuf = _buffers.erase(curbuf);
-
-      } while (curbuf != _buffers.end() && l > 0);
-
-      ceph_assert(l == 0);
-
-      tmp.rebuild();
-      _buffers.insert(curbuf, tmp._buffers.front());
-      return tmp.c_str() + off;
-    }
-
-    last_p = begin();  // we modified _buffers
-
-    return curbuf->c_str() + off;
-  }
-
   void buffer::list::substr_of(const list& other, unsigned off, unsigned len)
   {
     if (off + len > other.length())
index 1c941db15ce0c807d4f2fa9bbe025cf8ac1fa322..1fab7bcd6a0583ed3ccc4f08f54c65a95b7e174a 100644 (file)
@@ -910,11 +910,6 @@ namespace buffer CEPH_BUFFER_API {
 
     void substr_of(const list& other, unsigned off, unsigned len);
 
-    /// return a pointer to a contiguous extent of the buffer,
-    /// reallocating as needed
-    char *get_contiguous(unsigned off,  ///< offset
-                        unsigned len); ///< length
-
     // funky modifer
     void splice(unsigned off, unsigned len, list *claim_by=0 /*, bufferlist& replace_with */);
     void write(int off, int len, std::ostream& out) const;
index 129b366ea8b2956766e574194217d5b112fad653..7221ec617483650bd9c18a4465dd4dc234e192f2 100644 (file)
@@ -868,7 +868,7 @@ public:
           objects(t->object_index.size()) {
 
         ops = t->data.ops;
-        op_buffer_p = t->op_bl.get_contiguous(0, t->data.ops * sizeof(Op));
+        op_buffer_p = t->op_bl.c_str();
 
         map<coll_t, __le32>::iterator coll_index_p;
         for (coll_index_p = t->coll_index.begin();
index 1d9689fe966cfc5f524f1000076da9602cee6d62..359ab65a08e0c82f4321da93d29a514d0325ce0c 100644 (file)
@@ -1348,55 +1348,6 @@ TEST(BufferList, to_str) {
   }
 }
 
-TEST(BufferList, get_contiguous) {
-  {
-    bufferptr a("foobarbaz", 9);
-    bufferptr b("123456789", 9);
-    bufferptr c("ABCDEFGHI", 9);
-    bufferlist bl;
-    ASSERT_EQ(0, bl.get_contiguous(0, 0));
-
-    bl.append(a);
-    bl.append(b);
-    bl.append(c);
-    ASSERT_EQ(3u, bl.get_num_buffers());
-    ASSERT_EQ(0, memcmp("bar", bl.get_contiguous(3, 3), 3));
-    ASSERT_EQ(0, memcmp("456", bl.get_contiguous(12, 3), 3));
-    ASSERT_EQ(0, memcmp("ABC", bl.get_contiguous(18, 3), 3));
-    ASSERT_EQ(3u, bl.get_num_buffers());
-    ASSERT_EQ(0, memcmp("789ABC", bl.get_contiguous(15, 6), 6));
-    ASSERT_EQ(2u, bl.get_num_buffers());
-  }
-
-  {
-    bufferptr a("foobarbaz", 9);
-    bufferptr b("123456789", 9);
-    bufferptr c("ABCDEFGHI", 9);
-    bufferlist bl;
-
-    bl.append(a);
-    bl.append(b);
-    bl.append(c);
-
-    ASSERT_EQ(0, memcmp("789ABCDEFGHI", bl.get_contiguous(15, 12), 12));
-    ASSERT_EQ(2u, bl.get_num_buffers());
-  }
-
-  {
-    bufferptr a("foobarbaz", 9);
-    bufferptr b("123456789", 9);
-    bufferptr c("ABCDEFGHI", 9);
-    bufferlist bl;
-
-    bl.append(a);
-    bl.append(b);
-    bl.append(c);
-
-    ASSERT_EQ(0, memcmp("z123456789AB", bl.get_contiguous(8, 12), 12));
-    ASSERT_EQ(1u, bl.get_num_buffers());
-  }
-}
-
 TEST(BufferList, swap) {
   bufferlist b1;
   b1.append('A');
index d58a54507ea20c37831fe0f9133723edfb46d9a1..c2a2c2bcf6c9ad2a2b18379750eb8b80099f8df9 100644 (file)
@@ -278,22 +278,6 @@ double buffer_encode()
   return Cycles::to_seconds(total)/(count*10);
 }
 
-// Measure the cost of retrieving an object from the beginning of a buffer.
-double buffer_get_contiguous()
-{
-  int count = 1000000;
-  int value = 11;
-  bufferlist b;
-  b.append((char*)&value, sizeof(value));
-  int sum = 0;
-  uint64_t start = Cycles::rdtsc();
-  for (int i = 0; i < count; i++) {
-    sum += *reinterpret_cast<int*>(b.get_contiguous(0, sizeof(value)));
-  }
-  uint64_t stop = Cycles::rdtsc();
-  return Cycles::to_seconds(stop - start)/count;
-}
-
 // Measure the cost of creating an iterator and iterating over 10
 // chunks in a buffer.
 double buffer_iterator()
@@ -930,8 +914,6 @@ TestInfo tests[] = {
     "copy out 2 small ptrs from buffer"},
   {"buffer_encode10", buffer_encode,
     "buffer encoding 10 structures onto existing ptr"},
-  {"buffer_get_contiguous", buffer_get_contiguous,
-    "Buffer::get_contiguous"},
   {"buffer_iterator", buffer_iterator,
     "iterate over buffer with 5 ptrs"},
   {"cond_ping_pong", cond_ping_pong,