Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e96ff087
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看板
提交
e96ff087
编写于
5月 17, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: index failed to filter float/double data
上级
7d71a07a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
74 addition
and
48 deletion
+74
-48
source/libs/index/src/indexComm.c
source/libs/index/src/indexComm.c
+69
-44
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
+1
-1
未找到文件。
source/libs/index/src/indexComm.c
浏览文件 @
e96ff087
...
...
@@ -20,12 +20,13 @@
#include "tcompare.h"
#include "tdataformat.h"
#include "ttypes.h"
#include "tvariant.h"
char
JSON_COLUMN
[]
=
"JSON"
;
char
JSON_VALUE_DELIM
=
'&'
;
char
*
indexInt2str
(
int64_t
val
,
char
*
dst
,
int
radix
)
{
char
buffer
[
65
];
char
buffer
[
65
]
=
{
0
}
;
char
*
p
;
int64_t
new_val
;
uint64_t
uval
=
(
uint64_t
)
val
;
...
...
@@ -74,28 +75,70 @@ static TExeCond tCompareGreaterEqual(void* a, void* b, int8_t type) {
return
tCompare
(
func
,
QUERY_GREATER_EQUAL
,
a
,
b
,
type
);
}
TExeCond
tCompare
(
__compar_fn_t
func
,
int8_t
cmptype
,
void
*
a
,
void
*
b
,
int8_t
dtype
)
{
if
(
dtype
==
TSDB_DATA_TYPE_BINARY
||
dtype
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
dtype
==
TSDB_DATA_TYPE_BINARY
||
dtype
==
TSDB_DATA_TYPE_NCHAR
||
dtype
==
TSDB_DATA_TYPE_VARBINARY
)
{
return
tDoCompare
(
func
,
cmptype
,
a
,
b
);
}
#if 1
int8_t
bytes
=
tDataTypes
[
dtype
].
bytes
;
if
(
bytes
==
1
)
{
if
(
dtype
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
int64_t
va
=
taosStr2int64
(
a
);
int64_t
vb
=
taosStr2int64
(
b
);
return
tDoCompare
(
func
,
cmptype
,
&
va
,
&
vb
);
}
else
if
(
dtype
==
TSDB_DATA_TYPE_BOOL
||
dtype
==
TSDB_DATA_TYPE_UTINYINT
)
{
uint8_t
va
=
taosStr2int64
(
a
);
uint8_t
vb
=
taosStr2int64
(
b
);
return
tDoCompare
(
func
,
cmptype
,
&
va
,
&
vb
);
}
else
if
(
dtype
==
TSDB_DATA_TYPE_TINYINT
)
{
int8_t
va
=
taosStr2int64
(
a
);
int8_t
vb
=
taosStr2int64
(
b
);
return
tDoCompare
(
func
,
cmptype
,
&
va
,
&
vb
);
}
else
if
(
bytes
==
2
)
{
}
else
if
(
dtype
==
TSDB_DATA_TYPE_SMALLINT
)
{
int16_t
va
=
taosStr2int64
(
a
);
int16_t
vb
=
taosStr2int64
(
b
);
return
tDoCompare
(
func
,
cmptype
,
&
va
,
&
vb
);
}
else
if
(
bytes
==
4
)
{
}
else
if
(
dtype
==
TSDB_DATA_TYPE_USMALLINT
)
{
uint16_t
va
=
taosStr2int64
(
a
);
uint16_t
vb
=
taosStr2int64
(
b
);
return
tDoCompare
(
func
,
cmptype
,
&
va
,
&
vb
);
}
else
if
(
dtype
==
TSDB_DATA_TYPE_INT
)
{
int32_t
va
=
taosStr2int64
(
a
);
int32_t
vb
=
taosStr2int64
(
b
);
return
tDoCompare
(
func
,
cmptype
,
&
va
,
&
vb
);
}
else
{
}
else
if
(
dtype
==
TSDB_DATA_TYPE_UINT
)
{
uint32_t
va
=
taosStr2int64
(
a
);
uint32_t
vb
=
taosStr2int64
(
b
);
return
tDoCompare
(
func
,
cmptype
,
&
va
,
&
vb
);
}
else
if
(
dtype
==
TSDB_DATA_TYPE_BIGINT
)
{
int64_t
va
=
taosStr2int64
(
a
);
int64_t
vb
=
taosStr2int64
(
b
);
return
tDoCompare
(
func
,
cmptype
,
&
va
,
&
vb
);
}
else
if
(
dtype
==
TSDB_DATA_TYPE_UBIGINT
)
{
uint64_t
va
,
vb
;
if
(
0
!=
toUInteger
(
a
,
strlen
(
a
),
10
,
&
va
)
||
0
!=
toUInteger
(
b
,
strlen
(
b
),
10
,
&
vb
))
{
return
CONTINUE
;
}
return
tDoCompare
(
func
,
cmptype
,
&
va
,
&
vb
);
}
else
if
(
dtype
==
TSDB_DATA_TYPE_FLOAT
)
{
float
va
=
strtod
(
a
,
NULL
);
if
(
errno
==
ERANGE
&&
va
==
-
1
)
{
return
CONTINUE
;
}
float
vb
=
strtod
(
b
,
NULL
);
if
(
errno
==
ERANGE
&&
va
==
-
1
)
{
return
CONTINUE
;
}
return
tDoCompare
(
func
,
cmptype
,
&
va
,
&
vb
);
}
else
if
(
dtype
==
TSDB_DATA_TYPE_DOUBLE
)
{
double
va
=
strtod
(
a
,
NULL
);
if
(
errno
==
ERANGE
&&
va
==
-
1
)
{
return
CONTINUE
;
}
double
vb
=
strtod
(
b
,
NULL
);
if
(
errno
==
ERANGE
&&
va
==
-
1
)
{
return
CONTINUE
;
}
return
tDoCompare
(
func
,
cmptype
,
&
va
,
&
vb
);
}
assert
(
0
);
#endif
}
TExeCond
tDoCompare
(
__compar_fn_t
func
,
int8_t
comparType
,
void
*
a
,
void
*
b
)
{
...
...
@@ -248,20 +291,16 @@ int32_t indexConvertData(void* src, int8_t type, void** dst) {
break
;
}
case
TSDB_DATA_TYPE_VARCHAR
:
{
// TSDB_DATA_TYPE_BINARY
#if 1
tlen
=
taosEncodeBinary
(
NULL
,
src
,
strlen
(
src
));
*
dst
=
taosMemoryCalloc
(
1
,
tlen
+
1
);
tlen
=
taosEncodeBinary
(
dst
,
src
,
strlen
(
src
));
break
;
#endif
}
case
TSDB_DATA_TYPE_VARBINARY
:
#if 1
tlen
=
taosEncodeBinary
(
NULL
,
src
,
strlen
(
src
));
*
dst
=
taosMemoryCalloc
(
1
,
tlen
+
1
);
tlen
=
taosEncodeBinary
(
dst
,
src
,
strlen
(
src
));
break
;
#endif
default:
TASSERT
(
0
);
break
;
...
...
@@ -271,87 +310,73 @@ int32_t indexConvertData(void* src, int8_t type, void** dst) {
return
tlen
;
}
int32_t
indexConvertDataToStr
(
void
*
src
,
int8_t
type
,
void
**
dst
)
{
int
tlen
=
tDataTypes
[
type
].
bytes
;
int
tlen
=
tDataTypes
[
type
].
bytes
;
int32_t
bufSize
=
64
;
switch
(
type
)
{
case
TSDB_DATA_TYPE_TIMESTAMP
:
*
dst
=
taosMemoryCalloc
(
1
,
sizeof
(
int64_t
)
+
1
);
*
dst
=
taosMemoryCalloc
(
1
,
bufSize
+
1
);
indexInt2str
(
*
(
int64_t
*
)
src
,
*
dst
,
-
1
);
break
;
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_UTINYINT
:
// tlen = taosEncodeFixedU8(NULL, *(uint8_t*)src);
//*dst = taosMemoryCalloc(1, tlen + 1);
// tlen = taosEncodeFixedU8(dst, *(uint8_t*)src);
*
dst
=
taosMemoryCalloc
(
1
,
sizeof
(
int64_t
)
+
1
);
*
dst
=
taosMemoryCalloc
(
1
,
bufSize
+
1
);
indexInt2str
(
*
(
uint8_t
*
)
src
,
*
dst
,
1
);
break
;
case
TSDB_DATA_TYPE_TINYINT
:
*
dst
=
taosMemoryCalloc
(
1
,
sizeof
(
int64_t
)
+
1
);
*
dst
=
taosMemoryCalloc
(
1
,
bufSize
+
1
);
indexInt2str
(
*
(
int8_t
*
)
src
,
*
dst
,
1
);
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
*
dst
=
taosMemoryCalloc
(
1
,
sizeof
(
int64_t
)
+
1
);
*
dst
=
taosMemoryCalloc
(
1
,
bufSize
+
1
);
indexInt2str
(
*
(
int16_t
*
)
src
,
*
dst
,
-
1
);
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
*
dst
=
taosMemoryCalloc
(
1
,
sizeof
(
int64_t
)
+
1
);
*
dst
=
taosMemoryCalloc
(
1
,
bufSize
+
1
);
indexInt2str
(
*
(
uint16_t
*
)
src
,
*
dst
,
-
1
);
break
;
case
TSDB_DATA_TYPE_INT
:
*
dst
=
taosMemoryCalloc
(
1
,
sizeof
(
int64_t
)
+
1
);
*
dst
=
taosMemoryCalloc
(
1
,
bufSize
+
1
);
indexInt2str
(
*
(
int32_t
*
)
src
,
*
dst
,
-
1
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
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
);
*
dst
=
taosMemoryCalloc
(
1
,
bufSize
+
1
);
indexInt2str
(
*
(
uint32_t
*
)
src
,
*
dst
,
1
);
break
;
case
TSDB_DATA_TYPE_BIGINT
:
*
dst
=
taosMemoryCalloc
(
1
,
sizeof
(
int64_t
)
+
1
);
indexInt2str
(
*
(
int64_t
*
)
src
,
*
dst
,
1
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
tlen
=
taosEncodeBinary
(
NULL
,
src
,
sizeof
(
double
));
*
dst
=
taosMemoryCalloc
(
1
,
tlen
+
1
);
tlen
=
taosEncodeBinary
(
dst
,
src
,
sizeof
(
double
));
*
dst
=
*
dst
-
tlen
;
*
dst
=
taosMemoryCalloc
(
1
,
bufSize
+
1
);
sprintf
(
*
dst
,
"%"
PRIu64
,
*
(
uint64_t
*
)
src
);
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
assert
(
0
);
*
dst
=
taosMemoryCalloc
(
1
,
sizeof
(
int64_t
)
+
1
);
*
dst
=
taosMemoryCalloc
(
1
,
bufSize
+
1
);
indexInt2str
(
*
(
uint64_t
*
)
src
,
*
dst
,
1
);
case
TSDB_DATA_TYPE_FLOAT
:
*
dst
=
taosMemoryCalloc
(
1
,
bufSize
+
1
);
sprintf
(
*
dst
,
"%.9lf"
,
*
(
float
*
)
src
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
*
dst
=
taosMemoryCalloc
(
1
,
bufSize
+
1
);
sprintf
(
*
dst
,
"%.9lf"
,
*
(
double
*
)
src
);
break
;
case
TSDB_DATA_TYPE_NCHAR
:
{
tlen
=
taosEncodeBinary
(
NULL
,
varDataVal
(
src
),
varDataLen
(
src
));
*
dst
=
taosMemoryCalloc
(
1
,
tlen
+
1
);
tlen
=
taosEncodeBinary
(
dst
,
varDataVal
(
src
),
varDataLen
(
src
));
*
dst
=
*
dst
-
tlen
;
break
;
}
case
TSDB_DATA_TYPE_VARCHAR
:
{
// TSDB_DATA_TYPE_BINARY
#if 1
tlen
=
taosEncodeBinary
(
NULL
,
src
,
strlen
(
src
));
*
dst
=
taosMemoryCalloc
(
1
,
tlen
+
1
);
tlen
=
taosEncodeBinary
(
dst
,
src
,
strlen
(
src
));
*
dst
=
*
dst
-
tlen
;
break
;
#endif
}
case
TSDB_DATA_TYPE_VARBINARY
:
#if 1
tlen
=
taosEncodeBinary
(
NULL
,
src
,
strlen
(
src
));
*
dst
=
taosMemoryCalloc
(
1
,
tlen
+
1
);
tlen
=
taosEncodeBinary
(
dst
,
src
,
strlen
(
src
));
*
dst
=
*
dst
-
tlen
;
break
;
#endif
default:
TASSERT
(
0
);
break
;
...
...
source/libs/index/src/indexTfile.c
浏览文件 @
e96ff087
...
...
@@ -20,6 +20,7 @@ p *
#include "indexFstCountingWriter.h"
#include "indexUtil.h"
#include "taosdef.h"
#include "taoserror.h"
#include "tcoding.h"
#include "tcompare.h"
...
...
@@ -533,10 +534,12 @@ TFileReader* tfileReaderOpen(char* path, uint64_t suid, int32_t version, const c
tfileGenFileFullName
(
fullname
,
path
,
suid
,
colName
,
version
);
WriterCtx
*
wc
=
writerCtxCreate
(
TFile
,
fullname
,
true
,
1024
*
1024
*
1024
);
indexInfo
(
"open read file name:%s, file size: %d"
,
wc
->
file
.
buf
,
wc
->
file
.
size
);
if
(
wc
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
indexError
(
"failed to open readonly file: %s, reason: %s"
,
fullname
,
terrstr
());
return
NULL
;
}
indexInfo
(
"open read file name:%s, file size: %d"
,
wc
->
file
.
buf
,
wc
->
file
.
size
);
TFileReader
*
reader
=
tfileReaderCreate
(
wc
);
return
reader
;
...
...
@@ -613,9 +616,7 @@ 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));
...
...
source/libs/index/test/jsonUT.cc
浏览文件 @
e96ff087
...
...
@@ -553,7 +553,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_FLOAT) {
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
);
WriteData
(
index
,
colName
,
TSDB_DATA_TYPE_FLOAT
,
&
val
,
sizeof
(
val
),
i
+
1000
);
}
}
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录