Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a0864b1c
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a0864b1c
编写于
12月 20, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update index TFile write
上级
489179b9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
119 addition
and
6 deletion
+119
-6
source/libs/index/inc/indexInt.h
source/libs/index/inc/indexInt.h
+1
-1
source/libs/index/inc/index_tfile.h
source/libs/index/inc/index_tfile.h
+47
-2
source/libs/index/src/index_tfile.c
source/libs/index/src/index_tfile.c
+71
-3
未找到文件。
source/libs/index/inc/indexInt.h
浏览文件 @
a0864b1c
...
...
@@ -76,7 +76,7 @@ struct SIndexMultiTermQuery {
// field and key;
typedef
struct
SIndexTerm
{
int64_t
suid
;
int64_t
suid
;
SIndexOperOnColumn
operType
;
// oper type, add/del/update
uint8_t
colType
;
// term data type, str/interger/json
char
*
colName
;
...
...
source/libs/index/inc/index_tfile.h
浏览文件 @
a0864b1c
...
...
@@ -19,31 +19,76 @@
#include "indexInt.h"
#include "tlockfree.h"
#include "index_tfile.h"
#include "index_fst_counting_writer.h"
#include "index_fst.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
TFileCacheKey
{
uint64_t
suid
;
uint8_t
colType
;
int32_t
version
;
const
char
*
colName
;
int32_t
nColName
;
}
TFileCacheKey
;
// table cache
// refactor to LRU cache later
typedef
struct
TFileCache
{
SHashObj
*
tableCache
;
int16_t
capacity
;
// add more param
}
TFileCache
;
typedef
struct
TFileWriter
{
FstBuilder
*
fb
;
WriterCtx
*
wc
;
}
TFileWriter
;
typedef
struct
TFileReader
{
T_REF_DECLARE
()
Fst
*
fst
;
}
TFileReader
;
typedef
struct
IndexTFile
{
T_REF_DECLARE
()
char
*
path
;
TFileReader
*
tb
;
TFileWriter
*
tw
;
}
IndexTFile
;
typedef
struct
TFileWriterOpt
{
uint64_t
suid
;
int8_t
colType
;
char
*
colName
;
int32_t
nColName
;
int32_t
version
;
}
TFileWriterOpt
;
typedef
struct
TFileReaderOpt
{
uint64_t
suid
;
char
*
colName
;
int32_t
nColName
;
}
TFileReaderOpt
;
// tfile cache
TFileCache
*
tfileCacheCreate
();
void
tfileCacheDestroy
(
TFileCache
*
tcache
);
TFileReader
*
tfileCacheGet
(
TFileCache
*
tcache
,
TFileCacheKey
*
key
);
void
tfileCachePut
(
TFileCache
*
tcache
,
TFileCacheKey
*
key
,
TFileReader
*
reader
);
TFileWriter
*
tfileWriterCreate
(
const
char
*
suid
,
const
char
*
colName
);
IndexTFile
*
indexTFileCreate
();
int
indexTFilePut
(
void
*
tfile
,
SIndexTerm
*
term
,
uint64_t
uid
);
int
indexTFilePut
(
void
*
tfile
,
SIndexTerm
*
term
,
uint64_t
uid
);
int
indexTFileSearch
(
void
*
tfile
,
SIndexTermQuery
*
query
,
SArray
*
result
);
...
...
source/libs/index/src/index_tfile.c
浏览文件 @
a0864b1c
...
...
@@ -16,9 +16,67 @@
#include "index_tfile.h"
#include "index_fst.h"
#define SERIALIZE_TO_BUF(buf, key, mem) \
do { \
memcpy(buf, &key->mem, sizeof(key->mem)); \
buf += sizeof(key->mem); \
} while (0)
#define SERIALIZE_STR_TO_BUF(buf, key, mem, len) \
do { \
memcpy(buf, key->mem, len); \
buf += len; \
} while (0)
#define SERIALIZE_DELIMITER_TO_BUF(buf, delim) \
do { \
char c = delim; \
memcpy(buf, &c, sizeof(c)); \
buf += sizeof(c); \
} while (0)
static
void
tfileSerialCacheKey
(
TFileCacheKey
*
key
,
char
*
buf
)
{
SERIALIZE_TO_BUF
(
buf
,
key
,
suid
);
SERIALIZE_DELIMITER_TO_BUF
(
buf
,
'_'
);
SERIALIZE_TO_BUF
(
buf
,
key
,
colType
);
SERIALIZE_DELIMITER_TO_BUF
(
buf
,
'_'
);
SERIALIZE_TO_BUF
(
buf
,
key
,
version
);
SERIALIZE_DELIMITER_TO_BUF
(
buf
,
'_'
);
SERIALIZE_STR_TO_BUF
(
buf
,
key
,
colName
,
key
->
nColName
);
}
TFileCache
*
tfileCacheCreate
()
{
TFileCache
*
tcache
=
calloc
(
1
,
sizeof
(
TFileCache
));
if
(
tcache
==
NULL
)
{
return
NULL
;
}
tcache
->
tableCache
=
taosHashInit
(
8
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
tcache
->
capacity
=
64
;
return
tcache
;
}
void
tfileCacheDestroy
(
TFileCache
*
tcache
)
{
}
TFileReader
*
tfileCacheGet
(
TFileCache
*
tcache
,
TFileCacheKey
*
key
)
{
char
buf
[
128
]
=
{
0
};
tfileSerialCacheKey
(
key
,
buf
);
TFileReader
*
reader
=
taosHashGet
(
tcache
->
tableCache
,
buf
,
strlen
(
buf
));
return
reader
;
}
void
tfileCachePut
(
TFileCache
*
tcache
,
TFileCacheKey
*
key
,
TFileReader
*
reader
)
{
char
buf
[
128
]
=
{
0
};
tfileSerialCacheKey
(
key
,
buf
);
taosHashPut
(
tcache
->
tableCache
,
buf
,
strlen
(
buf
),
&
reader
,
sizeof
(
void
*
));
return
;
}
IndexTFile
*
indexTFileCreate
()
{
IndexTFile
*
tfile
=
calloc
(
1
,
sizeof
(
IndexTFile
));
return
tfile
;
}
void
IndexTFileDestroy
(
IndexTFile
*
tfile
)
{
...
...
@@ -28,10 +86,20 @@ void IndexTFileDestroy(IndexTFile *tfile) {
int
indexTFileSearch
(
void
*
tfile
,
SIndexTermQuery
*
query
,
SArray
*
result
)
{
IndexTFile
*
ptfile
=
(
IndexTFile
*
)
tfile
;
return
0
;
}
int
indexTFilePut
(
void
*
tfile
,
SIndexTerm
*
term
,
uint64_t
uid
);
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
};
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录