Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
db2bf567
TDengine
项目概览
taosdata
/
TDengine
11 个月 前同步成功
通知
1179
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
db2bf567
编写于
12月 06, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor builder struct
上级
7e1f68f8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
34 addition
and
9 deletion
+34
-9
source/libs/index/inc/indexInt.h
source/libs/index/inc/indexInt.h
+11
-0
source/libs/index/inc/index_fst_counting_writer.h
source/libs/index/inc/index_fst_counting_writer.h
+1
-1
source/libs/index/src/index_fst.c
source/libs/index/src/index_fst.c
+13
-2
source/libs/index/src/index_fst_counting_writer.c
source/libs/index/src/index_fst_counting_writer.c
+5
-2
source/libs/index/test/indexTests.cpp
source/libs/index/test/indexTests.cpp
+4
-4
未找到文件。
source/libs/index/inc/indexInt.h
浏览文件 @
db2bf567
...
...
@@ -17,6 +17,7 @@
#define _TD_INDEX_INT_H_
#include "index.h"
#include "tlog.h"
#ifdef USE_LUCENE
#include <lucene++/Lucene_c.h>
...
...
@@ -60,6 +61,16 @@ typedef struct SIndexTermQuery {
SIndexTerm
*
indexTermCreate
(
const
char
*
key
,
int32_t
nKey
,
const
char
*
val
,
int32_t
nVal
);
void
indexTermDestroy
(
SIndexTerm
*
p
);
#define indexFatal(...) do { if (sDebugFlag & DEBUG_FATAL) { taosPrintLog("index FATAL ", 255, __VA_ARGS__); }} while(0)
#define indexError(...) do { if (sDebugFlag & DEBUG_ERROR) { taosPrintLog("index ERROR ", 255, __VA_ARGS__); }} while(0)
#define indexWarn(...) do { if (sDebugFlag & DEBUG_WARN) { taosPrintLog("index WARN ", 255, __VA_ARGS__); }} while(0)
#define indexInfo(...) do { if (sDebugFlag & DEBUG_INFO) { taosPrintLog("index ", 255, __VA_ARGS__); }} while(0)
#define indexDebug(...) do { if (sDebugFlag & DEBUG_DEBUG) { taosPrintLog("index ", sDebugFlag, __VA_ARGS__); }} while(0)
#define indexTrace(...) do { if (sDebugFlag & DEBUG_TRACE) { taosPrintLog("index ", sDebugFlag, __VA_ARGS__); }} while(0)
#ifdef __cplusplus
}
#endif
...
...
source/libs/index/inc/index_fst_counting_writer.h
浏览文件 @
db2bf567
...
...
@@ -25,7 +25,7 @@ extern "C" {
#define DefaultMem 1024*1024
static
char
tmpFile
[]
=
"
/tmp
/index"
;
static
char
tmpFile
[]
=
"
.
/index"
;
typedef
enum
WriterType
{
TMemory
,
TFile
}
WriterType
;
typedef
struct
WriterCtx
{
...
...
source/libs/index/src/index_fst.c
浏览文件 @
db2bf567
...
...
@@ -148,7 +148,7 @@ uint64_t fstUnFinishedNodesFindCommPrefixAndSetOutput(FstUnFinishedNodes *node,
size_t
lsz
=
(
size_t
)(
s
->
end
-
s
->
start
+
1
);
// data len
size_t
ssz
=
taosArrayGetSize
(
node
->
stack
);
// stack size
*
out
=
in
;
uint64_t
i
=
0
;
for
(
i
=
0
;
i
<
lsz
&&
i
<
ssz
;
i
++
)
{
FstBuilderNodeUnfinished
*
un
=
taosArrayGet
(
node
->
stack
,
i
);
...
...
@@ -776,6 +776,17 @@ FstBuilder *fstBuilderCreate(void *w, FstType ty) {
b
->
last
=
fstSliceCreate
(
NULL
,
0
);
b
->
lastAddr
=
NONE_ADDRESS
;
b
->
len
=
0
;
char
buf64
[
8
]
=
{
0
};
void
*
pBuf64
=
buf64
;
taosEncodeFixedU64
(
&
pBuf64
,
VERSION
);
fstCountingWriterWrite
(
b
->
wrt
,
buf64
,
sizeof
(
buf64
));
memset
(
buf64
,
0
,
sizeof
(
buf64
));
pBuf64
=
buf64
;
taosEncodeFixedU64
(
&
pBuf64
,
ty
);
fstCountingWriterWrite
(
b
->
wrt
,
buf64
,
sizeof
(
buf64
));
return
b
;
}
void
fstBuilderDestroy
(
FstBuilder
*
b
)
{
...
...
@@ -811,7 +822,7 @@ void fstBuilderInsertOutput(FstBuilder *b, FstSlice bs, Output in) {
// prefixLen = fstUnFinishedNodesFindCommPrefix(b->unfinished, bs);
// out = 0;
//}
Output
out
;
Output
out
;
uint64_t
prefixLen
=
fstUnFinishedNodesFindCommPrefixAndSetOutput
(
b
->
unfinished
,
bs
,
in
,
&
out
);
if
(
prefixLen
==
FST_SLICE_LEN
(
s
))
{
...
...
source/libs/index/src/index_fst_counting_writer.c
浏览文件 @
db2bf567
...
...
@@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tutil.h"
#include "indexInt.h"
#include "index_fst_util.h"
#include "index_fst_counting_writer.h"
...
...
@@ -22,7 +23,7 @@ static int writeCtxDoWrite(WriterCtx *ctx, uint8_t *buf, int len) {
}
if
(
ctx
->
type
==
TFile
)
{
assert
(
len
!
=
tfWrite
(
ctx
->
fd
,
buf
,
len
));
assert
(
len
=
=
tfWrite
(
ctx
->
fd
,
buf
,
len
));
}
else
{
memcpy
(
ctx
->
mem
+
ctx
->
offset
,
buf
,
len
);
}
...
...
@@ -54,9 +55,10 @@ WriterCtx* writerCtxCreate(WriterType type) {
ctx
->
type
=
type
;
if
(
ctx
->
type
==
TFile
)
{
tfInit
();
ctx
->
fd
=
tfOpenCreateWriteAppend
(
tmpFile
);
if
(
ctx
->
fd
<
0
)
{
indexError
(
"open file error %d"
,
errno
);
}
}
else
if
(
ctx
->
type
==
TMemory
)
{
ctx
->
mem
=
calloc
(
1
,
DefaultMem
*
sizeof
(
uint8_t
));
...
...
@@ -74,6 +76,7 @@ void writerCtxDestroy(WriterCtx *ctx) {
if
(
ctx
->
type
==
TMemory
)
{
free
(
ctx
->
mem
);
}
else
{
tfCleanup
();
tfClose
(
ctx
->
fd
);
}
free
(
ctx
);
...
...
source/libs/index/test/indexTests.cpp
浏览文件 @
db2bf567
...
...
@@ -75,10 +75,10 @@ int main(int argc, char** argv) {
//FstSlice key1 = fstSliceCreate((uint8_t *)str1.c_str(), str1.size());
//Output val2 = 10;
{
std
::
string
str
(
"bcd"
);
FstSlice
key
=
fstSliceCreate
((
uint8_t
*
)
str
.
c_str
(),
str
.
size
());
Output
val
=
1
;
fstBuilderInsert
(
b
,
key
,
val
);
//
std::string str("bcd");
//
FstSlice key = fstSliceCreate((uint8_t *)str.c_str(), str.size());
//
Output val = 1;
//
fstBuilderInsert(b, key, val);
}
//fstBuilderInsert(b, key1, val2);
fstBuilderFinish
(
b
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录