lack include
This commit is contained in:
parent
9da2ced8a2
commit
0b36c8295d
37
src/data.h
37
src/data.h
@ -9,6 +9,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
#include <cstring>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "utils/io.h"
|
#include "utils/io.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
@ -16,9 +17,9 @@
|
|||||||
#include "utils/matrix_csr.h"
|
#include "utils/matrix_csr.h"
|
||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
/*!
|
/*!
|
||||||
* \brief unsigned interger type used in boost,
|
* \brief unsigned interger type used in boost,
|
||||||
* used for feature index and row index
|
* used for feature index and row index
|
||||||
*/
|
*/
|
||||||
typedef unsigned bst_uint;
|
typedef unsigned bst_uint;
|
||||||
/*! \brief float type, used for storing statistics */
|
/*! \brief float type, used for storing statistics */
|
||||||
@ -82,7 +83,7 @@ struct SparseBatch {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief This is a interface convention via template, defining the way to access features,
|
* \brief This is a interface convention via template, defining the way to access features,
|
||||||
* column access rule is defined by template, for efficiency purpose,
|
* column access rule is defined by template, for efficiency purpose,
|
||||||
* row access is defined by iterator of sparse batches
|
* row access is defined by iterator of sparse batches
|
||||||
* \tparam Derived type of actual implementation
|
* \tparam Derived type of actual implementation
|
||||||
*/
|
*/
|
||||||
@ -122,9 +123,9 @@ class FMatrixInterface {
|
|||||||
* \return number of columns
|
* \return number of columns
|
||||||
*/
|
*/
|
||||||
inline size_t NumCol(void) const;
|
inline size_t NumCol(void) const;
|
||||||
/*!
|
/*!
|
||||||
* \brief check if column access is supported, if not, initialize column access
|
* \brief check if column access is supported, if not, initialize column access
|
||||||
* \param max_rows maximum number of rows allowed in constructor
|
* \param max_rows maximum number of rows allowed in constructor
|
||||||
*/
|
*/
|
||||||
inline void InitColAccess(void);
|
inline void InitColAccess(void);
|
||||||
/*! \return whether column access is enabled */
|
/*! \return whether column access is enabled */
|
||||||
@ -133,8 +134,8 @@ class FMatrixInterface {
|
|||||||
inline size_t GetColSize(size_t cidx) const;
|
inline size_t GetColSize(size_t cidx) const;
|
||||||
/*!
|
/*!
|
||||||
* \breif return #entries-in-col / #rows
|
* \breif return #entries-in-col / #rows
|
||||||
* \param cidx column index
|
* \param cidx column index
|
||||||
* this function is used to help speedup,
|
* this function is used to help speedup,
|
||||||
* doese not necessarily implement it if not sure, return 0.0;
|
* doese not necessarily implement it if not sure, return 0.0;
|
||||||
* \return column density
|
* \return column density
|
||||||
*/
|
*/
|
||||||
@ -204,9 +205,9 @@ class FMatrixS : public FMatrixInterface<FMatrixS>{
|
|||||||
return ColIter(&col_data_[col_ptr_[cidx]] - 1,
|
return ColIter(&col_data_[col_ptr_[cidx]] - 1,
|
||||||
&col_data_[col_ptr_[cidx + 1]] - 1);
|
&col_data_[col_ptr_[cidx + 1]] - 1);
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
* \brief get reversed col iterator,
|
* \brief get reversed col iterator,
|
||||||
* this function will be deprecated at some point
|
* this function will be deprecated at some point
|
||||||
*/
|
*/
|
||||||
inline ColBackIter GetReverseSortedCol(size_t cidx) const {
|
inline ColBackIter GetReverseSortedCol(size_t cidx) const {
|
||||||
utils::Assert(cidx < this->NumCol(), "col id exceed bound");
|
utils::Assert(cidx < this->NumCol(), "col id exceed bound");
|
||||||
@ -226,8 +227,8 @@ class FMatrixS : public FMatrixInterface<FMatrixS>{
|
|||||||
if (this->HaveColAccess()) return;
|
if (this->HaveColAccess()) return;
|
||||||
this->InitColData(max_nrow);
|
this->InitColData(max_nrow);
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
* \brief get the row iterator associated with FMatrix
|
* \brief get the row iterator associated with FMatrix
|
||||||
* this function is not threadsafe, returns iterator stored in FMatrixS
|
* this function is not threadsafe, returns iterator stored in FMatrixS
|
||||||
*/
|
*/
|
||||||
inline utils::IIterator<SparseBatch>* RowIterator(void) const {
|
inline utils::IIterator<SparseBatch>* RowIterator(void) const {
|
||||||
@ -287,19 +288,19 @@ class FMatrixS : public FMatrixInterface<FMatrixS>{
|
|||||||
size_t nrow;
|
size_t nrow;
|
||||||
utils::Check(fi.Read(&nrow, sizeof(size_t)) != 0, "invalid input file format");
|
utils::Check(fi.Read(&nrow, sizeof(size_t)) != 0, "invalid input file format");
|
||||||
out_ptr->resize(nrow + 1);
|
out_ptr->resize(nrow + 1);
|
||||||
utils::Check(fi.Read(&(*out_ptr)[0], out_ptr->size() * sizeof(size_t)) != 0,
|
utils::Check(fi.Read(&(*out_ptr)[0], out_ptr->size() * sizeof(size_t)) != 0,
|
||||||
"invalid input file format");
|
"invalid input file format");
|
||||||
out_data->resize(out_ptr->back());
|
out_data->resize(out_ptr->back());
|
||||||
if (out_data->size() != 0) {
|
if (out_data->size() != 0) {
|
||||||
utils::Assert(fi.Read(&(*out_data)[0], out_data->size() * sizeof(SparseBatch::Entry)) != 0,
|
utils::Assert(fi.Read(&(*out_data)[0], out_data->size() * sizeof(SparseBatch::Entry)) != 0,
|
||||||
"invalid input file format");
|
"invalid input file format");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*!
|
/*!
|
||||||
* \brief intialize column data
|
* \brief intialize column data
|
||||||
* \param max_nrow maximum number of rows supported
|
* \param max_nrow maximum number of rows supported
|
||||||
*/
|
*/
|
||||||
inline void InitColData(size_t max_nrow) {
|
inline void InitColData(size_t max_nrow) {
|
||||||
// note: this part of code is serial, todo, parallelize this transformer
|
// note: this part of code is serial, todo, parallelize this transformer
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user