Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e8a63769
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
e8a63769
编写于
5月 15, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(index): fix tag query error
上级
54d0e3c3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
148 addition
and
39 deletion
+148
-39
source/libs/index/inc/indexComm.h
source/libs/index/inc/indexComm.h
+6
-0
source/libs/index/src/indexCache.c
source/libs/index/src/indexCache.c
+4
-1
source/libs/index/src/indexComm.c
source/libs/index/src/indexComm.c
+92
-38
source/libs/index/test/.utilUT.cc.swn
source/libs/index/test/.utilUT.cc.swn
+0
-0
source/libs/index/test/jsonUT.cc
source/libs/index/test/jsonUT.cc
+28
-0
source/libs/index/test/utilUT.cc
source/libs/index/test/utilUT.cc
+18
-0
未找到文件。
source/libs/index/inc/indexComm.h
浏览文件 @
e8a63769
...
...
@@ -39,6 +39,12 @@ _cache_range_compare indexGetCompare(RangeType ty);
int32_t
indexConvertData
(
void
*
src
,
int8_t
type
,
void
**
dst
);
int32_t
indexGetDataByteLen
(
int8_t
type
);
int32_t
indexMayFillNumbericData
(
void
*
number
,
int32_t
tlen
);
int32_t
indexMayUnfillNumbericData
(
void
*
number
,
int32_t
tlen
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/index/src/indexCache.c
浏览文件 @
e8a63769
...
...
@@ -282,8 +282,10 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTe
if
(
0
!=
strncmp
(
c
->
colVal
,
pCt
->
colVal
,
skip
))
{
break
;
}
char
*
p
=
taosMemoryCalloc
(
1
,
strlen
(
c
->
colVal
)
+
1
);
memcpy
(
p
,
c
->
colVal
,
strlen
(
c
->
colVal
));
TExeCond
cond
=
cmpFn
(
c
->
colVal
+
skip
,
term
->
colVal
,
dType
);
TExeCond
cond
=
cmpFn
(
p
+
skip
,
term
->
colVal
,
dType
);
if
(
cond
==
MATCH
)
{
if
(
c
->
operaType
==
ADD_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
deled
,
tr
->
added
,
c
->
uid
)
...
...
@@ -297,6 +299,7 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTe
}
else
if
(
cond
==
BREAK
)
{
break
;
}
taosMemoryFree
(
p
);
}
taosMemoryFree
(
pCt
);
...
...
source/libs/index/src/indexComm.c
浏览文件 @
e8a63769
...
...
@@ -31,44 +31,34 @@ static __compar_fn_t indexGetCompar(int8_t type) {
}
static
TExeCond
tCompareLessThan
(
void
*
a
,
void
*
b
,
int8_t
type
)
{
__compar_fn_t
func
=
indexGetCompar
(
type
);
int32_t
tlen
=
indexGetDataByteLen
(
type
);
indexMayUnfillNumbericData
(
a
,
tlen
);
indexMayUnfillNumbericData
(
b
,
tlen
);
return
tDoCommpare
(
func
,
QUERY_LESS_THAN
,
a
,
b
);
}
static
TExeCond
tCompareLessEqual
(
void
*
a
,
void
*
b
,
int8_t
type
)
{
__compar_fn_t
func
=
indexGetCompar
(
type
);
int32_t
tlen
=
indexGetDataByteLen
(
type
);
indexMayUnfillNumbericData
(
a
,
tlen
);
indexMayUnfillNumbericData
(
b
,
tlen
);
return
tDoCommpare
(
func
,
QUERY_LESS_EQUAL
,
a
,
b
);
}
static
TExeCond
tCompareGreaterThan
(
void
*
a
,
void
*
b
,
int8_t
type
)
{
__compar_fn_t
func
=
indexGetCompar
(
type
);
if
(
type
==
TSDB_DATA_TYPE_INT
)
{
char
*
v1
=
(
char
*
)
a
;
char
*
v2
=
(
char
*
)
b
;
for
(
int
i
=
0
;
i
<
sizeof
(
int32_t
);
i
++
)
{
if
(
v1
[
i
]
==
'0'
)
{
v1
[
i
]
=
0
;
}
if
(
v2
[
i
]
==
'0'
)
{
v2
[
i
]
=
0
;
}
}
return
tDoCommpare
(
func
,
QUERY_GREATER_THAN
,
v1
,
v2
);
}
int32_t
tlen
=
indexGetDataByteLen
(
type
);
indexMayUnfillNumbericData
(
a
,
tlen
);
indexMayUnfillNumbericData
(
b
,
tlen
);
return
tDoCommpare
(
func
,
QUERY_GREATER_THAN
,
a
,
b
);
}
static
TExeCond
tCompareGreaterEqual
(
void
*
a
,
void
*
b
,
int8_t
type
)
{
__compar_fn_t
func
=
indexGetCompar
(
type
);
if
(
type
==
TSDB_DATA_TYPE_INT
)
{
char
*
v1
=
(
char
*
)
a
;
char
*
v2
=
(
char
*
)
b
;
for
(
int
i
=
0
;
i
<
sizeof
(
int32_t
);
i
++
)
{
if
(
v1
[
i
]
==
'0'
)
{
v1
[
i
]
=
0
;
}
if
(
v2
[
i
]
==
'0'
)
{
v2
[
i
]
=
0
;
}
}
return
tDoCommpare
(
func
,
QUERY_GREATER_EQUAL
,
v1
,
v2
);
}
int32_t
tlen
=
indexGetDataByteLen
(
type
);
indexMayUnfillNumbericData
(
a
,
tlen
);
indexMayUnfillNumbericData
(
b
,
tlen
);
return
tDoCommpare
(
func
,
QUERY_GREATER_EQUAL
,
a
,
b
);
}
...
...
@@ -200,9 +190,9 @@ int32_t indexConvertData(void* src, int8_t type, void** dst) {
tlen
=
taosEncodeFixedU32
(
dst
,
*
(
uint32_t
*
)
src
);
break
;
case
TSDB_DATA_TYPE_BIGINT
:
tlen
=
taosEncodeFixedI64
(
NULL
,
*
(
uint32
_t
*
)
src
);
tlen
=
taosEncodeFixedI64
(
NULL
,
*
(
int64
_t
*
)
src
);
*
dst
=
taosMemoryCalloc
(
1
,
tlen
+
1
);
tlen
=
taosEncodeFixedI64
(
dst
,
*
(
uint32
_t
*
)
src
);
tlen
=
taosEncodeFixedI64
(
dst
,
*
(
int64
_t
*
)
src
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
tlen
=
taosEncodeBinary
(
NULL
,
src
,
sizeof
(
double
));
...
...
@@ -210,9 +200,9 @@ int32_t indexConvertData(void* src, int8_t type, void** dst) {
tlen
=
taosEncodeBinary
(
dst
,
src
,
sizeof
(
double
));
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
tlen
=
taosEncodeFixedU64
(
NULL
,
*
(
uint
32
_t
*
)
src
);
tlen
=
taosEncodeFixedU64
(
NULL
,
*
(
uint
64
_t
*
)
src
);
*
dst
=
taosMemoryCalloc
(
1
,
tlen
+
1
);
tlen
=
taosEncodeFixedU64
(
dst
,
*
(
uint
32
_t
*
)
src
);
tlen
=
taosEncodeFixedU64
(
dst
,
*
(
uint
64
_t
*
)
src
);
break
;
case
TSDB_DATA_TYPE_NCHAR
:
{
tlen
=
taosEncodeBinary
(
NULL
,
varDataVal
(
src
),
varDataLen
(
src
));
...
...
@@ -241,14 +231,78 @@ int32_t indexConvertData(void* src, int8_t type, void** dst) {
break
;
}
*
dst
=
*
dst
-
tlen
;
if
(
type
!=
TSDB_DATA_TYPE_BINARY
&&
type
!=
TSDB_DATA_TYPE_NCHAR
&&
type
!=
TSDB_DATA_TYPE_VARBINARY
&&
type
!=
TSDB_DATA_TYPE_VARCHAR
)
{
uint8_t
*
p
=
*
dst
;
for
(
int
i
=
0
;
i
<
tlen
;
i
++
)
{
if
(
p
[
i
]
==
0
)
{
p
[
i
]
=
(
uint8_t
)
'0'
;
}
}
indexMayFillNumbericData
(
*
dst
,
tlen
);
// if (type != TSDB_DATA_TYPE_BINARY && type != TSDB_DATA_TYPE_NCHAR && type != TSDB_DATA_TYPE_VARBINARY &&
// type != TSDB_DATA_TYPE_VARCHAR) { uint8_t* p = *dst;
// for (int i = 0; i < tlen; i++) {
// if (p[i] == 0) {
// p[i] = (uint8_t)'0';
// }
// }
//}
return
tlen
;
}
int32_t
indexGetDataByteLen
(
int8_t
type
)
{
int32_t
tlen
=
-
1
;
switch
(
type
)
{
case
TSDB_DATA_TYPE_TIMESTAMP
:
tlen
=
sizeof
(
int64_t
);
break
;
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_UTINYINT
:
tlen
=
sizeof
(
uint8_t
);
break
;
case
TSDB_DATA_TYPE_TINYINT
:
tlen
=
sizeof
(
uint8_t
);
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
tlen
=
sizeof
(
int16_t
);
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
tlen
=
sizeof
(
uint16_t
);
break
;
case
TSDB_DATA_TYPE_INT
:
tlen
=
sizeof
(
int32_t
);
break
;
case
TSDB_DATA_TYPE_UINT
:
tlen
=
sizeof
(
uint32_t
);
break
;
case
TSDB_DATA_TYPE_BIGINT
:
tlen
=
sizeof
(
int64_t
);
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
tlen
=
sizeof
(
uint64_t
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
tlen
=
sizeof
(
float
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
tlen
=
sizeof
(
double
);
break
;
default:
break
;
}
return
tlen
;
}
int32_t
indexMayFillNumbericData
(
void
*
number
,
int32_t
tlen
)
{
for
(
int
i
=
0
;
i
<
tlen
;
i
++
)
{
int8_t
*
p
=
number
;
if
(
p
[
i
]
==
0
)
{
p
[
i
]
=
(
uint8_t
)
'0'
;
}
}
return
0
;
}
int32_t
indexMayUnfillNumbericData
(
void
*
number
,
int32_t
tlen
)
{
for
(
int
i
=
0
;
i
<
tlen
;
i
++
)
{
int8_t
*
p
=
number
;
if
(
p
[
i
]
==
(
uint8_t
)
'0'
)
{
p
[
i
]
=
0
;
}
}
return
0
;
}
source/libs/index/test/.utilUT.cc.swn
0 → 100644
浏览文件 @
e8a63769
文件已添加
source/libs/index/test/jsonUT.cc
浏览文件 @
e8a63769
...
...
@@ -456,4 +456,32 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache) {
EXPECT_EQ
(
0
,
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
{
std
::
string
colName
(
"test1"
);
int
val
=
15
;
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
(
const
char
*
)
&
val
,
sizeof
(
val
));
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
1000
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"test1"
);
int
val
=
8
;
// std::string colVal("10");
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_INT
,
colName
.
c_str
(),
colName
.
size
(),
(
const
char
*
)
&
val
,
sizeof
(
val
));
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_GREATER_EQUAL
);
tIndexJsonSearch
(
index
,
mq
,
result
);
EXPECT_EQ
(
2000
,
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
}
source/libs/index/test/utilUT.cc
浏览文件 @
e8a63769
...
...
@@ -6,12 +6,14 @@
#include <vector>
#include "index.h"
#include "indexCache.h"
#include "indexComm.h"
#include "indexFst.h"
#include "indexFstCountingWriter.h"
#include "indexFstUtil.h"
#include "indexInt.h"
#include "indexTfile.h"
#include "indexUtil.h"
#include "tcoding.h"
#include "tglobal.h"
#include "tskiplist.h"
#include "tutil.h"
...
...
@@ -305,3 +307,19 @@ TEST_F(UtilEnv, 01Except) {
ASSERT_EQ
(
*
(
uint64_t
*
)
taosArrayGet
(
total
,
0
),
1
);
ASSERT_EQ
(
*
(
uint64_t
*
)
taosArrayGet
(
total
,
1
),
100
);
}
TEST_F
(
UtilEnv
,
testFill
)
{
for
(
int
i
=
0
;
i
<
10000
;
i
++
)
{
char
buf
[
10
]
=
{
0
};
void
*
pBuf
=
(
void
*
)
buf
;
int
val
=
i
;
int
v
;
taosEncodeFixedI32
((
void
**
)(
&
pBuf
),
val
);
// memcpy(buf, &val, sizeof(int));
indexMayFillNumbericData
((
void
*
)
buf
,
sizeof
(
val
));
indexMayUnfillNumbericData
((
void
*
)
buf
,
sizeof
(
val
));
taosDecodeFixedI32
(
buf
,
&
v
);
ASSERT_EQ
(
val
,
v
);
}
assert
(
0
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录