Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f7be7909
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f7be7909
编写于
12月 21, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update index TFile write
上级
192552be
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
9 deletion
+27
-9
source/libs/index/inc/index_tfile.h
source/libs/index/inc/index_tfile.h
+2
-1
source/libs/index/src/index_tfile.c
source/libs/index/src/index_tfile.c
+25
-8
未找到文件。
source/libs/index/inc/index_tfile.h
浏览文件 @
f7be7909
...
...
@@ -96,7 +96,8 @@ TFileReader *tfileCacheGet(TFileCache *tcache, TFileCacheKey *key);
void
tfileCachePut
(
TFileCache
*
tcache
,
TFileCacheKey
*
key
,
TFileReader
*
reader
);
TFileReader
*
tfileReaderCreate
(
WriterCtx
*
ctx
);
void
TFileReaderDestroy
(
TFileReader
*
reader
);
void
tfileReaderDestroy
(
TFileReader
*
reader
);
int
tfileReaderSearch
(
TFileReader
*
reader
,
SIndexTermQuery
*
query
,
SArray
*
result
);
TFileWriter
*
tfileWriterCreate
(
WriterCtx
*
ctx
,
TFileHeader
*
header
);
void
tfileWriterDestroy
(
TFileWriter
*
tw
);
...
...
source/libs/index/src/index_tfile.c
浏览文件 @
f7be7909
...
...
@@ -117,7 +117,7 @@ TFileCache *tfileCacheCreate(const char *path) {
}
TFileReader
*
reader
=
tfileReaderCreate
(
wc
);
if
(
0
!=
tfileReadLoadHeader
(
reader
))
{
TF
ileReaderDestroy
(
reader
);
tf
ileReaderDestroy
(
reader
);
indexError
(
"failed to load index header, index Id: %s"
,
file
);
goto
End
;
}
...
...
@@ -126,7 +126,6 @@ TFileCache *tfileCacheCreate(const char *path) {
TFileHeader
*
header
=
&
reader
->
header
;
TFileCacheKey
key
=
{
.
suid
=
header
->
suid
,
.
version
=
header
->
version
,
.
colName
=
header
->
colName
,
.
nColName
=
strlen
(
header
->
colName
),
.
colType
=
header
->
colType
};
char
buf
[
128
]
=
{
0
};
tfileSerialCacheKey
(
&
key
,
buf
);
taosHashPut
(
tcache
->
tableCache
,
buf
,
strlen
(
buf
),
&
reader
,
sizeof
(
void
*
));
...
...
@@ -147,7 +146,7 @@ void tfileCacheDestroy(TFileCache *tcache) {
TFileReader
*
p
=
*
reader
;
indexInfo
(
"drop table cache suid: %"
PRIu64
", colName: %s, colType: %d"
,
p
->
header
.
suid
,
p
->
header
.
colName
,
p
->
header
.
colType
);
TF
ileReaderDestroy
(
p
);
tf
ileReaderDestroy
(
p
);
reader
=
taosHashIterate
(
tcache
->
tableCache
,
reader
);
}
taosHashCleanup
(
tcache
->
tableCache
);
...
...
@@ -175,13 +174,32 @@ TFileReader *tfileReaderCreate(WriterCtx *ctx) {
reader
->
ctx
=
ctx
;
return
reader
;
}
void
TF
ileReaderDestroy
(
TFileReader
*
reader
)
{
void
tf
ileReaderDestroy
(
TFileReader
*
reader
)
{
if
(
reader
==
NULL
)
{
return
;
}
// T_REF_INC(reader);
writerCtxDestroy
(
reader
->
ctx
);
free
(
reader
);
}
int
tfileReaderSearch
(
TFileReader
*
reader
,
SIndexTermQuery
*
query
,
SArray
*
result
)
{
SIndexTerm
*
term
=
query
->
term
;
// refactor to callback later
if
(
query
->
qType
==
QUERY_TERM
)
{
uint64_t
offset
;
FstSlice
key
=
fstSliceCreate
(
term
->
colVal
,
term
->
nColVal
);
if
(
fstGet
(
reader
->
fst
,
&
key
,
&
offset
))
{
//
}
else
{
indexInfo
(
"index: %"
PRIu64
", col: %s, colVal: %s, not found in tindex"
,
term
->
suid
,
term
->
colName
,
term
->
colVal
);
}
return
0
;
}
else
if
(
query
->
qType
==
QUERY_PREFIX
)
{
//
//
}
return
0
;
}
TFileWriter
*
tfileWriterCreate
(
WriterCtx
*
ctx
,
TFileHeader
*
header
)
{
// char pathBuf[128] = {0};
// sprintf(pathBuf, "%s/% " PRIu64 "-%d-%d.tindex", path, suid, colId, version);
...
...
@@ -196,7 +214,7 @@ TFileWriter *tfileWriterCreate(WriterCtx *ctx, TFileHeader *header) {
}
TFileWriter
*
tw
=
calloc
(
1
,
sizeof
(
TFileWriter
));
if
(
tw
==
NULL
)
{
indexError
(
"index: %
"
PRIu64
" failed to write header info"
);
indexError
(
"index: %
"
PRIu64
" failed to alloc TFilerWriter"
,
header
->
suid
);
return
NULL
;
}
return
tw
;
...
...
@@ -218,15 +236,14 @@ IndexTFile *indexTFileCreate(const char *path) {
void
IndexTFileDestroy
(
IndexTFile
*
tfile
)
{
free
(
tfile
);
}
int
indexTFileSearch
(
void
*
tfile
,
SIndexTermQuery
*
query
,
SArray
*
result
)
{
if
(
tfile
==
NULL
)
{
return
-
1
;
}
IndexTFile
*
pTfile
=
(
IndexTFile
*
)
tfile
;
if
(
pTfile
==
NULL
)
{
return
-
1
;
}
SIndexTerm
*
term
=
query
->
term
;
TFileCacheKey
key
=
{.
suid
=
term
->
suid
,
.
colType
=
term
->
colType
,
.
version
=
0
,
.
colName
=
term
->
colName
,
.
nColName
=
term
->
nColName
};
TFileReader
*
reader
=
tfileCacheGet
(
pTfile
->
cache
,
&
key
);
return
0
;
return
tfileReaderSearch
(
reader
,
query
,
result
);
}
int
indexTFilePut
(
void
*
tfile
,
SIndexTerm
*
term
,
uint64_t
uid
)
{
TFileWriterOpt
wOpt
=
{.
suid
=
term
->
suid
,
.
colType
=
term
->
colType
,
.
colName
=
term
->
colName
,
.
nColName
=
term
->
nColName
,
.
version
=
1
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录