6 #ifndef TURI_SFRAME_sframe_rows_HPP 7 #define TURI_SFRAME_sframe_rows_HPP 10 #include <core/data/flexible_type/flexible_type.hpp> 52 typedef std::shared_ptr<decoded_column_type> ptr_to_decoded_column_type;
64 m_decoded_columns = other.m_decoded_columns;
66 other.m_is_unique =
false;
78 m_decoded_columns = other.m_decoded_columns;
80 other.m_is_unique =
false;
91 return m_decoded_columns.size();
96 if (m_decoded_columns.empty())
return 0;
97 else if (m_decoded_columns[0] ==
nullptr)
return 0;
98 else return m_decoded_columns[0]->size();
132 return m_decoded_columns;
138 inline const std::vector<ptr_to_decoded_column_type>&
get_columns()
const {
139 return m_decoded_columns;
145 inline const std::vector<ptr_to_decoded_column_type>&
cget_columns()
const {
146 return m_decoded_columns;
180 inline row(
const row& other) =
default;
183 inline row(
row&& other) =
default;
186 inline row() =
default;
194 m_source = other.m_source;
195 m_current_row_number = other.m_current_row_number;
204 for (
size_t i = 0;i <
size(); ++i) {
205 (*this)[i] = other[i];
216 for (
size_t i = 0;i <
size(); ++i) {
217 (*this)[i] = std::move(other[i]);
223 m_source(source), m_current_row_number(current_row_number) { }
228 inline operator std::vector<flexible_type>()
const {
229 std::vector<flexible_type> ret(
size());
230 for (
size_t i = 0;i < ret.size(); ++i) ret[i] = (*
this)[i];
238 if (i <
size())
return (*
this)[i];
239 else throw "Index out of bounds";
246 if (i <
size())
return (*
this)[i];
247 else throw "Index out of bounds";
255 const auto& column = (*(m_source->m_decoded_columns[i]));
256 return column[m_current_row_number];
263 const auto& column = (*(m_source->m_decoded_columns[i]));
264 return column[m_current_row_number];
271 auto& column = (*(m_source->m_decoded_columns[i]));
272 return column[m_current_row_number];
283 ssize_t m_current_row_number = 0;
292 public boost::iterator_facade<const_iterator,
294 boost::random_access_traversal_tag> {
296 const row* m_source =
nullptr;
297 size_t m_current_idx = 0;
305 m_source(&source), m_current_idx(current_idx) { };
308 friend class boost::iterator_core_access;
310 inline void increment() {
314 inline void advance(
size_t n) {
320 return this->m_source == other.
m_source &&
321 this->m_current_idx == other.m_current_idx;
326 return m_source->
fast_at(m_current_idx);
331 return other.m_current_idx - m_current_idx;
355 public boost::iterator_facade<const_iterator,
357 boost::random_access_traversal_tag> {
382 m_row(source, current_row_number) { };
384 friend class boost::iterator_core_access;
386 inline void increment() {
387 ++m_row.m_current_row_number;
390 inline void advance(
size_t n) {
391 m_row.m_current_row_number += n;
396 return this->m_source == other.
m_source &&
397 m_row.m_current_row_number == other.m_row.m_current_row_number;
401 inline const row& dereference()
const {
407 return other.m_row.m_current_row_number - m_row.m_current_row_number;
415 public boost::iterator_facade<iterator,
417 boost::random_access_traversal_tag> {
428 m_source = std::move(other.
m_source);
437 m_source = std::move(other.
m_source);
442 m_row(source, current_row_number) { };
444 friend class boost::iterator_core_access;
446 inline void increment() {
447 ++m_row.m_current_row_number;
450 inline void advance(
size_t n) {
451 m_row.m_current_row_number += n;
455 inline bool equal(
const iterator& other)
const {
456 return this->m_source == other.
m_source &&
457 m_row.m_current_row_number == other.m_row.m_current_row_number;
461 inline row& dereference()
const {
466 const ssize_t distance_to(
const iterator& other)
const {
467 return other.m_row.m_current_row_number - m_row.m_current_row_number;
554 std::vector<ptr_to_decoded_column_type> m_decoded_columns;
555 mutable bool m_is_unique =
true;
const flexible_type & fast_at(size_t i) const
const_iterator end() const
size_t num_rows() const
Returns the number of rows.
sframe_rows & operator=(const sframe_rows &other)
const row * m_source
Pointer to the input range. NULL if end iterator.
row & operator=(const row &other)
const_iterator begin() const
void save(oarchive &oarc) const
sframe_rows(const sframe_rows &other)
The serialization input archive object which, provided with a reference to an istream, will read from the istream, providing deserialization capabilities.
size_t num_columns() const
Returns the number of columns.
const std::vector< ptr_to_decoded_column_type > & get_columns() const
void load(iarchive &oarc)
const std::vector< ptr_to_decoded_column_type > & cget_columns() const
const_iterator cbegin() const
const row operator[](size_t i) const
const flexible_type & operator[](size_t i) const
const_iterator begin() const
const_iterator cend() const
const_iterator(const sframe_rows::row &source, size_t current_idx=0)
default constructor
const sframe_rows * m_source
Pointer to the input range. NULL if end iterator.
std::vector< ptr_to_decoded_column_type > & get_columns()
const_iterator()
default constructor
iterator()
default constructor
sframe_rows type_check(const std::vector< flex_type_enum > &typelist) const
row & operator=(row &&other)
flexible_type & at(size_t i)
const sframe_rows * m_source
Pointer to the input range. NULL if end iterator.
flexible_type & operator[](size_t i)
void resize(size_t num_cols, ssize_t num_rows=-1)
const_iterator end() const
The serialization output archive object which, provided with a reference to an ostream, will write to the ostream, providing serialization capabilities.
std::vector< flexible_type > decoded_column_type
The data type of decoded column (block_contents::DECODED_COLUMN)
void add_decoded_column(const ptr_to_decoded_column_type &decoded_column)
void copy_reference(const row &other)
const flexible_type & at(size_t i) const
void type_check_inplace(const std::vector< flex_type_enum > &typelist)