Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ac327389
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看板
提交
ac327389
编写于
5月 16, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix tag query error
上级
9453f80d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
101 addition
and
5 deletion
+101
-5
source/libs/index/src/indexComm.c
source/libs/index/src/indexComm.c
+2
-0
source/libs/index/src/indexFst.c
source/libs/index/src/indexFst.c
+1
-1
source/libs/index/src/indexTfile.c
source/libs/index/src/indexTfile.c
+4
-3
source/libs/index/test/jsonUT.cc
source/libs/index/test/jsonUT.cc
+94
-1
未找到文件。
source/libs/index/src/indexComm.c
浏览文件 @
ac327389
...
...
@@ -306,6 +306,7 @@ int32_t indexConvertDataToStr(void* src, int8_t type, void** dst) {
tlen
=
taosEncodeBinary
(
NULL
,
src
,
sizeof
(
float
));
*
dst
=
taosMemoryCalloc
(
1
,
tlen
+
1
);
tlen
=
taosEncodeBinary
(
dst
,
src
,
sizeof
(
float
));
*
dst
=
*
dst
-
tlen
;
break
;
case
TSDB_DATA_TYPE_UINT
:
*
dst
=
taosMemoryCalloc
(
1
,
sizeof
(
int64_t
)
+
1
);
...
...
@@ -319,6 +320,7 @@ int32_t indexConvertDataToStr(void* src, int8_t type, void** dst) {
tlen
=
taosEncodeBinary
(
NULL
,
src
,
sizeof
(
double
));
*
dst
=
taosMemoryCalloc
(
1
,
tlen
+
1
);
tlen
=
taosEncodeBinary
(
dst
,
src
,
sizeof
(
double
));
*
dst
=
*
dst
-
tlen
;
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
assert
(
0
);
...
...
source/libs/index/src/indexFst.c
浏览文件 @
ac327389
...
...
@@ -1324,7 +1324,7 @@ StreamWithStateResult* streamWithStateNextWith(StreamWithState* sws, StreamCallb
if
(
FST_NODE_ADDR
(
p
->
node
)
!=
fstGetRootAddr
(
sws
->
fst
))
{
taosArrayPop
(
sws
->
inp
);
}
streamStateDestroy
(
p
);
//
streamStateDestroy(p);
continue
;
}
FstTransition
trn
;
...
...
source/libs/index/src/indexTfile.c
浏览文件 @
ac327389
...
...
@@ -410,8 +410,9 @@ static int32_t tfSearchTerm_JSON(void* reader, SIndexTerm* tem, SIdxTempResult*
ret
=
tfileReaderLoadTableIds
((
TFileReader
*
)
reader
,
offset
,
tr
->
total
);
cost
=
taosGetTimestampUs
()
-
et
;
indexInfo
(
"index: %"
PRIu64
", col: %s, colVal: %s, load all table info, time cost: %"
PRIu64
"us"
,
tem
->
suid
,
tem
->
colName
,
tem
->
colVal
,
cost
);
indexInfo
(
"index: %"
PRIu64
", col: %s, colVal: %s, load all table info, offset: %"
PRIu64
", size: %d, time cost: %"
PRIu64
"us"
,
tem
->
suid
,
tem
->
colName
,
tem
->
colVal
,
offset
,
(
int
)
taosArrayGetSize
(
tr
->
total
),
cost
);
}
fstSliceDestroy
(
&
key
);
return
0
;
...
...
@@ -941,7 +942,7 @@ static int tfileReaderLoadTableIds(TFileReader* reader, int32_t offset, SArray*
// TODO(yihao): opt later
WriterCtx
*
ctx
=
reader
->
ctx
;
// add block cache
char
block
[
1024
]
=
{
0
};
char
block
[
4096
]
=
{
0
};
int32_t
nread
=
ctx
->
readFrom
(
ctx
,
block
,
sizeof
(
block
),
offset
);
assert
(
nread
>=
sizeof
(
uint32_t
));
...
...
source/libs/index/test/jsonUT.cc
浏览文件 @
ac327389
...
...
@@ -56,6 +56,29 @@ class JsonEnv : public ::testing::Test {
SIndexJson
*
index
;
};
static
void
WriteData
(
SIndexJson
*
index
,
const
std
::
string
&
colName
,
int8_t
dtype
,
void
*
data
,
int
dlen
,
int
tableId
,
int8_t
operType
=
ADD_VALUE
)
{
SIndexTerm
*
term
=
indexTermCreate
(
1
,
(
SIndexOperOnColumn
)
operType
,
dtype
,
colName
.
c_str
(),
colName
.
size
(),
(
const
char
*
)
data
,
dlen
);
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
tIndexJsonPut
(
index
,
terms
,
(
int64_t
)
tableId
);
indexMultiTermDestroy
(
terms
);
}
static
void
Search
(
SIndexJson
*
index
,
const
std
::
string
&
colNam
,
int8_t
dtype
,
void
*
data
,
int
dlen
,
int8_t
filterType
,
SArray
**
result
)
{
std
::
string
colName
(
colNam
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
dtype
,
colName
.
c_str
(),
colName
.
size
(),
(
const
char
*
)
data
,
dlen
);
SArray
*
res
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
(
EIndexQueryType
)
filterType
);
tIndexJsonSearch
(
index
,
mq
,
res
);
indexMultiTermQueryDestroy
(
mq
);
*
result
=
res
;
}
TEST_F
(
JsonEnv
,
testWrite
)
{
{
std
::
string
colName
(
"test"
);
...
...
@@ -329,7 +352,7 @@ TEST_F(JsonEnv, testWriteJsonNumberData) {
}
}
TEST_F
(
JsonEnv
,
testWriteJsonTfileAndCache
)
{
TEST_F
(
JsonEnv
,
testWriteJsonTfileAndCache
_INT
)
{
{
std
::
string
colName
(
"test1"
);
int
val
=
10
;
...
...
@@ -485,3 +508,73 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache) {
indexMultiTermQueryDestroy
(
mq
);
}
}
TEST_F
(
JsonEnv
,
testWriteJsonTfileAndCache_INT2
)
{
{
int
val
=
10
;
std
::
string
colName
(
"test1"
);
for
(
int
i
=
0
;
i
<
10000
;
i
++
)
{
val
+=
1
;
WriteData
(
index
,
colName
,
TSDB_DATA_TYPE_INT
,
&
val
,
sizeof
(
val
),
i
);
}
}
{
int
val
=
10
;
std
::
string
colName
(
"test2xxx"
);
std
::
string
colVal
(
"xxxxxxxxxxxxxxx"
);
for
(
int
i
=
0
;
i
<
100000
;
i
++
)
{
val
+=
1
;
WriteData
(
index
,
colName
,
TSDB_DATA_TYPE_BINARY
,
(
void
*
)(
colVal
.
c_str
()),
colVal
.
size
(),
i
);
}
}
{
SArray
*
res
=
NULL
;
std
::
string
colName
(
"test1"
);
int
val
=
9
;
Search
(
index
,
colName
,
TSDB_DATA_TYPE_INT
,
&
val
,
sizeof
(
val
),
QUERY_GREATER_EQUAL
,
&
res
);
EXPECT_EQ
(
10000
,
taosArrayGetSize
(
res
));
}
{
SArray
*
res
=
NULL
;
std
::
string
colName
(
"test2xxx"
);
std
::
string
colVal
(
"xxxxxxxxxxxxxxx"
);
Search
(
index
,
colName
,
TSDB_DATA_TYPE_BINARY
,
(
void
*
)(
colVal
.
c_str
()),
colVal
.
size
(),
QUERY_TERM
,
&
res
);
EXPECT_EQ
(
100000
,
taosArrayGetSize
(
res
));
}
}
TEST_F
(
JsonEnv
,
testWriteJsonTfileAndCache_FLOAT
)
{
{
float
val
=
10.0
;
std
::
string
colName
(
"test1"
);
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
WriteData
(
index
,
colName
,
TSDB_DATA_TYPE_FLOAT
,
&
val
,
sizeof
(
val
),
i
);
}
}
{
float
val
=
2.0
;
std
::
string
colName
(
"test1"
);
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
WriteData
(
index
,
colName
,
TSDB_DATA_TYPE_FLOAT
,
&
val
,
sizeof
(
val
),
i
);
}
}
{
SArray
*
res
=
NULL
;
std
::
string
colName
(
"test1"
);
float
val
=
1.9
;
Search
(
index
,
colName
,
TSDB_DATA_TYPE_FLOAT
,
&
val
,
sizeof
(
val
),
QUERY_GREATER_EQUAL
,
&
res
);
EXPECT_EQ
(
2000
,
taosArrayGetSize
(
res
));
}
{
SArray
*
res
=
NULL
;
std
::
string
colName
(
"test1"
);
float
val
=
2.1
;
Search
(
index
,
colName
,
TSDB_DATA_TYPE_FLOAT
,
&
val
,
sizeof
(
val
),
QUERY_GREATER_EQUAL
,
&
res
);
EXPECT_EQ
(
1000
,
taosArrayGetSize
(
res
));
}
{
std
::
string
colName
(
"test1"
);
SArray
*
res
=
NULL
;
float
val
=
2.1
;
Search
(
index
,
colName
,
TSDB_DATA_TYPE_FLOAT
,
&
val
,
sizeof
(
val
),
QUERY_GREATER_EQUAL
,
&
res
);
EXPECT_EQ
(
1000
,
taosArrayGetSize
(
res
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录