6 #ifndef TURI_SFRAME_READER_BUFFER 7 #define TURI_SFRAME_READER_BUFFER 10 #include <core/data/flexible_type/flexible_type.hpp> 11 #include <core/storage/sframe_data/sframe.hpp> 12 #include <core/storage/sframe_data/sframe_constants.hpp> 53 std::shared_ptr<typename sframe::reader_type> reader,
54 size_t row_start,
size_t row_end,
56 init(reader, row_start, row_end, buffer_size);
59 void init(std::shared_ptr<typename sframe::reader_type>& reader,
60 size_t row_start,
size_t row_end,
65 m_original_row_start = row_start;
66 m_row_start = row_start;
67 m_row_end = std::min(row_end, m_reader->size());
68 m_buffer_size = internal_buffer_size;
85 inline size_t size() {
return m_row_end - m_original_row_start;}
105 std::shared_ptr<reader_type> m_reader;
108 size_t m_buffer_pos = 0;
110 size_t m_original_row_start = 0;
112 size_t m_row_start = 0;
114 size_t m_row_end = 0;
116 size_t m_buffer_size = 0;
125 if (m_buffer_pos == m_buffer.
num_rows()) {
129 DASSERT_LT(m_buffer_pos, m_buffer.
num_rows());
141 return m_iter < m_row_end;
145 inline void sframe_reader_buffer::refill() {
146 size_t size_of_refill = std::min<size_t>(m_row_end - m_row_start, m_buffer_size);
147 m_reader->read_rows(m_row_start, m_row_start + size_of_refill, m_buffer);
148 m_row_start += size_of_refill;
154 m_row_start = m_original_row_start;
155 m_iter = m_original_row_start;
size_t num_rows() const
Returns the number of rows.
sframe_rows & get_buffer()
Return the buffer.
const sframe_rows::row & current()
Returns the current element.
const size_t DEFAULT_SARRAY_READER_BUFFER_SIZE
const sframe_rows::row & next()
Return the next element in the reader.
sframe_reader_buffer(std::shared_ptr< typename sframe::reader_type > reader, size_t row_start, size_t row_end, size_t buffer_size=DEFAULT_SARRAY_READER_BUFFER_SIZE)
Construct from sframe reader with begin and end row.
size_t size()
Return the Number of elements between row_start and row_end.
bool has_next()
Return true if the reader has more element.
void copy_reference(const row &other)