1 /*!
2  * Copyright 2019-2021 by XGBoost Contributors
3  */
4 
5 #ifndef XGBOOST_DATA_ELLPACK_PAGE_SOURCE_H_
6 #define XGBOOST_DATA_ELLPACK_PAGE_SOURCE_H_
7 
8 #include <xgboost/data.h>
9 #include <memory>
10 #include <string>
11 #include <utility>
12 
13 #include "../common/common.h"
14 #include "../common/hist_util.h"
15 #include "sparse_page_source.h"
16 
17 namespace xgboost {
18 namespace data {
19 
20 class EllpackPageSource : public PageSourceIncMixIn<EllpackPage> {
21   bool is_dense_;
22   size_t row_stride_;
23   BatchParam param_;
24   common::Span<FeatureType const> feature_types_;
25   std::unique_ptr<common::HistogramCuts> cuts_;
26 
27  public:
EllpackPageSource(float missing,int nthreads,bst_feature_t n_features,size_t n_batches,std::shared_ptr<Cache> cache,BatchParam param,std::unique_ptr<common::HistogramCuts> cuts,bool is_dense,size_t row_stride,common::Span<FeatureType const> feature_types,std::shared_ptr<SparsePageSource> source)28   EllpackPageSource(
29       float missing, int nthreads, bst_feature_t n_features, size_t n_batches,
30       std::shared_ptr<Cache> cache, BatchParam param,
31       std::unique_ptr<common::HistogramCuts> cuts, bool is_dense,
32       size_t row_stride, common::Span<FeatureType const> feature_types,
33       std::shared_ptr<SparsePageSource> source)
34       : PageSourceIncMixIn(missing, nthreads, n_features, n_batches, cache),
35         is_dense_{is_dense}, row_stride_{row_stride}, param_{std::move(param)},
36         feature_types_{feature_types}, cuts_{std::move(cuts)} {
37     this->source_ = source;
38     this->Fetch();
39   }
40 
41   void Fetch() final;
42 };
43 
44 #if !defined(XGBOOST_USE_CUDA)
Fetch()45 inline void EllpackPageSource::Fetch() {
46   common::AssertGPUSupport();
47 }
48 #endif  // !defined(XGBOOST_USE_CUDA)
49 }  // namespace data
50 }  // namespace xgboost
51 
52 #endif  // XGBOOST_DATA_ELLPACK_PAGE_SOURCE_H_
53