Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7a3d8568
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
7a3d8568
编写于
12月 20, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update index TFile write
上级
a0864b1c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
73 addition
and
48 deletion
+73
-48
source/libs/index/inc/index_util.h
source/libs/index/inc/index_util.h
+53
-0
source/libs/index/src/index_cache.c
source/libs/index/src/index_cache.c
+9
-21
source/libs/index/src/index_tfile.c
source/libs/index/src/index_tfile.c
+11
-27
未找到文件。
source/libs/index/inc/index_util.h
0 → 100644
浏览文件 @
7a3d8568
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __INDEX_UTIL_H__
#define __INDEX_UTIL_H__
#ifdef __cplusplus
extern
"C"
{
#endif
#define SERIALIZE_MEM_TO_BUF(buf, key, mem) \
do { \
memcpy((void *)buf, (void *)(&key->mem), sizeof(key->mem)); \
buf += sizeof(key->mem); \
} while (0)
#define SERIALIZE_STR_MEM_TO_BUF(buf, key, mem, len) \
do { \
memcpy((void *)buf, (void *)key->mem, len); \
buf += len; \
} while (0)
#define SERIALIZE_VAR_TO_BUF(buf, var, type) \
do { \
type c = var; \
assert(sizeof(var) == sizeof(type));\
memcpy((void *)buf, (void *)&c, sizeof(c)); \
buf += sizeof(c); \
} while (0)
#define SERIALIZE_STR_VAR_TO_BUF(buf, var, len) \
do { \
memcpy((void *)buf, (void *)var, len); \
buf += len;\
} while (0)
#ifdef __cplusplus
}
#endif
#endif
source/libs/index/src/index_cache.c
浏览文件 @
7a3d8568
...
...
@@ -15,6 +15,7 @@
#include "index_cache.h"
#include "tcompare.h"
#include "index_util.h"
#define MAX_INDEX_KEY_LEN 256// test only, change later
...
...
@@ -110,35 +111,22 @@ int indexCachePut(void *cache, SIndexTerm *term, int16_t colId, int32_t version,
if
(
cache
==
NULL
)
{
return
-
1
;}
IndexCache
*
pCache
=
cache
;
// encode data
int32_t
total
=
CACHE_KEY_LEN
(
term
);
char
*
buf
=
calloc
(
1
,
total
);
char
*
p
=
buf
;
memcpy
(
p
,
&
total
,
sizeof
(
total
));
p
+=
sizeof
(
total
);
memcpy
(
p
,
&
colId
,
sizeof
(
colId
));
p
+=
sizeof
(
colId
);
SERIALIZE_VAR_TO_BUF
(
p
,
total
,
int32_t
);
SERIALIZE_VAR_TO_BUF
(
p
,
colId
,
int16_t
);
memcpy
(
p
,
&
term
->
colType
,
sizeof
(
term
->
colType
));
p
+=
sizeof
(
term
->
colType
);
SERIALIZE_MEM_TO_BUF
(
p
,
term
,
colType
);
SERIALIZE_MEM_TO_BUF
(
p
,
term
,
nColVal
);
SERIALIZE_STR_MEM_TO_BUF
(
p
,
term
,
colVal
,
term
->
nColVal
);
memcpy
(
p
,
&
term
->
nColVal
,
sizeof
(
term
->
nColVal
));
p
+=
sizeof
(
term
->
nColVal
);
memcpy
(
p
,
term
->
colVal
,
term
->
nColVal
);
p
+=
term
->
nColVal
;
memcpy
(
p
,
&
version
,
sizeof
(
version
));
p
+=
sizeof
(
version
);
memcpy
(
p
,
&
uid
,
sizeof
(
uid
));
p
+=
sizeof
(
uid
);
SERIALIZE_VAR_TO_BUF
(
p
,
version
,
int32_t
);
SERIALIZE_VAR_TO_BUF
(
p
,
uid
,
uint64_t
);
memcpy
(
p
,
&
term
->
operType
,
sizeof
(
term
->
operType
));
p
+=
sizeof
(
term
->
operType
);
SERIALIZE_MEM_TO_BUF
(
p
,
term
,
operType
);
tSkipListPut
(
pCache
->
skiplist
,
(
void
*
)
buf
);
return
0
;
...
...
source/libs/index/src/index_tfile.c
浏览文件 @
7a3d8568
...
...
@@ -15,36 +15,18 @@
#include "index_tfile.h"
#include "index_fst.h"
#include "index_util.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
);
SERIALIZE_
MEM_
TO_BUF
(
buf
,
key
,
suid
);
SERIALIZE_
VAR_TO_BUF
(
buf
,
'_'
,
char
);
SERIALIZE_
MEM_
TO_BUF
(
buf
,
key
,
colType
);
SERIALIZE_
VAR_TO_BUF
(
buf
,
'_'
,
char
);
SERIALIZE_
MEM_
TO_BUF
(
buf
,
key
,
version
);
SERIALIZE_
VAR_TO_BUF
(
buf
,
'_'
,
char
);
SERIALIZE_STR_
MEM_TO_BUF
(
buf
,
key
,
colName
,
key
->
nColName
);
}
TFileCache
*
tfileCacheCreate
()
{
...
...
@@ -57,6 +39,8 @@ TFileCache *tfileCacheCreate() {
}
void
tfileCacheDestroy
(
TFileCache
*
tcache
)
{
free
(
tcache
);
}
TFileReader
*
tfileCacheGet
(
TFileCache
*
tcache
,
TFileCacheKey
*
key
)
{
...
...
@@ -86,7 +70,7 @@ 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
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录