Skip to content

Commit

Permalink
Merge pull request #685 from jubatus/fix-684
Browse files Browse the repository at this point in the history
fix bit_index_storage to erase rows with empty vector on MIX
  • Loading branch information
hido committed Mar 23, 2014
2 parents 9ef3b6d + bcaf05a commit 5f4029d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
6 changes: 5 additions & 1 deletion jubatus/core/storage/bit_index_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ bool bit_index_storage::set_mixed_and_clear_diff(
const bit_table_t& mixed_diff) {
for (bit_table_t::const_iterator it = mixed_diff.begin();
it != mixed_diff.end(); ++it) {
bitvals_[it->first] = it->second;
if (it->second.bit_num() == 0) {
bitvals_.erase(it->first);
} else {
bitvals_[it->first] = it->second;
}
}
bitvals_diff_.clear();
return true;
Expand Down
19 changes: 19 additions & 0 deletions jubatus/core/storage/bit_index_storage_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,25 @@ TEST(bit_index_storage, mix) {
EXPECT_TRUE(v == make_vector("1100"));
s3.get_row("r4", v);
EXPECT_TRUE(v == bit_vector());

vector<string> ids;

s3.get_all_row_ids(ids);
EXPECT_EQ(3u, ids.size());

s3.remove_row("r3");

// Once MIXed, remove_row does not take affect until next MIX.
s3.get_all_row_ids(ids);
EXPECT_EQ(3u, ids.size());

// do MIX
bit_table_t d3;
s3.get_diff(d3);
s3.set_mixed_and_clear_diff(d3);

s3.get_all_row_ids(ids);
EXPECT_EQ(2u, ids.size());
}

} // namespace storage
Expand Down

0 comments on commit 5f4029d

Please sign in to comment.