Skip to content

Commit

Permalink
Style fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 committed May 24, 2018
1 parent bea2d81 commit 5b5e79e
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/data/simple_csr_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
#include <dmlc/base.h>
#include <xgboost/logging.h>
#include <limits>
#include "./simple_csr_source.h"

namespace xgboost {
Expand Down Expand Up @@ -32,10 +33,10 @@ void SimpleCSRSource::CopyFrom(DMatrix* src) {
}

void SimpleCSRSource::CopyFrom(dmlc::Parser<uint32_t>* parser) {
// use qid get gourp info
const uint64_t defaultMax = 0xFFFFFFFFFFFFFFFF;
uint64_t lastGroupId = defaultMax;
bst_uint groupSize = 0;
// use qid to get group info
const uint64_t default_max = std::numeric_limits<uint64_t>::max();
uint64_t last_group_id = default_max;
bst_uint group_size = 0;
this->Clear();
while (parser->Next()) {
const dmlc::RowBlock<uint32_t>& batch = parser->Value();
Expand All @@ -49,14 +50,14 @@ void SimpleCSRSource::CopyFrom(dmlc::Parser<uint32_t>* parser) {
info.qids_.insert(info.qids_.end(), batch.qid, batch.qid + batch.size);
// get group
for (size_t i = 0; i < batch.size; ++i) {
uint64_t curGroupId = batch.qid[i];
if (lastGroupId == defaultMax) {
const uint64_t cur_group_id = batch.qid[i];
if (last_group_id == default_max) {
info.group_ptr_.push_back(0);
} else if (lastGroupId != curGroupId) {
info.group_ptr_.push_back(groupSize);
} else if (last_group_id != cur_group_id) {
info.group_ptr_.push_back(group_size);
}
lastGroupId = curGroupId;
groupSize++;
last_group_id = cur_group_id;
group_size++;
}
}

Expand All @@ -81,9 +82,9 @@ void SimpleCSRSource::CopyFrom(dmlc::Parser<uint32_t>* parser) {
row_ptr_.push_back(row_ptr_[top - 1] + batch.offset[i + 1] - batch.offset[0]);
}
}
if (lastGroupId != defaultMax) {
if (groupSize > info.group_ptr_.back()) {
info.group_ptr_.push_back(groupSize);
if (last_group_id != default_max) {
if (group_size > info.group_ptr_.back()) {
info.group_ptr_.push_back(group_size);
}
}
this->info.num_nonzero_ = static_cast<uint64_t>(row_data_.size());
Expand Down

0 comments on commit 5b5e79e

Please sign in to comment.