Turi Create  4.0
turi::sframe_reader_buffer Class Reference

#include <core/storage/sframe_data/sframe_reader_buffer.hpp>

Public Member Functions

 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.
 
const sframe_rows::rownext ()
 Return the next element in the reader. More...
 
const sframe_rows::rowcurrent ()
 Returns the current element.
 
bool has_next ()
 Return true if the reader has more element. More...
 
sframe_rowsget_buffer ()
 Return the buffer.
 
size_t size ()
 Return the Number of elements between row_start and row_end.
 
void clear ()
 

Detailed Description

A buffered reader reading from a range of an sframe<T>.

sframe<flexible_type> mysframe = ...;
// Reader for the first thousand lines
sframe_reader_buffer<flexible_type> reader(mysframe, 0, 1000);
while(reader.has_next()) {
flexible_type val = reader.next();
... do some thing with val ...
}
// Reader for the entire sframe
reader = sframe_reader_buffer<flexible_type>(mysframe, 0, (size_t)(-1));
...

Internally, the reader maintains a vector as buffer, and when reading reaches the end of the buffer, refill the buffer by reading from sframe.

Definition at line 45 of file sframe_reader_buffer.hpp.

Member Function Documentation

◆ clear()

void turi::sframe_reader_buffer::clear ( )
inline

Resets the buffer to the initial starting conditions. Reading from the buffer again will start from row_start.

Definition at line 152 of file sframe_reader_buffer.hpp.

◆ has_next()

bool turi::sframe_reader_buffer::has_next ( )
inline

Return true if the reader has more element.

Return true if the chunk has remaining element.

Definition at line 140 of file sframe_reader_buffer.hpp.

◆ next()

const sframe_rows::row & turi::sframe_reader_buffer::next ( )
inline

Return the next element in the reader.

Return the next element in the chunk.

Definition at line 124 of file sframe_reader_buffer.hpp.


The documentation for this class was generated from the following file: