Sort sparse page index when constructing DMatrix. (#7731)

This commit is contained in:
Jiaming Yuan
2022-03-16 18:01:05 +08:00
committed by GitHub
parent 613ec36c5a
commit e78a38b837
4 changed files with 67 additions and 1 deletions

View File

@@ -201,6 +201,9 @@ struct Entry {
inline static bool CmpValue(const Entry& a, const Entry& b) {
return a.fvalue < b.fvalue;
}
static bool CmpIndex(Entry const& a, Entry const& b) {
return a.index < b.index;
}
inline bool operator==(const Entry& other) const {
return (this->index == other.index && this->fvalue == other.fvalue);
}
@@ -313,6 +316,15 @@ class SparsePage {
SparsePage GetTranspose(int num_columns, int32_t n_threads) const;
/**
* \brief Sort the column index.
*/
void SortIndices(int32_t n_threads);
/**
* \brief Check wether the column index is sorted.
*/
bool IsIndicesSorted(int32_t n_threads) const;
void SortRows(int32_t n_threads);
/**