From b674e47786ea1710b945c2115fac0cf82ba90604 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 24 Sep 2021 15:20:59 +0800 Subject: [PATCH] add lru module --- include/libs/lru/lru.h | 27 +++++++++++++++++++++++++++ source/libs/CMakeLists.txt | 3 ++- source/libs/lru/CMakeLists.txt | 7 +++++++ source/libs/lru/inc/lruInt.h | 27 +++++++++++++++++++++++++++ source/libs/lru/src/lru.c | 14 ++++++++++++++ source/libs/lru/test/lruTests.cpp | 0 6 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 include/libs/lru/lru.h create mode 100644 source/libs/lru/CMakeLists.txt create mode 100644 source/libs/lru/inc/lruInt.h create mode 100644 source/libs/lru/src/lru.c create mode 100644 source/libs/lru/test/lruTests.cpp diff --git a/include/libs/lru/lru.h b/include/libs/lru/lru.h new file mode 100644 index 0000000000..c82e8ed746 --- /dev/null +++ b/include/libs/lru/lru.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_LRU_H_ +#define _TD_LRU_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_LRU_H_*/ \ No newline at end of file diff --git a/source/libs/CMakeLists.txt b/source/libs/CMakeLists.txt index ed6d2bef4f..c1bec69cd2 100644 --- a/source/libs/CMakeLists.txt +++ b/source/libs/CMakeLists.txt @@ -4,4 +4,5 @@ add_subdirectory(tkv) add_subdirectory(index) add_subdirectory(wal) add_subdirectory(parser) -add_subdirectory(scheduler) \ No newline at end of file +add_subdirectory(scheduler) +add_subdirectory(lru) \ No newline at end of file diff --git a/source/libs/lru/CMakeLists.txt b/source/libs/lru/CMakeLists.txt new file mode 100644 index 0000000000..b65615dbbf --- /dev/null +++ b/source/libs/lru/CMakeLists.txt @@ -0,0 +1,7 @@ +aux_source_directory(src LRU_SRC) +add_library(lru ${LRU_SRC}) +target_include_directories( + lru + PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/lru" + PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" +) \ No newline at end of file diff --git a/source/libs/lru/inc/lruInt.h b/source/libs/lru/inc/lruInt.h new file mode 100644 index 0000000000..e0da680104 --- /dev/null +++ b/source/libs/lru/inc/lruInt.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_LRU_INT_H_ +#define _TD_LRU_INT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_LRU_INT_H_*/ \ No newline at end of file diff --git a/source/libs/lru/src/lru.c b/source/libs/lru/src/lru.c new file mode 100644 index 0000000000..6dea4a4e57 --- /dev/null +++ b/source/libs/lru/src/lru.c @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ \ No newline at end of file diff --git a/source/libs/lru/test/lruTests.cpp b/source/libs/lru/test/lruTests.cpp new file mode 100644 index 0000000000..e69de29bb2