Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nautaa committed Feb 20, 2025
1 parent 94657eb commit dff1790
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 29 deletions.
6 changes: 3 additions & 3 deletions src/cpplings/cas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details. */

// CAS (Compare And Swap) 操作通常通过 `std::atomic` 类型的成员函数 `compare_exchange_weak()`
// CAS (Compare And Swap) 操作通常通过 `std::atomic` 类型的成员函数 `compare_exchange_weak()`
// 或 `compare_exchange_strong()` 函数来实现。
// `compare_exchange_strong()` 的基本语义是比较一个原子变量的当前值与预期值,如果相等,则将其更新为新值。
// 如果不相等,则将原子变量的当前值赋值给预期值。这个操作是原子的,保证了线程安全。
Expand All @@ -26,14 +26,14 @@ struct Node
Node *next;
};

Node * list_head(nullptr);
Node *list_head(nullptr);

// 向 `list_head` 中添加一个值为 `val` 的 Node 节点。
void append_node(int val)
{
Node *old_head = list_head;
Node *new_node = new Node{val, old_head};

// TODO: 使用 compare_exchange_strong 来使这段代码线程安全。
list_head = new_node;
}
Expand Down
3 changes: 1 addition & 2 deletions src/cpplings/lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ struct Node
Node *next;
};


Node * list_head(nullptr);
Node *list_head(nullptr);

// 向 `list_head` 中添加一个 value 为 `val` 的 Node 节点。
void append_node(int val)
Expand Down
1 change: 0 additions & 1 deletion src/cpplings/mutex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ struct Node
Node *next;
};


std::atomic<Node *> list_head(nullptr);

// 向 `list_head` 中添加一个 value 为 `val` 的 Node 节点。
Expand Down
3 changes: 2 additions & 1 deletion src/cpplings/smart_pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ See the Mulan PSL v2 for more details. */
class Foo
{
public:
Foo() {
Foo()
{
// TODO: 添加必要的日志信息,观察函数何时调用。
}

Expand Down
28 changes: 10 additions & 18 deletions src/oblsm/util/ob_bloomfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ObBloomfilter
public:
/**
* @brief Constructs a Bloom filter with specified parameters.
*
*
* @param hash_func_count Number of hash functions to use. Default is 4.
* @param totoal_bits Total number of bits in the Bloom filter. Default is 65536.
*/
Expand All @@ -33,43 +33,35 @@ class ObBloomfilter
* @details This method computes hash values for the given object and sets corresponding bits in the filter.
* @param object The object to be inserted.
*/
void insert(const string &object)
{
}
void insert(const string &object) {}

/**
* @brief Clears all entries in the Bloom filter.
*
*
* @details Resets the filter, removing all previously inserted objects.
*/
void clear()
{
}

void clear() {}

/**
* @brief Checks if an object is possibly in the Bloom filter.
*
*
* @param object The object to be checked.
* @return true if the object might be in the filter, false if definitely not.
*/
bool contains(const string &object) const
{
return false;
}

/**
bool contains(const string &object) const { return false; }

/**
* @brief Returns the count of objects inserted into the Bloom filter.
*/
size_t object_count() const { return object_count_; }

/**
* @brief Checks if the Bloom filter is empty.
* @return true if the filter is empty, false otherwise.
*/
bool empty() const { return 0 == object_count(); }

private:

/// the count of objects inserted into the Bloom filter
size_t object_count_;
};
Expand Down
4 changes: 3 additions & 1 deletion unittest/oblsm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
FILE(GLOB_RECURSE ALL_SRC *.cpp)

FIND_PACKAGE(jsoncpp CONFIG REQUIRED)

FOREACH (F ${ALL_SRC})
get_filename_component(prjName ${F} NAME_WE)
MESSAGE("Build ${prjName} according to ${F}")
ADD_EXECUTABLE(${prjName} ${F})
TARGET_LINK_LIBRARIES(${prjName} pthread GTest::gtest_main jsoncpp oblsm)
TARGET_LINK_LIBRARIES(${prjName} pthread GTest::gtest_main JsonCpp::JsonCpp oblsm)
add_test(NAME ${prjName} COMMAND ${prjName})
ENDFOREACH (F)
4 changes: 1 addition & 3 deletions unittest/observer/mvcc_trx_log_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,7 @@ TEST(MvccTrxLog, wal_rollback_abnormal)
visible_count++;
}
}
if (visible_count != insert_num / 2) {
system("find . -name \"mvcc_trx_log_test.log*\" -exec cat {} +");
}

ASSERT_EQ(visible_count, insert_num / 2);
}
db2->trx_kit().destroy_trx(trx);
Expand Down

0 comments on commit dff1790

Please sign in to comment.