6 #ifndef TURI_ML_DATA_ROW_REFERENCE_H_ 7 #define TURI_ML_DATA_ROW_REFERENCE_H_ 9 #include <core/logging/assertions.hpp> 10 #include <toolkits/ml_data_2/data_storage/ml_data_row_translation.hpp> 11 #include <toolkits/ml_data_2/data_storage/ml_data_block_manager.hpp> 12 #include <toolkits/ml_data_2/ml_data.hpp> 13 #include <toolkits/ml_data_2/side_features.hpp> 14 #include <core/util/code_optimization.hpp> 16 #include <Eigen/SparseCore> 21 namespace turi {
namespace v2 {
23 typedef Eigen::Matrix<double, Eigen::Dynamic,1> DenseVector;
24 typedef Eigen::SparseVector<double> SparseVector;
107 template <
typename Entry>
109 inline void fill(std::vector<Entry>& x)
const {
113 if(!data_block->metadata->has_translated_columns())
116 ml_data_internal::copy_raw_into_ml_data_entry_row(
117 x, data_block->rm, current_data_iter(),
128 if(!data_block->metadata->has_untranslated_columns()) {
133 x.resize(data_block->untranslated_columns.size());
135 for(
size_t i = 0; i < data_block->untranslated_columns.size(); ++i) {
136 x[i] = data_block->untranslated_columns[i][current_in_block_index];
180 if(!data_block->metadata->has_translated_columns())
183 ml_data_internal::copy_raw_into_eigen_array(
185 data_block->rm, current_data_iter(),
187 use_reference_encoding);
226 if(!data_block->metadata->has_translated_columns())
229 ml_data_internal::copy_raw_into_eigen_array(
231 data_block->rm, current_data_iter(),
233 use_reference_encoding);
256 template <
typename DenseRowXpr>
262 ml_data_internal::copy_raw_into_eigen_array(
264 data_block->rm, current_data_iter(),
266 use_reference_encoding);
274 return get_target_value(data_block->rm, current_data_iter());
281 return get_target_index(data_block->rm, current_data_iter());
287 const std::shared_ptr<ml_metadata>&
metadata()
const {
288 return data_block->metadata;
295 std::shared_ptr<ml_data_internal::ml_data_block> data_block;
296 std::shared_ptr<ml_data_side_features> side_features;
297 size_t current_in_block_index = size_t(-1);
298 bool use_reference_encoding =
false;
304 DASSERT_LT(current_in_block_index, data_block->translated_rows.entry_data.size());
306 return &(data_block->translated_rows.entry_data[current_in_block_index]);
const std::shared_ptr< ml_metadata > & metadata() const
void fill(SparseVector &x) const GL_HOT_INLINE_FLATTEN
double target_value() const GL_HOT_INLINE_FLATTEN
GL_HOT_INLINE_FLATTEN void fill_eigen_row(DenseRowXpr &&x) const
size_t target_index() const GL_HOT_INLINE_FLATTEN
GL_HOT_INLINE void fill(std::vector< Entry > &x) const
#define GL_HOT_INLINE_FLATTEN
void fill_untranslated_values(std::vector< flexible_type > &x) const GL_HOT_INLINE_FLATTEN
#define DASSERT_TRUE(cond)
void fill(DenseVector &x) const GL_HOT_INLINE_FLATTEN