susumu.yata
null+****@clear*****
Tue Apr 23 09:50:44 JST 2013
susumu.yata 2013-04-23 09:50:44 +0900 (Tue, 23 Apr 2013) New Revision: d40e550d05240e722b4a131059a7808db023e1e5 https://github.com/groonga/grnxx/commit/d40e550d05240e722b4a131059a7808db023e1e5 Message: Fix a bug of BitwiseCompletionCursor. Modified files: lib/grnxx/alpha/map/double_array.cpp test/test_alpha_map.cpp Modified: lib/grnxx/alpha/map/double_array.cpp (+6 -6) =================================================================== --- lib/grnxx/alpha/map/double_array.cpp 2013-04-22 21:40:59 +0900 (cd9de63) +++ lib/grnxx/alpha/map/double_array.cpp 2013-04-23 09:50:44 +0900 (ea7e7ce) @@ -958,8 +958,8 @@ DoubleArrayBitwiseCompletionCursor::DoubleArrayBitwiseCompletionCursor( : MapCursor<GeoPoint>(), double_array_(double_array), cur_(), count_(0), query_(query), bit_size_(bit_size), mask_(), options_(options), node_ids_(), keys_() { - if ((~options_.flags & MAP_CURSOR_ORDER_BY_ID) || - (options_.flags & MAP_CURSOR_ORDER_BY_KEY)) { + if ((options_.flags & MAP_CURSOR_ORDER_BY_ID) && + (~options_.flags & MAP_CURSOR_ORDER_BY_KEY)) { init_order_by_id(); } else { init_order_by_key(); @@ -1001,7 +1001,7 @@ void DoubleArrayBitwiseCompletionCursor::init_order_by_id() { if (node.is_leaf()) { const GeoPoint key = double_array_->keys_[node.key_id()]; - if (((key.value() ^ query_.value()) & mask_) != 0) { + if (((key.value() ^ query_.value()) & mask_) == 0) { keys_.push_back(std::make_pair(node.key_id(), key)); } } else if (node.child() != INVALID_LABEL) { @@ -1052,7 +1052,7 @@ void DoubleArrayBitwiseCompletionCursor::init_order_by_key() { const DoubleArrayNodeForOthers node = double_array_->nodes_[node_id]; if (node.is_leaf()) { const GeoPoint key = double_array_->keys_[node.key_id()]; - if (((key.value() ^ query_.value()) ^ mask_) != 0) { + if (((key.value() ^ query_.value()) & mask_) == 0) { if (~options_.flags & MAP_CURSOR_REVERSE_ORDER) { node_id |= IS_ROOT_FLAG; } @@ -1097,7 +1097,7 @@ bool DoubleArrayBitwiseCompletionCursor::next_order_by_key() { if (node.is_leaf()) { const GeoPoint key = double_array_->keys_[node.key_id()]; - if (((key.value() ^ query_.value()) ^ mask_) != 0) { + if (((key.value() ^ query_.value()) & mask_) == 0) { if (options_.offset > 0) { --options_.offset; } else { @@ -1124,7 +1124,7 @@ bool DoubleArrayBitwiseCompletionCursor::next_reverse_order_by_key() { node_ids_.pop_back(); if (node.is_leaf()) { const GeoPoint key = double_array_->keys_[node.key_id()]; - if (((key.value() ^ query_.value()) ^ mask_) != 0) { + if (((key.value() ^ query_.value()) & mask_) == 0) { if (options_.offset > 0) { --options_.offset; } else { Modified: test/test_alpha_map.cpp (+1 -1) =================================================================== --- test/test_alpha_map.cpp 2013-04-22 21:40:59 +0900 (f6edf23) +++ test/test_alpha_map.cpp 2013-04-23 09:50:44 +0900 (b3e47c6) @@ -555,7 +555,7 @@ int main() { test_map_nan(grnxx::alpha::MAP_DOUBLE_ARRAY); test_map_zero(grnxx::alpha::MAP_DOUBLE_ARRAY); -// test_bitwise_completion_cursor(grnxx::alpha::MAP_DOUBLE_ARRAY); + test_bitwise_completion_cursor(grnxx::alpha::MAP_DOUBLE_ARRAY); return 0; } -------------- next part -------------- HTML����������������������������...Download