Browse Source

!1744 Fix Codex

Merge pull request !1744 from JesseKLee/btree_fix
tags/v0.5.0-beta
mindspore-ci-bot Gitee 5 years ago
parent
commit
05177ff91a
2 changed files with 10 additions and 4 deletions
  1. +4
    -4
      mindspore/ccsrc/dataset/util/btree.h
  2. +6
    -0
      mindspore/ccsrc/dataset/util/btree_impl.tpp

+ 4
- 4
mindspore/ccsrc/dataset/util/btree.h View File

@@ -252,8 +252,8 @@ class BPlusTree {


~InnerNode() = default; ~InnerNode() = default;


slot_type slot_dir_[traits::kInnerSlots];
key_type keys_[traits::kInnerSlots];
slot_type slot_dir_[traits::kInnerSlots] = {0};
key_type keys_[traits::kInnerSlots] = {0};
BaseNode *data_[traits::kInnerSlots + 1] = {nullptr}; BaseNode *data_[traits::kInnerSlots + 1] = {nullptr};
uint64_t num_keys_[traits::kInnerSlots + 1] = {0}; uint64_t num_keys_[traits::kInnerSlots + 1] = {0};
slot_type slotuse_; slot_type slotuse_;
@@ -282,8 +282,8 @@ class BPlusTree {


~LeafNode() = default; ~LeafNode() = default;


slot_type slot_dir_[traits::kLeafSlots];
key_type keys_[traits::kLeafSlots];
slot_type slot_dir_[traits::kLeafSlots] = {0};
key_type keys_[traits::kLeafSlots] = {0};
std::unique_ptr<value_type> data_[traits::kLeafSlots]; std::unique_ptr<value_type> data_[traits::kLeafSlots];
slot_type slotuse_; slot_type slotuse_;
}; };


+ 6
- 0
mindspore/ccsrc/dataset/util/btree_impl.tpp View File

@@ -42,6 +42,9 @@ typename BPlusTree<K, V, A, C, T>::IndexRc BPlusTree<K, V, A, C, T>::InnerNode::
// Swap the key // Swap the key
std::swap(keys_[j], keys_[i]); std::swap(keys_[j], keys_[i]);
// Swap the pointers. // Swap the pointers.
if ((j + 1) >= traits::kInnerSlots + 1 || (i + 1) >= traits::kInnerSlots + 1) {
return IndexRc::kUnexpectedError;
}
std::swap(data_[j + 1], data_[i + 1]); std::swap(data_[j + 1], data_[i + 1]);
// one key in order. // one key in order.
inverse[j] = j; inverse[j] = j;
@@ -131,6 +134,9 @@ typename BPlusTree<K, V, A, C, T>::IndexRc BPlusTree<K, V, A, C, T>::LeafNode::S
slot_type j = inverse[i]; slot_type j = inverse[i];
slot_type k = inverse[j]; slot_type k = inverse[j];
// Swap the key // Swap the key
if (j >= traits::kLeafSlots || i >= traits::kLeafSlots) {
return IndexRc::kUnexpectedError;
}
std::swap(keys_[j], keys_[i]); std::swap(keys_[j], keys_[i]);
// Swap the shared pointers // Swap the shared pointers
std::swap(data_[j], data_[i]); std::swap(data_[j], data_[i]);


Loading…
Cancel
Save