Create from data iterator
| 327 | |
| 328 | // Create from data iterator |
| 329 | XGB_DLL int XGDMatrixCreateFromCallback(DataIterHandle iter, DMatrixHandle proxy, |
| 330 | DataIterResetCallback *reset, XGDMatrixCallbackNext *next, |
| 331 | char const *config, DMatrixHandle *out) { |
| 332 | API_BEGIN(); |
| 333 | xgboost_CHECK_C_ARG_PTR(config); |
| 334 | |
| 335 | auto jconfig = Json::Load(StringView{config}); |
| 336 | auto missing = GetMissing(jconfig); |
| 337 | std::string cache = RequiredArg<String>(jconfig, "cache_prefix", __func__); |
| 338 | std::int32_t n_threads = OptionalArg<Integer, std::int64_t>(jconfig, "nthread", 0); |
| 339 | auto on_host = OptionalArg<Boolean>(jconfig, "on_host", false); |
| 340 | auto min_cache_page_bytes = OptionalArg<Integer, std::int64_t>(jconfig, "min_cache_page_bytes", |
| 341 | cuda_impl::MatchingPageBytes()); |
| 342 | CHECK_EQ(min_cache_page_bytes, cuda_impl::MatchingPageBytes()) |
| 343 | << "Page concatenation is not supported by the DMatrix yet."; |
| 344 | auto cache_host_ratio = |
| 345 | OptionalArg<Number, float>(jconfig, "cache_host_ratio", cuda_impl::AutoHostRatio()); |
| 346 | |
| 347 | xgboost_CHECK_C_ARG_PTR(next); |
| 348 | xgboost_CHECK_C_ARG_PTR(reset); |
| 349 | xgboost_CHECK_C_ARG_PTR(out); |
| 350 | |
| 351 | auto config = |
| 352 | ExtMemConfig{cache, on_host, cache_host_ratio, min_cache_page_bytes, missing, n_threads}; |
| 353 | *out = new std::shared_ptr<xgboost::DMatrix>{ |
| 354 | xgboost::DMatrix::Create(iter, proxy, reset, next, config)}; |
| 355 | API_END(); |
| 356 | } |
| 357 | |
| 358 | namespace { |
| 359 | std::shared_ptr<DMatrix> GetRefDMatrix(DataIterHandle ref) { |