Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d4cd3836
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1191
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d4cd3836
编写于
10月 21, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add lucene
上级
8be1a251
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
195 addition
and
16 deletion
+195
-16
cmake/cmake.options
cmake/cmake.options
+3
-3
cmake/lucene_CMakeLists.txt.in
cmake/lucene_CMakeLists.txt.in
+2
-3
deps/CMakeLists.txt
deps/CMakeLists.txt
+5
-0
include/libs/index/index.h
include/libs/index/index.h
+61
-1
source/libs/index/CMakeLists.txt
source/libs/index/CMakeLists.txt
+24
-1
source/libs/index/inc/indexInt.h
source/libs/index/inc/indexInt.h
+20
-1
source/libs/index/src/index.c
source/libs/index/src/index.c
+62
-6
source/libs/index/test/indexTests.cpp
source/libs/index/test/indexTests.cpp
+15
-0
source/libs/tkv/src/tkv.c
source/libs/tkv/src/tkv.c
+3
-1
未找到文件。
cmake/cmake.options
浏览文件 @
d4cd3836
...
@@ -16,17 +16,17 @@ option(
...
@@ -16,17 +16,17 @@ option(
option(
option(
BUILD_WITH_ROCKSDB
BUILD_WITH_ROCKSDB
"If build with rocksdb"
"If build with rocksdb"
OF
F
OF
)
)
option(
option(
BUILD_WITH_LUCENE
BUILD_WITH_LUCENE
"If build with lucene"
"If build with lucene"
OFF
on
)
)
option(
option(
BUILD_DEPENDENCY_TESTS
BUILD_DEPENDENCY_TESTS
"If build dependency tests"
"If build dependency tests"
OFF
OFF
)
)
\ No newline at end of file
cmake/lucene_CMakeLists.txt.in
浏览文件 @
d4cd3836
# lucene
# lucene
ExternalProject_Add(lucene
ExternalProject_Add(lucene
GIT_REPOSITORY https://github.com/taosdata-contrib/LucenePlusPlus.git
GIT_REPOSITORY https://github.com/yihaoDeng/LucenePlusPlus.git
GIT_TAG rel_3.0.8
SOURCE_DIR "${CMAKE_SOURCE_DIR}/deps/lucene"
SOURCE_DIR "${CMAKE_SOURCE_DIR}/deps/lucene"
BINARY_DIR ""
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
#BUILD_IN_SOURCE TRUE
...
@@ -10,4 +9,4 @@ ExternalProject_Add(lucene
...
@@ -10,4 +9,4 @@ ExternalProject_Add(lucene
BUILD_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
TEST_COMMAND ""
)
)
\ No newline at end of file
deps/CMakeLists.txt
浏览文件 @
d4cd3836
...
@@ -65,6 +65,11 @@ endif(${BUILD_WITH_ROCKSDB})
...
@@ -65,6 +65,11 @@ endif(${BUILD_WITH_ROCKSDB})
if
(
${
BUILD_WITH_LUCENE
}
)
if
(
${
BUILD_WITH_LUCENE
}
)
option
(
ENABLE_TEST
"Enable the tests"
OFF
)
option
(
ENABLE_TEST
"Enable the tests"
OFF
)
add_subdirectory
(
lucene
)
add_subdirectory
(
lucene
)
target_include_directories
(
lucene++
PUBLIC $<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/lucene/include>
)
endif
(
${
BUILD_WITH_LUCENE
}
)
endif
(
${
BUILD_WITH_LUCENE
}
)
# ================================================================================================
# ================================================================================================
...
...
include/libs/index/index.h
浏览文件 @
d4cd3836
...
@@ -16,12 +16,72 @@
...
@@ -16,12 +16,72 @@
#ifndef _TD_INDEX_H_
#ifndef _TD_INDEX_H_
#define _TD_INDEX_H_
#define _TD_INDEX_H_
#include "os.h"
#include "tarray.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
typedef
struct
SIndex
SIndex
;
typedef
struct
SIndexOpts
SIndexOpts
;
typedef
enum
{
MUST
=
0
,
SHOULD
=
1
,
NOT
=
2
}
EIndexOperatorType
;
typedef
enum
{
QUERY_POINT
=
0
,
QUERY_PREFIX
=
1
,
QUERY_SUFFIX
=
2
,
QUERY_REGEX
=
3
}
EIndexQueryType
;
typedef
struct
SIndexTermQuery
{
EIndexQueryType
opera
;
SArray
*
querys
;
}
SIndexTermQuery
;
// tag and tag val;
typedef
struct
SIndexPair
{
char
*
key
;
char
*
val
;
}
SIndexPair
;
//
typedef
struct
SIndexTerm
{
SIndexPair
*
field_value
;
EIndexQueryType
type
;
}
SIndexTerm
;
/*
* @param: oper
*
*/
SIndexTermQuery
*
indexTermQueryCreate
(
EIndexOperatorType
oper
);
void
indexTermQueryDestroy
(
SIndexTermQuery
*
pQuery
);
int
indexTermQueryAdd
(
SIndexTermQuery
*
pQuery
,
const
char
*
field
,
int32_t
nFields
,
const
char
*
value
,
int32_t
nValue
,
EIndexQueryType
type
);
/*
* @param:
* @param:
*/
SIndex
*
indexOpen
(
SIndexOpts
*
opt
,
const
char
*
path
);
void
indexClose
(
SIndex
*
index
);
int
indexPut
(
SIndex
*
index
,
SArray
*
pairs
,
int
uid
);
int
indexDelete
(
SIndex
*
index
,
SIndexTermQuery
*
query
);
int
indexSearch
(
SIndex
*
index
,
SIndexTermQuery
*
query
,
SArray
*
result
);
int
indexRebuild
(
SIndex
*
index
,
SIndexOpts
*
opt
);
/*
* @param:
* @param:
*/
SIndexOpts
*
indexOptsCreate
();
void
indexOptsDestroy
(
SIndexOpts
*
opts
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
#endif
/*_TD_INDEX_H_*/
#endif
/*_TD_INDEX_H_*/
\ No newline at end of file
source/libs/index/CMakeLists.txt
浏览文件 @
d4cd3836
...
@@ -4,4 +4,27 @@ target_include_directories(
...
@@ -4,4 +4,27 @@ target_include_directories(
index
index
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/index"
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/index"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
)
\ No newline at end of file
target_link_libraries
(
index
PUBLIC os
PUBLIC util
)
if
(
${
BUILD_WITH_LUCENE
}
)
target_include_directories
(
index
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/deps/lucene/include"
)
LINK_DIRECTORIES
(
"
${
CMAKE_SOURCE_DIR
}
/deps/lucene/debug/src/core"
)
target_link_libraries
(
index
PUBLIC lucene++
)
endif
(
${
BUILD_WITH_LUCENE
}
)
if
(
${
BUILD_TEST
}
)
add_subdirectory
(
test
)
endif
(
${
BUILD_TEST
}
)
source/libs/index/inc/indexInt.h
浏览文件 @
d4cd3836
...
@@ -16,12 +16,31 @@
...
@@ -16,12 +16,31 @@
#ifndef _TD_INDEX_INT_H_
#ifndef _TD_INDEX_INT_H_
#define _TD_INDEX_INT_H_
#define _TD_INDEX_INT_H_
#include "index.h"
#ifdef USE_LUCENE
#include <lucene++/Lucene_c.h>
#endif
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
struct
SIndex
{
#ifdef USE_LUCENE
index_t
*
index
;
#endif
};
struct
SIndexOpts
{
#ifdef USE_LUCENE
void
*
opts
;
#endif
};
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
#endif
/*_TD_INDEX_INT_H_*/
#endif
/*_TD_INDEX_INT_H_*/
\ No newline at end of file
source/libs/index/src/index.c
浏览文件 @
d4cd3836
...
@@ -13,15 +13,71 @@
...
@@ -13,15 +13,71 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#i
fndef _TD_INDEX_H_
#i
nclude "index.h"
#
define _TD_INDEX_H_
#
include "indexInt.h"
#ifdef
__cplusplus
#ifdef
USE_LUCENE
extern
"C"
{
#include "lucene++/Lucene_c.h"
#endif
#endif
#ifdef __cplusplus
static
pthread_once_t
isInit
=
PTHREAD_ONCE_INIT
;
static
void
indexInit
();
SIndex
*
indexOpen
(
SIndexOpts
*
opts
,
const
char
*
path
)
{
pthread_once
(
&
isInit
,
indexInit
);
#ifdef USE_LUCENE
index_t
*
index
=
index_open
(
path
);
SIndex
*
p
=
malloc
(
sizeof
(
SIndex
));
p
->
index
=
index
;
return
p
;
#endif
return
NULL
;
}
}
void
indexClose
(
SIndex
*
index
)
{
#ifdef USE_LUCENE
index_close
(
index
->
index
);
#endif
#endif
free
(
index
);
return
;
}
int
indexPut
(
SIndex
*
index
,
SArray
*
field_vals
,
int
uid
)
{
return
1
;
}
int
indexSearch
(
SIndex
*
index
,
SIndexTermQuery
*
query
,
SArray
*
result
)
{
return
1
;
}
int
indexDelete
(
SIndex
*
index
,
SIndexTermQuery
*
query
)
{
return
1
;
}
int
indexRebuild
(
SIndex
*
index
,
SIndexOpts
*
opts
);
#endif
/*_TD_INDEX_H_*/
SIndexOpts
*
indexOptsCreate
()
{
\ No newline at end of file
return
NULL
;
}
void
indexOptsDestroy
(
SIndexOpts
*
opts
)
{
}
/*
* @param: oper
*
*/
SIndexTermQuery
*
indexTermQueryCreate
(
EIndexOperatorType
oper
)
{
return
NULL
;
}
void
indexTermQueryDestroy
(
SIndexTermQuery
*
pQuery
)
{
}
int
indexTermQueryAdd
(
SIndexTermQuery
*
pQuery
,
const
char
*
field
,
int32_t
nFields
,
const
char
*
value
,
int32_t
nValue
,
EIndexQueryType
type
){
return
1
;
}
void
indexInit
()
{
//do nothing
}
source/libs/index/test/indexTests.cpp
浏览文件 @
d4cd3836
#include <gtest/gtest.h>
#include <string>
#include <iostream>
#include "index.h"
TEST
(
IndexTest
,
index_create_test
)
{
SIndexOpts
*
opts
=
indexOptsCreate
();
SIndex
*
index
=
indexOpen
(
opts
,
"./"
);
if
(
index
==
NULL
)
{
std
::
cout
<<
"index open failed"
<<
std
::
endl
;
}
indexOptsDestroy
(
opts
);
}
source/libs/tkv/src/tkv.c
浏览文件 @
d4cd3836
...
@@ -158,6 +158,8 @@ static void tkvInit() {
...
@@ -158,6 +158,8 @@ static void tkvInit() {
#ifdef USE_ROCKSDB
#ifdef USE_ROCKSDB
defaultReadOpts
.
ropts
=
rocksdb_readoptions_create
();
defaultReadOpts
.
ropts
=
rocksdb_readoptions_create
();
defaultWriteOpts
.
wopts
=
rocksdb_writeoptions_create
();
defaultWriteOpts
.
wopts
=
rocksdb_writeoptions_create
();
rocksdb_writeoptions_disable_WAL
(
defaultWriteOpts
.
wopts
,
true
);
#endif
#endif
}
}
...
@@ -166,4 +168,4 @@ static void tkvClear() {
...
@@ -166,4 +168,4 @@ static void tkvClear() {
rocksdb_readoptions_destroy
(
defaultReadOpts
.
ropts
);
rocksdb_readoptions_destroy
(
defaultReadOpts
.
ropts
);
rocksdb_writeoptions_destroy
(
defaultWriteOpts
.
wopts
);
rocksdb_writeoptions_destroy
(
defaultWriteOpts
.
wopts
);
#endif
#endif
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录