Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
261ef100
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
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,发现更多精彩内容 >>
提交
261ef100
编写于
12月 29, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor code
上级
efe872c6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
32 deletion
+57
-32
source/libs/index/src/index_cache.c
source/libs/index/src/index_cache.c
+36
-11
source/libs/index/src/index_fst_counting_writer.c
source/libs/index/src/index_fst_counting_writer.c
+5
-2
source/libs/index/src/index_tfile.c
source/libs/index/src/index_tfile.c
+3
-3
source/libs/index/test/indexTests.cc
source/libs/index/test/indexTests.cc
+13
-16
未找到文件。
source/libs/index/src/index_cache.c
浏览文件 @
261ef100
...
...
@@ -20,7 +20,7 @@
#define MAX_INDEX_KEY_LEN 256 // test only, change later
#define MEM_TERM_LIMIT
1
00
#define MEM_TERM_LIMIT
2
00
// ref index_cache.h:22
//#define CACHE_KEY_LEN(p) \
// (sizeof(int32_t) + sizeof(uint16_t) + sizeof(p->colType) + sizeof(p->nColVal) + p->nColVal + sizeof(uint64_t) +
...
...
@@ -66,19 +66,43 @@ void indexCacheDebug(IndexCache* cache) {
indexMemRef
(
tbl
);
pthread_mutex_unlock
(
&
cache
->
mtx
);
SSkipList
*
slt
=
tbl
->
mem
;
SSkipListIterator
*
iter
=
tSkipListCreateIter
(
slt
);
while
(
tSkipListIterNext
(
iter
))
{
SSkipListNode
*
node
=
tSkipListIterGet
(
iter
);
CacheTerm
*
ct
=
(
CacheTerm
*
)
SL_GET_NODE_DATA
(
node
);
if
(
ct
!=
NULL
)
{
// TODO, add more debug info
indexInfo
(
"{colVal: %s, version: %d}
\t
"
,
ct
->
colVal
,
ct
->
version
);
{
SSkipList
*
slt
=
tbl
->
mem
;
SSkipListIterator
*
iter
=
tSkipListCreateIter
(
slt
);
while
(
tSkipListIterNext
(
iter
))
{
SSkipListNode
*
node
=
tSkipListIterGet
(
iter
);
CacheTerm
*
ct
=
(
CacheTerm
*
)
SL_GET_NODE_DATA
(
node
);
if
(
ct
!=
NULL
)
{
// TODO, add more debug info
indexInfo
(
"{colVal: %s, version: %d}
\t
"
,
ct
->
colVal
,
ct
->
version
);
}
}
tSkipListDestroyIter
(
iter
);
indexMemUnRef
(
tbl
);
}
tSkipListDestroyIter
(
iter
);
indexMemUnRef
(
tbl
);
{
pthread_mutex_lock
(
&
cache
->
mtx
);
tbl
=
cache
->
imm
;
indexMemRef
(
tbl
);
pthread_mutex_unlock
(
&
cache
->
mtx
);
if
(
tbl
!=
NULL
)
{
SSkipList
*
slt
=
tbl
->
mem
;
SSkipListIterator
*
iter
=
tSkipListCreateIter
(
slt
);
while
(
tSkipListIterNext
(
iter
))
{
SSkipListNode
*
node
=
tSkipListIterGet
(
iter
);
CacheTerm
*
ct
=
(
CacheTerm
*
)
SL_GET_NODE_DATA
(
node
);
if
(
ct
!=
NULL
)
{
// TODO, add more debug info
indexInfo
(
"{colVal: %s, version: %d}
\t
"
,
ct
->
colVal
,
ct
->
version
);
}
}
tSkipListDestroyIter
(
iter
);
}
indexMemUnRef
(
tbl
);
}
}
void
indexCacheDestroySkiplist
(
SSkipList
*
slt
)
{
...
...
@@ -247,6 +271,7 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, SArray* result, STermV
SIndexTerm
*
term
=
query
->
term
;
EIndexQueryType
qtype
=
query
->
qType
;
CacheTerm
ct
=
{.
colVal
=
term
->
colVal
,
.
version
=
atomic_load_32
(
&
pCache
->
version
)};
indexCacheDebug
(
pCache
);
int
ret
=
indexQueryMem
(
mem
,
&
ct
,
qtype
,
result
,
s
);
if
(
ret
==
0
&&
*
s
!=
kTypeDeletion
)
{
...
...
source/libs/index/src/index_fst_counting_writer.c
浏览文件 @
261ef100
...
...
@@ -52,7 +52,7 @@ static int writeCtxDoReadFrom(WriterCtx* ctx, uint8_t* buf, int len, int32_t off
}
static
int
writeCtxDoFlush
(
WriterCtx
*
ctx
)
{
if
(
ctx
->
type
==
TFile
)
{
// tfFsync(ctx->
fd);
tfFsync
(
ctx
->
file
.
fd
);
// tfFlush(ctx->file.fd);
}
else
{
// do nothing
...
...
@@ -101,7 +101,10 @@ void writerCtxDestroy(WriterCtx* ctx, bool remove) {
free
(
ctx
->
mem
.
buf
);
}
else
{
tfClose
(
ctx
->
file
.
fd
);
if
(
remove
)
unlink
(
ctx
->
file
.
buf
);
if
(
remove
)
{
indexError
(
"rm file %s"
,
ctx
->
file
.
buf
);
unlink
(
ctx
->
file
.
buf
);
}
}
free
(
ctx
);
}
...
...
source/libs/index/src/index_tfile.c
浏览文件 @
261ef100
...
...
@@ -81,7 +81,7 @@ TFileCache* tfileCacheCreate(const char* path) {
continue
;
}
WriterCtx
*
wc
=
writerCtxCreate
(
TFile
,
file
,
true
,
1024
*
64
);
WriterCtx
*
wc
=
writerCtxCreate
(
TFile
,
file
,
true
,
1024
*
1024
*
64
);
if
(
wc
==
NULL
)
{
indexError
(
"failed to open index:%s"
,
file
);
goto
End
;
...
...
@@ -211,7 +211,7 @@ TFileWriter* tfileWriterOpen(char* path, uint64_t suid, int32_t version, const c
char
fullname
[
256
]
=
{
0
};
snprintf
(
fullname
,
sizeof
(
fullname
),
"%s/%s"
,
path
,
filename
);
WriterCtx
*
wcx
=
writerCtxCreate
(
TFile
,
fullname
,
false
,
1024
*
1024
);
WriterCtx
*
wcx
=
writerCtxCreate
(
TFile
,
fullname
,
false
,
1024
*
1024
*
64
);
if
(
wcx
==
NULL
)
{
return
NULL
;
}
TFileHeader
tfh
=
{
0
};
...
...
@@ -229,7 +229,7 @@ TFileReader* tfileReaderOpen(char* path, uint64_t suid, int32_t version, const c
char
fullname
[
256
]
=
{
0
};
snprintf
(
fullname
,
sizeof
(
fullname
),
"%s/%s"
,
path
,
filename
);
WriterCtx
*
wc
=
writerCtxCreate
(
TFile
,
fullname
,
true
,
1024
*
1024
);
WriterCtx
*
wc
=
writerCtxCreate
(
TFile
,
fullname
,
true
,
1024
*
1024
*
1024
);
if
(
wc
==
NULL
)
{
return
NULL
;
}
TFileReader
*
reader
=
tfileReaderCreateImpl
(
wc
);
...
...
source/libs/index/test/indexTests.cc
浏览文件 @
261ef100
...
...
@@ -427,7 +427,7 @@ static TFileValue* genTFileValue(const char* val) {
memcpy
(
tv
->
colVal
,
val
,
vlen
);
tv
->
tableId
=
(
SArray
*
)
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
for
(
size_t
i
=
0
;
i
<
1
0
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
20
0
;
i
++
)
{
uint64_t
v
=
i
;
taosArrayPush
(
tv
->
tableId
,
&
v
);
}
...
...
@@ -440,17 +440,14 @@ static void destroyTFileValue(void* val) {
free
(
tv
);
}
TEST_F
(
IndexTFileEnv
,
test_tfile_write
)
{
TFileValue
*
v1
=
genTFileValue
(
"c"
);
TFileValue
*
v2
=
genTFileValue
(
"ab"
);
TFileValue
*
v3
=
genTFileValue
(
"b"
);
TFileValue
*
v4
=
genTFileValue
(
"d"
);
TFileValue
*
v1
=
genTFileValue
(
"ab"
);
SArray
*
data
=
(
SArray
*
)
taosArrayInit
(
4
,
sizeof
(
void
*
));
taosArrayPush
(
data
,
&
v1
);
taosArrayPush
(
data
,
&
v2
);
taosArrayPush
(
data
,
&
v3
);
taosArrayPush
(
data
,
&
v4
);
//
taosArrayPush(data, &v2);
//
taosArrayPush(data, &v3);
//
taosArrayPush(data, &v4);
fObj
->
Put
(
data
);
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
data
);
i
++
)
{
destroyTFileValue
(
taosArrayGetP
(
data
,
i
));
}
...
...
@@ -464,7 +461,7 @@ TEST_F(IndexTFileEnv, test_tfile_write) {
SArray
*
result
=
(
SArray
*
)
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
fObj
->
Get
(
&
query
,
result
);
assert
(
taosArrayGetSize
(
result
)
==
1
0
);
assert
(
taosArrayGetSize
(
result
)
==
20
0
);
indexTermDestroy
(
term
);
// tfileWriterDestroy(twrite);
...
...
@@ -665,8 +662,8 @@ class IndexObj {
}
~
IndexObj
()
{
indexClose
(
idx
);
indexCleanUp
();
indexClose
(
idx
);
}
private:
...
...
@@ -696,9 +693,9 @@ TEST_F(IndexEnv2, testIndexOpen) {
exit
(
1
);
}
int
targetSize
=
1
00
;
int
targetSize
=
2
00
;
{
std
::
string
colName
(
"tag1"
),
colVal
(
"Hello
world
"
);
std
::
string
colName
(
"tag1"
),
colVal
(
"Hello"
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
...
...
@@ -712,8 +709,8 @@ TEST_F(IndexEnv2, testIndexOpen) {
indexMultiTermDestroy
(
terms
);
}
{
size_t
size
=
1
00
;
std
::
string
colName
(
"tag1"
),
colVal
(
"hello
world
"
);
size_t
size
=
2
00
;
std
::
string
colName
(
"tag1"
),
colVal
(
"hello"
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
...
...
@@ -728,7 +725,7 @@ TEST_F(IndexEnv2, testIndexOpen) {
}
{
std
::
string
colName
(
"tag1"
),
colVal
(
"Hello
world
"
);
std
::
string
colName
(
"tag1"
),
colVal
(
"Hello"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
...
...
@@ -747,7 +744,7 @@ TEST_F(IndexEnv2, testIndex_TrigeFlush) {
if
(
index
->
Init
(
path
)
!=
0
)
{}
int
numOfTable
=
100
*
10000
;
index
->
WriteMillonData
(
"tag1"
,
"Hello world"
,
numOfTable
);
int
target
=
index
->
SearchOne
(
"tag1"
,
"Hello
w
world"
);
int
target
=
index
->
SearchOne
(
"tag1"
,
"Hello world"
);
assert
(
numOfTable
==
target
);
}
TEST_F
(
IndexEnv2
,
testIndex_serarch_cache_and_tfile
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录