Refactor for GHistIndex. (#7923)
* Pass sparse page as adapter, which prepares for quantile dmatrix. * Remove old external memory code like `rbegin` and extra `Init` function. * Simplify type dispatch.
This commit is contained in:
@@ -125,26 +125,25 @@ class HistogramCuts {
|
||||
/**
|
||||
* \brief Search the bin index for numerical feature.
|
||||
*/
|
||||
bst_bin_t SearchBin(Entry const& e) const {
|
||||
return SearchBin(e.fvalue, e.index);
|
||||
}
|
||||
bst_bin_t SearchBin(Entry const& e) const { return SearchBin(e.fvalue, e.index); }
|
||||
|
||||
/**
|
||||
* \brief Search the bin index for categorical feature.
|
||||
*/
|
||||
bst_bin_t SearchCatBin(Entry const &e) const {
|
||||
bst_bin_t SearchCatBin(float value, bst_feature_t fidx) const {
|
||||
auto const &ptrs = this->Ptrs();
|
||||
auto const &vals = this->Values();
|
||||
auto end = ptrs.at(e.index + 1) + vals.cbegin();
|
||||
auto beg = ptrs[e.index] + vals.cbegin();
|
||||
auto end = ptrs.at(fidx + 1) + vals.cbegin();
|
||||
auto beg = ptrs[fidx] + vals.cbegin();
|
||||
// Truncates the value in case it's not perfectly rounded.
|
||||
auto v = static_cast<float>(common::AsCat(e.fvalue));
|
||||
auto v = static_cast<float>(common::AsCat(value));
|
||||
auto bin_idx = std::lower_bound(beg, end, v) - vals.cbegin();
|
||||
if (bin_idx == ptrs.at(e.index + 1)) {
|
||||
if (bin_idx == ptrs.at(fidx + 1)) {
|
||||
bin_idx -= 1;
|
||||
}
|
||||
return bin_idx;
|
||||
}
|
||||
bst_bin_t SearchCatBin(Entry const& e) const { return SearchCatBin(e.fvalue, e.index); }
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user