add a test for cpu predictor using external memory (#4308)

* add a test for cpu predictor using external memory

* allow different page size for testing
This commit is contained in:
Rong Ou
2019-04-09 18:25:10 -07:00
committed by Rory Mitchell
parent b72eab3e07
commit 81c1cd40ca
7 changed files with 95 additions and 20 deletions

View File

@@ -29,16 +29,19 @@ TEST(SparsePageDMatrix, RowAccess) {
// Create sufficiently large data to make two row pages
dmlc::TemporaryDirectory tempdir;
const std::string tmp_file = tempdir.path + "/big.libsvm";
CreateBigTestData(tmp_file, 5000000);
CreateBigTestData(tmp_file, 12);
xgboost::DMatrix * dmat = xgboost::DMatrix::Load(
tmp_file + "#" + tmp_file + ".cache", true, false);
tmp_file + "#" + tmp_file + ".cache", true, false, "auto", 64UL);
EXPECT_TRUE(FileExists(tmp_file + ".cache.row.page"));
// Loop over the batches and count the records
int64_t batch_count = 0;
int64_t row_count = 0;
for (auto &batch : dmat->GetRowBatches()) {
for (const auto &batch : dmat->GetRowBatches()) {
batch_count++;
row_count += batch.Size();
}
EXPECT_EQ(batch_count, 2);
EXPECT_EQ(row_count, dmat->Info().num_row_);
// Test the data read into the first row