mirror of
https://github.com/apache/arrow.git
synced 2026-10-29 00:56:31 +08:00
added 'print' method to Buffer class
This commit is contained in:
1 parent
982f341bc8
commit
7d945eb554
4 files changed
+16
No files matched your search
@@ -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_ ||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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):
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user