added 'print' method to Buffer class

This commit is contained in:
Anatoly Myachev committed 2019-05-14 19:04:09 +03:00
1 parent 982f341bc8
commit 7d945eb554
4 files changed
+16

No files matched your search

+10
View File
@@ -18,6 +18,7 @@
#include "arrow/buffer.h"
#include <cstdint>
#include <iostream>
#include <utility>
#include "arrow/memory_pool.h"
@@ -47,6 +48,15 @@ Status Buffer::Copy(const int64_t start, const int64_t nbytes,
return Copy(start, nbytes, default_memory_pool(), out);
}
void Buffer::print() {
const uint8_t* _data = is_mutable() ? mutable_data() : data();
for (int64_t i = 0; i < size(); ++i) {
std::cout << std::hex << static_cast<unsigned int>(_data[i]);
}
std::cout << std::endl;
}
bool Buffer::Equals(const Buffer& other, const int64_t nbytes) const {
return this == &other || (size_ >= nbytes && other.size_ >= nbytes &&
(data_ == other.data_ ||
+2
View File
@@ -89,6 +89,8 @@ class ARROW_EXPORT Buffer {
bool is_mutable() const { return is_mutable_; }
void print();
/// Return true if both buffers are the same size and contain the same bytes
/// up to the number of compared bytes
bool Equals(const Buffer& other, int64_t nbytes) const;
+1
View File
@@ -208,6 +208,7 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
int64_t size()
shared_ptr[CBuffer] parent()
c_bool is_mutable() const
void print()
c_bool Equals(const CBuffer& other)
shared_ptr[CBuffer] SliceBuffer(const shared_ptr[CBuffer]& buffer,
+3
View File
@@ -868,6 +868,9 @@ cdef class Buffer:
"""
return <uintptr_t> self.buffer.get().data()
def print(self):
self.buffer.get().print()
@property
def is_mutable(self):
"""