You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by om...@apache.org on 2019/03/12 17:26:29 UTC

[orc] branch master updated: ORC-478: [C++] Add move constructor for DataBuffer to enable memory ownership transfer.

This is an automated email from the ASF dual-hosted git repository.

omalley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/orc.git


The following commit(s) were added to refs/heads/master by this push:
     new a753662  ORC-478: [C++] Add move constructor for DataBuffer to enable memory ownership transfer.
a753662 is described below

commit a7536622addddc6f20b78b0b1eca787ecf52bfee
Author: Yurui Zhou <yu...@alibaba-inc.com>
AuthorDate: Tue Mar 12 11:38:57 2019 +0800

    ORC-478: [C++] Add move constructor for DataBuffer to enable memory ownership
    transfer.
    
    Fixes #375
    
    Signed-off-by: Owen O'Malley <om...@apache.org>
---
 c++/include/orc/MemoryPool.hh |  3 +++
 c++/src/MemoryPool.cc         | 12 ++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/c++/include/orc/MemoryPool.hh b/c++/include/orc/MemoryPool.hh
index 2cf9e84..32db084 100644
--- a/c++/include/orc/MemoryPool.hh
+++ b/c++/include/orc/MemoryPool.hh
@@ -51,6 +51,9 @@ namespace orc {
 
   public:
     DataBuffer(MemoryPool& pool, uint64_t _size = 0);
+
+    DataBuffer(DataBuffer<T>&& buffer) noexcept;
+
     virtual ~DataBuffer();
 
     T* data() {
diff --git a/c++/src/MemoryPool.cc b/c++/src/MemoryPool.cc
index 14b7ebf..ecfb295 100644
--- a/c++/src/MemoryPool.cc
+++ b/c++/src/MemoryPool.cc
@@ -62,6 +62,18 @@ namespace orc {
   }
 
   template <class T>
+  DataBuffer<T>::DataBuffer(DataBuffer<T>&& buffer
+                      ) noexcept:
+                      memoryPool(buffer.memoryPool),
+                      buf(buffer.buf),
+                      currentSize(buffer.currentSize),
+                      currentCapacity(buffer.currentCapacity)  {
+    buffer.buf = nullptr;
+    buffer.currentSize = 0;
+    buffer.currentCapacity = 0;
+  }
+
+  template <class T>
   DataBuffer<T>::~DataBuffer(){
     for(uint64_t i=currentSize; i > 0; --i) {
       (buf + i - 1)->~T();