Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d4c550db
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看板
提交
d4c550db
编写于
5月 10, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(query): add executor plan interface
上级
6c844c75
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
368 addition
and
105 deletion
+368
-105
source/libs/executor/test/executorTests.cpp
source/libs/executor/test/executorTests.cpp
+61
-57
source/libs/index/src/indexCache.c
source/libs/index/src/indexCache.c
+24
-22
source/libs/index/src/indexTfile.c
source/libs/index/src/indexTfile.c
+39
-18
source/libs/index/test/fstTest.cc
source/libs/index/test/fstTest.cc
+7
-8
source/libs/index/test/jsonUT.cc
source/libs/index/test/jsonUT.cc
+237
-0
未找到文件。
source/libs/executor/test/executorTests.cpp
浏览文件 @
d4c550db
...
...
@@ -23,34 +23,34 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "
tglobal
.h"
#include "
executor
.h"
#include "executorimpl.h"
#include "function.h"
#include "stub.h"
#include "taos.h"
#include "tdef.h"
#include "tvariant.h"
#include "tdatablock.h"
#include "trpc.h"
#include "stub.h"
#include "executor.h"
#include "tdef.h"
#include "tglobal.h"
#include "tmsg.h"
#include "tname.h"
#include "trpc.h"
#include "tvariant.h"
namespace
{
enum
{
data_rand
=
0x1
,
data_asc
=
0x2
,
data_asc
=
0x2
,
data_desc
=
0x3
,
};
typedef
struct
SDummyInputInfo
{
int32_t
totalPages
;
// numOfPages
int32_t
totalPages
;
// numOfPages
int32_t
current
;
int32_t
startVal
;
int32_t
type
;
int32_t
numOfRowsPerPage
;
int32_t
numOfCols
;
// number of columns
int32_t
numOfCols
;
// number of columns
int64_t
tsStart
;
SSDataBlock
*
pBlock
;
}
SDummyInputInfo
;
...
...
@@ -75,26 +75,26 @@ SSDataBlock* getDummyBlock(SOperatorInfo* pOperator) {
taosArrayPush
(
pInfo
->
pBlock
->
pDataBlock
,
&
colInfo
);
// SColumnInfoData colInfo1 = {0};
// colInfo1.info.type = TSDB_DATA_TYPE_BINARY;
// colInfo1.info.bytes = 40;
// colInfo1.info.colId = 2;
//
// colInfo1.varmeta.allocLen = 0;//numOfRows * sizeof(int32_t);
// colInfo1.varmeta.length = 0;
// colInfo1.varmeta.offset = static_cast<int32_t*>(taosMemoryCalloc(1, numOfRows * sizeof(int32_t)));
//
// taosArrayPush(pInfo->pBlock->pDataBlock, &colInfo1);
// SColumnInfoData colInfo1 = {0};
// colInfo1.info.type = TSDB_DATA_TYPE_BINARY;
// colInfo1.info.bytes = 40;
// colInfo1.info.colId = 2;
//
// colInfo1.varmeta.allocLen = 0;//numOfRows * sizeof(int32_t);
// colInfo1.varmeta.length = 0;
// colInfo1.varmeta.offset = static_cast<int32_t*>(taosMemoryCalloc(1, numOfRows * sizeof(int32_t)));
//
// taosArrayPush(pInfo->pBlock->pDataBlock, &colInfo1);
}
else
{
blockDataCleanup
(
pInfo
->
pBlock
);
}
SSDataBlock
*
pBlock
=
pInfo
->
pBlock
;
char
buf
[
128
]
=
{
0
};
char
b1
[
128
]
=
{
0
};
char
buf
[
128
]
=
{
0
};
char
b1
[
128
]
=
{
0
};
int32_t
v
=
0
;
for
(
int32_t
i
=
0
;
i
<
pInfo
->
numOfRowsPerPage
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInfo
->
numOfRowsPerPage
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
static_cast
<
SColumnInfoData
*>
(
TARRAY_GET_ELEM
(
pBlock
->
pDataBlock
,
0
));
if
(
pInfo
->
type
==
data_desc
)
{
...
...
@@ -107,11 +107,11 @@ SSDataBlock* getDummyBlock(SOperatorInfo* pOperator) {
colDataAppend
(
pColInfo
,
i
,
reinterpret_cast
<
const
char
*>
(
&
v
),
false
);
// sprintf(buf, "this is %d row", i);
// STR_TO_VARSTR(b1, buf);
//
// SColumnInfoData* pColInfo2 = static_cast<SColumnInfoData*>(TARRAY_GET_ELEM(pBlock->pDataBlock, 1));
// colDataAppend(pColInfo2, i, b1, false);
// sprintf(buf, "this is %d row", i);
// STR_TO_VARSTR(b1, buf);
//
// SColumnInfoData* pColInfo2 = static_cast<SColumnInfoData*>(TARRAY_GET_ELEM(pBlock->pDataBlock, 1));
// colDataAppend(pColInfo2, i, b1, false);
}
pBlock
->
info
.
rows
=
pInfo
->
numOfRowsPerPage
;
...
...
@@ -137,7 +137,7 @@ SSDataBlock* get2ColsDummyBlock(SOperatorInfo* pOperator) {
colInfo
.
info
.
bytes
=
sizeof
(
int64_t
);
colInfo
.
info
.
colId
=
1
;
colInfo
.
pData
=
static_cast
<
char
*>
(
taosMemoryCalloc
(
pInfo
->
numOfRowsPerPage
,
sizeof
(
int64_t
)));
// colInfo.nullbitmap = static_cast<char*>(taosMemoryCalloc(1, (pInfo->numOfRowsPerPage + 7) / 8));
// colInfo.nullbitmap = static_cast<char*>(taosMemoryCalloc(1, (pInfo->numOfRowsPerPage + 7) / 8));
taosArrayPush
(
pInfo
->
pBlock
->
pDataBlock
,
&
colInfo
);
...
...
@@ -156,11 +156,11 @@ SSDataBlock* get2ColsDummyBlock(SOperatorInfo* pOperator) {
SSDataBlock
*
pBlock
=
pInfo
->
pBlock
;
char
buf
[
128
]
=
{
0
};
char
b1
[
128
]
=
{
0
};
char
buf
[
128
]
=
{
0
};
char
b1
[
128
]
=
{
0
};
int64_t
ts
=
0
;
int32_t
v
=
0
;
for
(
int32_t
i
=
0
;
i
<
pInfo
->
numOfRowsPerPage
;
++
i
)
{
int32_t
v
=
0
;
for
(
int32_t
i
=
0
;
i
<
pInfo
->
numOfRowsPerPage
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
static_cast
<
SColumnInfoData
*>
(
TARRAY_GET_ELEM
(
pBlock
->
pDataBlock
,
0
));
ts
=
(
++
pInfo
->
tsStart
);
...
...
@@ -177,11 +177,11 @@ SSDataBlock* get2ColsDummyBlock(SOperatorInfo* pOperator) {
colDataAppend
(
pColInfo1
,
i
,
reinterpret_cast
<
const
char
*>
(
&
v
),
false
);
// sprintf(buf, "this is %d row", i);
// STR_TO_VARSTR(b1, buf);
//
// SColumnInfoData* pColInfo2 = static_cast<SColumnInfoData*>(TARRAY_GET_ELEM(pBlock->pDataBlock, 1));
// colDataAppend(pColInfo2, i, b1, false);
// sprintf(buf, "this is %d row", i);
// STR_TO_VARSTR(b1, buf);
//
// SColumnInfoData* pColInfo2 = static_cast<SColumnInfoData*>(TARRAY_GET_ELEM(pBlock->pDataBlock, 1));
// colDataAppend(pColInfo2, i, b1, false);
}
pBlock
->
info
.
rows
=
pInfo
->
numOfRowsPerPage
;
...
...
@@ -191,10 +191,10 @@ SSDataBlock* get2ColsDummyBlock(SOperatorInfo* pOperator) {
blockDataUpdateTsWindow
(
pBlock
);
return
pBlock
;
}
SOperatorInfo
*
createDummyOperator
(
int32_t
startVal
,
int32_t
numOfBlocks
,
int32_t
rowsPerPage
,
int32_t
type
,
int32_t
numOfCols
)
{
SOperatorInfo
*
createDummyOperator
(
int32_t
startVal
,
int32_t
numOfBlocks
,
int32_t
rowsPerPage
,
int32_t
type
,
int32_t
numOfCols
)
{
SOperatorInfo
*
pOperator
=
static_cast
<
SOperatorInfo
*>
(
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
)));
pOperator
->
name
=
"dummyInputOpertor4Test"
;
...
...
@@ -204,24 +204,25 @@ SOperatorInfo* createDummyOperator(int32_t startVal, int32_t numOfBlocks, int32_
pOperator
->
fpSet
.
getNextFn
=
get2ColsDummyBlock
;
}
SDummyInputInfo
*
pInfo
=
(
SDummyInputInfo
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SDummyInputInfo
));
SDummyInputInfo
*
pInfo
=
(
SDummyInputInfo
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SDummyInputInfo
));
pInfo
->
totalPages
=
numOfBlocks
;
pInfo
->
startVal
=
startVal
;
pInfo
->
startVal
=
startVal
;
pInfo
->
numOfRowsPerPage
=
rowsPerPage
;
pInfo
->
type
=
type
;
pInfo
->
tsStart
=
1620000000000
;
pInfo
->
type
=
type
;
pInfo
->
tsStart
=
1620000000000
;
pOperator
->
info
=
pInfo
;
return
pOperator
;
}
}
}
// namespace
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
TEST
(
testCase
,
build_executor_tree_Test
)
{
const
char
*
msg
=
"{
\n
"
const
char
*
msg
=
"{
\n
"
"
\"
NodeType
\"
:
\"
48
\"
,
\n
"
"
\"
Name
\"
:
\"
PhysiSubplan
\"
,
\n
"
"
\"
PhysiSubplan
\"
: {
\n
"
...
...
@@ -938,16 +939,19 @@ TEST(testCase, build_executor_tree_Test) {
SExecTaskInfo
*
pTaskInfo
=
nullptr
;
DataSinkHandle
sinkHandle
=
nullptr
;
SReadHandle
handle
=
{
reinterpret_cast
<
void
*>
(
0x1
),
reinterpret_cast
<
void
*>
(
0x1
),
NULL
};
SReadHandle
handle
=
{
reinterpret_cast
<
void
*>
(
0x1
),
reinterpret_cast
<
void
*>
(
0x1
),
NULL
};
struct
SSubplan
*
plan
=
NULL
;
int32_t
code
=
qStringToSubplan
(
msg
,
&
plan
);
struct
SSubplan
*
plan
=
NULL
;
int32_t
code
=
qStringToSubplan
(
msg
,
&
plan
);
ASSERT_EQ
(
code
,
0
);
code
=
qCreateExecTask
(
&
handle
,
2
,
1
,
plan
,
(
void
**
)
&
pTaskInfo
,
&
sinkHandle
,
OPTR_EXEC_MODEL_BATCH
);
code
=
qCreateExecTask
(
&
handle
,
2
,
1
,
plan
,
(
void
**
)
&
pTaskInfo
,
&
sinkHandle
,
OPTR_EXEC_MODEL_BATCH
);
ASSERT_EQ
(
code
,
0
);
}
TEST
(
testCase
,
index_plan_test
)
{
// add later
EXPECT_EQ
(
0
,
0
);
}
#if 0
TEST(testCase, inMem_sort_Test) {
...
...
@@ -983,19 +987,19 @@ TEST(testCase, inMem_sort_Test) {
typedef
struct
su
{
int32_t
v
;
char
*
c
;
char
*
c
;
}
su
;
int32_t
cmp
(
const
void
*
p1
,
const
void
*
p2
)
{
su
*
v1
=
(
su
*
)
p1
;
su
*
v2
=
(
su
*
)
p2
;
su
*
v1
=
(
su
*
)
p1
;
su
*
v2
=
(
su
*
)
p2
;
int32_t
x1
=
*
(
int32_t
*
)
v1
->
c
;
int32_t
x2
=
*
(
int32_t
*
)
v2
->
c
;
int32_t
x1
=
*
(
int32_t
*
)
v1
->
c
;
int32_t
x2
=
*
(
int32_t
*
)
v2
->
c
;
if
(
x1
==
x2
)
{
return
0
;
}
else
{
return
x1
<
x2
?
-
1
:
1
;
return
x1
<
x2
?
-
1
:
1
;
}
}
...
...
@@ -1228,4 +1232,4 @@ TEST(testCase, time_interval_Operator_Test) {
}
#endif
#pragma GCC diagnosti
\ No newline at end of file
#pragma GCC diagnosti
source/libs/index/src/indexCache.c
浏览文件 @
d4c550db
...
...
@@ -278,9 +278,9 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTe
break
;
}
CacheTerm
*
c
=
(
CacheTerm
*
)
SL_GET_NODE_DATA
(
node
);
printf
(
"json val: %s
\n
"
,
c
->
colVal
);
if
(
0
!=
strncmp
(
c
->
colVal
,
term
->
colName
,
term
->
nColName
))
{
continue
;
//
printf("json val: %s\n", c->colVal);
if
(
0
!=
strncmp
(
c
->
colVal
,
pCt
->
colVal
,
skip
))
{
break
;
}
TExeCond
cond
=
cmpFn
(
c
->
colVal
+
skip
,
term
->
colVal
,
dType
);
...
...
@@ -640,30 +640,30 @@ static int indexFindCh(char* a, char c) {
return
p
-
a
;
}
static
int
indexCacheJsonTermCompareImpl
(
char
*
a
,
char
*
b
)
{
int
alen
=
indexFindCh
(
a
,
'&'
);
int
blen
=
indexFindCh
(
b
,
'&'
);
int
cmp
=
strncmp
(
a
,
b
,
MIN
(
alen
,
blen
));
if
(
cmp
==
0
)
{
cmp
=
alen
-
blen
;
if
(
cmp
!=
0
)
{
return
cmp
;
}
cmp
=
*
(
a
+
alen
)
-
*
(
b
+
blen
);
if
(
cmp
!=
0
)
{
return
cmp
;
}
alen
+=
2
;
blen
+=
2
;
cmp
=
strcmp
(
a
+
alen
,
b
+
blen
);
}
return
cmp
;
//
int alen = indexFindCh(a, '&');
//
int blen = indexFindCh(b, '&');
//
int cmp = strncmp(a, b, MIN(alen, blen));
//
if (cmp == 0) {
//
cmp = alen - blen;
//
if (cmp != 0) {
//
return cmp;
//
}
//
cmp = *(a + alen) - *(b + blen);
//
if (cmp != 0) {
//
return cmp;
//
}
//
alen += 2;
//
blen += 2;
//
cmp = strcmp(a + alen, b + blen);
//
}
return
0
;
}
static
int32_t
indexCacheJsonTermCompare
(
const
void
*
l
,
const
void
*
r
)
{
CacheTerm
*
lt
=
(
CacheTerm
*
)
l
;
CacheTerm
*
rt
=
(
CacheTerm
*
)
r
;
// compare colVal
int
cmp
=
indexCacheJsonTermCompareImpl
(
lt
->
colVal
,
rt
->
colVal
);
int
32_t
cmp
=
strcmp
(
lt
->
colVal
,
rt
->
colVal
);
if
(
cmp
==
0
)
{
return
rt
->
version
-
lt
->
version
;
}
...
...
@@ -704,6 +704,8 @@ static bool indexCacheIteratorNext(Iterate* itera) {
iv
->
type
=
ct
->
operaType
;
iv
->
ver
=
ct
->
version
;
iv
->
colVal
=
tstrdup
(
ct
->
colVal
);
// printf("col Val: %s\n", iv->colVal);
// iv->colType = cv->colType;
taosArrayPush
(
iv
->
val
,
&
ct
->
uid
);
}
...
...
source/libs/index/src/indexTfile.c
浏览文件 @
d4c550db
...
...
@@ -334,7 +334,12 @@ static int32_t tfSearchCompareFunc(void* reader, SIndexTerm* tem, SIdxTempResult
while
((
rt
=
streamWithStateNextWith
(
st
,
NULL
))
!=
NULL
)
{
FstSlice
*
s
=
&
rt
->
data
;
char
*
ch
=
(
char
*
)
fstSliceData
(
s
,
NULL
);
TExeCond
cond
=
cmpFn
(
ch
,
p
,
tem
->
colType
);
// if (0 != strncmp(ch, tem->colName, tem->nColName)) {
// swsResultDestroy(rt);
// break;
//}
TExeCond
cond
=
cmpFn
(
ch
,
p
,
tem
->
colType
);
if
(
MATCH
==
cond
)
{
tfileReaderLoadTableIds
((
TFileReader
*
)
reader
,
rt
->
out
.
out
,
tr
->
total
);
}
else
if
(
CONTINUE
==
cond
)
{
...
...
@@ -455,16 +460,22 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTempR
AutomationCtx
*
ctx
=
automCtxCreate
((
void
*
)
p
,
AUTOMATION_PREFIX
);
FstStreamBuilder
*
sb
=
fstSearch
(((
TFileReader
*
)
reader
)
->
fst
,
ctx
);
FstSlice
h
=
fstSliceCreate
((
uint8_t
*
)
p
,
skip
);
fstStreamBuilderSetRange
(
sb
,
&
h
,
ctype
);
fstSliceDestroy
(
&
h
);
//
FstSlice h = fstSliceCreate((uint8_t*)p, skip);
//
fstStreamBuilderSetRange(sb, &h, ctype);
//
fstSliceDestroy(&h);
StreamWithState
*
st
=
streamBuilderIntoStream
(
sb
);
StreamWithStateResult
*
rt
=
NULL
;
while
((
rt
=
streamWithStateNextWith
(
st
,
NULL
))
!=
NULL
)
{
FstSlice
*
s
=
&
rt
->
data
;
char
*
ch
=
(
char
*
)
fstSliceData
(
s
,
NULL
);
TExeCond
cond
=
cmpFn
(
ch
,
p
,
tem
->
colType
);
char
*
ch
=
(
char
*
)
fstSliceData
(
s
,
NULL
);
if
(
0
!=
strncmp
(
ch
,
p
,
skip
))
{
swsResultDestroy
(
rt
);
break
;
}
TExeCond
cond
=
cmpFn
(
ch
+
skip
,
tem
->
colVal
,
tem
->
colType
);
if
(
MATCH
==
cond
)
{
tfileReaderLoadTableIds
((
TFileReader
*
)
reader
,
rt
->
out
.
out
,
tr
->
total
);
}
else
if
(
CONTINUE
==
cond
)
{
...
...
@@ -594,13 +605,16 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) {
if
(
tfileWriteData
(
tw
,
v
)
!=
0
)
{
indexError
(
"failed to write data: %s, offset: %d len: %d"
,
v
->
colVal
,
v
->
offset
,
(
int
)
taosArrayGetSize
(
v
->
tableId
));
// printf("write faile\n");
}
else
{
// printf("write sucee\n");
// indexInfo("success to write data: %s, offset: %d len: %d", v->colVal, v->offset,
// (int)taosArrayGetSize(v->tableId));
// indexInfo("tfile write data size: %d", tw->ctx->size(tw->ctx));
}
}
fstBuilderFinish
(
tw
->
fb
);
fstBuilderDestroy
(
tw
->
fb
);
tw
->
fb
=
NULL
;
...
...
@@ -845,18 +859,24 @@ static int tfileWriteData(TFileWriter* write, TFileValue* tval) {
uint8_t
colType
=
header
->
colType
;
colType
=
INDEX_TYPE_GET_TYPE
(
colType
);
if
(
colType
==
TSDB_DATA_TYPE_BINARY
||
colType
==
TSDB_DATA_TYPE_NCHAR
)
{
FstSlice
key
=
fstSliceCreate
((
uint8_t
*
)(
tval
->
colVal
),
(
size_t
)
strlen
(
tval
->
colVal
));
if
(
fstBuilderInsert
(
write
->
fb
,
key
,
tval
->
offset
))
{
fstSliceDestroy
(
&
key
);
return
0
;
}
FstSlice
key
=
fstSliceCreate
((
uint8_t
*
)(
tval
->
colVal
),
(
size_t
)
strlen
(
tval
->
colVal
));
if
(
fstBuilderInsert
(
write
->
fb
,
key
,
tval
->
offset
))
{
fstSliceDestroy
(
&
key
);
return
-
1
;
}
else
{
// handle other type later
return
0
;
}
return
0
;
return
-
1
;
// if (colType == TSDB_DATA_TYPE_BINARY || colType == TSDB_DATA_TYPE_NCHAR) {
// FstSlice key = fstSliceCreate((uint8_t*)(tval->colVal), (size_t)strlen(tval->colVal));
// if (fstBuilderInsert(write->fb, key, tval->offset)) {
// fstSliceDestroy(&key);
// return 0;
// }
// fstSliceDestroy(&key);
// return -1;
//} else {
// // handle other type later
//}
}
static
int
tfileWriteFooter
(
TFileWriter
*
write
)
{
char
buf
[
sizeof
(
tfileMagicNumber
)
+
1
]
=
{
0
};
...
...
@@ -913,8 +933,9 @@ static int tfileReaderLoadFst(TFileReader* reader) {
static
int
tfileReaderLoadTableIds
(
TFileReader
*
reader
,
int32_t
offset
,
SArray
*
result
)
{
// TODO(yihao): opt later
WriterCtx
*
ctx
=
reader
->
ctx
;
char
block
[
1024
]
=
{
0
};
int32_t
nread
=
ctx
->
readFrom
(
ctx
,
block
,
sizeof
(
block
),
offset
);
// add block cache
char
block
[
1024
]
=
{
0
};
int32_t
nread
=
ctx
->
readFrom
(
ctx
,
block
,
sizeof
(
block
),
offset
);
assert
(
nread
>=
sizeof
(
uint32_t
));
char
*
p
=
block
;
...
...
source/libs/index/test/fstTest.cc
浏览文件 @
d4c550db
...
...
@@ -272,9 +272,8 @@ void checkFstCheckIterator1() {
std
::
cout
<<
"insert data count : "
<<
count
<<
"elapas time: "
<<
e
-
s
<<
std
::
endl
;
fw
->
Put
(
"Hello world"
,
1
);
fw
->
Put
(
"Hello worle"
,
2
);
fw
->
Put
(
"hello worlf"
,
4
);
fw
->
Put
(
"test1&^D&10"
,
1
);
fw
->
Put
(
"test2&^D&10"
,
2
);
delete
fw
;
FstReadMemory
*
m
=
new
FstReadMemory
(
1024
*
64
);
...
...
@@ -645,11 +644,11 @@ int main(int argc, char* argv[]) {
// iterTFileReader(argv[1], argv[2], argv[3], argv[4]);
//}
checkFstCheckIterator1
();
checkFstCheckIterator2
();
checkFstCheckIteratorPrefix
();
checkFstCheckIteratorRange1
();
checkFstCheckIteratorRange2
();
checkFstCheckIteratorRange3
();
//
checkFstCheckIterator2();
//
checkFstCheckIteratorPrefix();
//
checkFstCheckIteratorRange1();
//
checkFstCheckIteratorRange2();
//
checkFstCheckIteratorRange3();
// checkFstLongTerm();
// checkFstPrefixSearch();
...
...
source/libs/index/test/jsonUT.cc
浏览文件 @
d4c550db
...
...
@@ -181,3 +181,240 @@ TEST_F(JsonEnv, testWriteMillonData) {
}
}
}
TEST_F
(
JsonEnv
,
testWriteJsonNumberData
)
{
{
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"10"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
1000
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"test2"
);
std
::
string
colVal
(
"20"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
1000
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"test2"
);
std
::
string
colVal
(
"15"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
1000
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"test2"
);
std
::
string
colVal
(
"15"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
1000
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"10"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_TERM
);
tIndexJsonSearch
(
index
,
mq
,
result
);
EXPECT_EQ
(
1000
,
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
{
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"10"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_GREATER_THAN
);
tIndexJsonSearch
(
index
,
mq
,
result
);
EXPECT_EQ
(
0
,
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
{
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"10"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_GREATER_EQUAL
);
tIndexJsonSearch
(
index
,
mq
,
result
);
EXPECT_EQ
(
1000
,
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
{
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"10"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_LESS_THAN
);
tIndexJsonSearch
(
index
,
mq
,
result
);
EXPECT_EQ
(
0
,
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
{
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"10"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_LESS_EQUAL
);
tIndexJsonSearch
(
index
,
mq
,
result
);
EXPECT_EQ
(
1000
,
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
}
TEST_F
(
JsonEnv
,
testWriteJsonTfileAndCache
)
{
{
std
::
string
colName
(
"test1"
);
std
::
string
colVal
(
"10"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
1000
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"xxxxxxxxxxxxxxxxxxx"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
100000
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"test1"
);
std
::
string
colVal
(
"10"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_TERM
);
tIndexJsonSearch
(
index
,
mq
,
result
);
EXPECT_EQ
(
1000
,
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
{
std
::
string
colName
(
"test1"
);
std
::
string
colVal
(
"10"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_GREATER_THAN
);
tIndexJsonSearch
(
index
,
mq
,
result
);
EXPECT_EQ
(
0
,
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
{
std
::
string
colName
(
"test1"
);
std
::
string
colVal
(
"10"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_GREATER_EQUAL
);
tIndexJsonSearch
(
index
,
mq
,
result
);
EXPECT_EQ
(
1000
,
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
{
std
::
string
colName
(
"test1"
);
std
::
string
colVal
(
"10"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_GREATER_THAN
);
tIndexJsonSearch
(
index
,
mq
,
result
);
EXPECT_EQ
(
0
,
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
{
std
::
string
colName
(
"test1"
);
std
::
string
colVal
(
"10"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_LESS_EQUAL
);
tIndexJsonSearch
(
index
,
mq
,
result
);
EXPECT_EQ
(
1000
,
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
{
std
::
string
colName
(
"test1"
);
std
::
string
colVal
(
"10"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_LESS_THAN
);
tIndexJsonSearch
(
index
,
mq
,
result
);
EXPECT_EQ
(
0
,
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录