Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a655dd2e
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
a655dd2e
编写于
12月 22, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update tindex write
上级
7d8e5c3a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
45 addition
and
13 deletion
+45
-13
source/libs/index/inc/index_fst_counting_writer.h
source/libs/index/inc/index_fst_counting_writer.h
+2
-0
source/libs/index/src/index_fst_counting_writer.c
source/libs/index/src/index_fst_counting_writer.c
+12
-0
source/libs/index/src/index_tfile.c
source/libs/index/src/index_tfile.c
+31
-13
未找到文件。
source/libs/index/inc/index_fst_counting_writer.h
浏览文件 @
a655dd2e
...
...
@@ -31,6 +31,7 @@ typedef struct WriterCtx {
int
(
*
write
)(
struct
WriterCtx
*
ctx
,
uint8_t
*
buf
,
int
len
);
int
(
*
read
)(
struct
WriterCtx
*
ctx
,
uint8_t
*
buf
,
int
len
);
int
(
*
flush
)(
struct
WriterCtx
*
ctx
);
int
(
*
readFrom
)(
struct
WriterCtx
*
ctx
,
uint8_t
*
buf
,
int
len
,
int32_t
offset
);
WriterType
type
;
union
{
struct
{
...
...
@@ -48,6 +49,7 @@ typedef struct WriterCtx {
static
int
writeCtxDoWrite
(
WriterCtx
*
ctx
,
uint8_t
*
buf
,
int
len
);
static
int
writeCtxDoRead
(
WriterCtx
*
ctx
,
uint8_t
*
buf
,
int
len
);
static
int
writeCtxDoReadFrom
(
WriterCtx
*
ctx
,
uint8_t
*
buf
,
int
len
,
int32_t
offset
);
static
int
writeCtxDoFlush
(
WriterCtx
*
ctx
);
WriterCtx
*
writerCtxCreate
(
WriterType
type
,
const
char
*
path
,
bool
readOnly
,
int32_t
capacity
);
...
...
source/libs/index/src/index_fst_counting_writer.c
浏览文件 @
a655dd2e
...
...
@@ -39,6 +39,17 @@ static int writeCtxDoRead(WriterCtx* ctx, uint8_t* buf, int len) {
return
nRead
;
}
static
int
writeCtxDoReadFrom
(
WriterCtx
*
ctx
,
uint8_t
*
buf
,
int
len
,
int32_t
offset
)
{
int
nRead
=
0
;
if
(
ctx
->
type
==
TFile
)
{
tfLseek
(
ctx
->
file
.
fd
,
offset
,
0
);
nRead
=
tfRead
(
ctx
->
file
.
fd
,
buf
,
len
);
}
else
{
// refactor later
assert
(
0
);
}
return
nRead
;
}
static
int
writeCtxDoFlush
(
WriterCtx
*
ctx
)
{
if
(
ctx
->
type
==
TFile
)
{
// tfFsync(ctx->fd);
...
...
@@ -73,6 +84,7 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int
ctx
->
write
=
writeCtxDoWrite
;
ctx
->
read
=
writeCtxDoRead
;
ctx
->
flush
=
writeCtxDoFlush
;
ctx
->
readFrom
=
writeCtxDoReadFrom
;
ctx
->
offset
=
0
;
ctx
->
limit
=
capacity
;
...
...
source/libs/index/src/index_tfile.c
浏览文件 @
a655dd2e
...
...
@@ -34,18 +34,18 @@ typedef struct TFileValue {
static
int
tfileValueCompare
(
const
void
*
a
,
const
void
*
b
,
const
void
*
param
);
static
void
tfileSerialTableIdsToBuf
(
char
*
buf
,
SArray
*
tableIds
);
static
int
tfileWriteFstOffset
(
TFileWriter
*
tw
,
int32_t
offset
);
static
int
tfileWriteHeader
(
TFileWriter
*
writer
);
static
int
tfileWriteFstOffset
(
TFileWriter
*
tw
,
int32_t
offset
);
static
int
tfileWriteData
(
TFileWriter
*
write
,
TFileValue
*
tval
);
static
int
tfileReadLoadHeader
(
TFileReader
*
reader
);
static
int
tfileReadLoadTableIds
(
TFileReader
*
reader
,
int32_t
offset
,
SArray
*
result
);
static
int
tfileGetFileList
(
const
char
*
path
,
SArray
*
result
);
static
void
tfileDestroyFileName
(
void
*
elem
);
static
int
tfileCompare
(
const
void
*
a
,
const
void
*
b
);
static
int
tfileParseFileName
(
const
char
*
filename
,
uint64_t
*
suid
,
int
*
colId
,
int
*
version
);
static
void
tfileSerialCacheKey
(
TFileCacheKey
*
key
,
char
*
buf
);
// static tfileGetCompareFunc(uint8_t byte) {}
TFileCache
*
tfileCacheCreate
(
const
char
*
path
)
{
TFileCache
*
tcache
=
calloc
(
1
,
sizeof
(
TFileCache
));
...
...
@@ -142,19 +142,22 @@ void tfileReaderDestroy(TFileReader* 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
))
{
//
return
tfileReadLoadTableIds
(
reader
,
offset
,
result
);
}
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
)
{
// handle later
//
//
}
else
{
// handle later
}
return
0
;
}
...
...
@@ -198,13 +201,10 @@ int tfileWriterPut(TFileWriter* tw, void* data) {
TFileValue
*
v
=
taosArrayGetP
((
SArray
*
)
data
,
i
);
int32_t
tbsz
=
taosArrayGetSize
(
v
->
tableId
);
int32_t
ttsz
=
TF_TABLE_TATOAL_SIZE
(
tbsz
);
fstOffset
+=
ttsz
;
fstOffset
+=
TF_TABLE_TATOAL_SIZE
(
tbsz
);
}
// check result or not
tfileWriteFstOffset
(
tw
,
fstOffset
);
// tw->ctx->header.fstOffset = fstOffset;
// tw->ctx->write(tw->ctx, &fstOffset, sizeof(fstOffset));
for
(
size_t
i
=
0
;
i
<
sz
;
i
++
)
{
TFileValue
*
v
=
taosArrayGetP
((
SArray
*
)
data
,
i
);
...
...
@@ -287,11 +287,11 @@ static int tfileValueCompare(const void* a, const void* b, const void* param) {
return
fn
(
av
->
colVal
,
bv
->
colVal
);
}
static
void
tfileSerialTableIdsToBuf
(
char
*
buf
,
SArray
*
tableI
ds
)
{
int
tbSz
=
taosArrayGetSize
(
tableI
ds
);
SERIALIZE_VAR_TO_BUF
(
buf
,
tbS
z
,
int32_t
);
for
(
size_t
i
=
0
;
i
<
tbS
z
;
i
++
)
{
uint64_t
*
v
=
taosArrayGet
(
tableI
ds
,
i
);
static
void
tfileSerialTableIdsToBuf
(
char
*
buf
,
SArray
*
i
ds
)
{
int
sz
=
taosArrayGetSize
(
i
ds
);
SERIALIZE_VAR_TO_BUF
(
buf
,
s
z
,
int32_t
);
for
(
size_t
i
=
0
;
i
<
s
z
;
i
++
)
{
uint64_t
*
v
=
taosArrayGet
(
i
ds
,
i
);
SERIALIZE_VAR_TO_BUF
(
buf
,
*
v
,
uint64_t
);
}
}
...
...
@@ -328,6 +328,7 @@ static int tfileWriteData(TFileWriter* write, TFileValue* tval) {
}
else
{
// handle other type later
}
return
0
;
}
static
int
tfileReadLoadHeader
(
TFileReader
*
reader
)
{
// TODO simple tfile header later
...
...
@@ -339,6 +340,23 @@ static int tfileReadLoadHeader(TFileReader* reader) {
memcpy
(
&
reader
->
header
,
buf
,
sizeof
(
buf
));
return
0
;
}
static
int
tfileReadLoadTableIds
(
TFileReader
*
reader
,
int32_t
offset
,
SArray
*
result
)
{
int32_t
nid
;
WriterCtx
*
ctx
=
reader
->
ctx
;
int32_t
nread
=
ctx
->
readFrom
(
ctx
,
(
char
*
)
&
nid
,
sizeof
(
nid
),
offset
);
assert
(
sizeof
(
nid
)
==
nread
);
char
*
buf
=
calloc
(
1
,
sizeof
(
uint64_t
)
*
nid
);
if
(
buf
==
NULL
)
{
return
-
1
;
}
nread
=
ctx
->
read
(
ctx
,
buf
,
sizeof
(
uint64_t
)
*
nid
);
uint64_t
*
ids
=
(
uint64_t
*
)
buf
;
for
(
int32_t
i
=
0
;
i
<
nid
;
i
++
)
{
taosArrayPush
(
result
,
ids
+
i
);
}
free
(
buf
);
return
0
;
}
static
int
tfileGetFileList
(
const
char
*
path
,
SArray
*
result
)
{
DIR
*
dir
=
opendir
(
path
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录