Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
09837b76
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看板
提交
09837b76
编写于
5月 18, 2023
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: save work
上级
dec15bf4
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
109 addition
and
15 deletion
+109
-15
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+109
-15
未找到文件。
source/libs/scalar/src/filter.c
浏览文件 @
09837b76
...
...
@@ -3960,7 +3960,7 @@ typedef struct {
union
{
int64_t
val
;
// for int64, uint64 and double and bool (1 true, 0 false)
uint8_t
*
pData
;
// for varchar, nchar
}
datum
;
};
SDataType
type
;
// TODO: original data type, may not be used?
}
SFltSclDatum
;
...
...
@@ -3981,11 +3981,11 @@ int32_t fltSclCompareWithFloat64(SFltSclDatum *val1, SFltSclDatum *val2) {
// val2->kind == int64
switch
(
val1
->
kind
)
{
case
FLT_SCL_DATUM_KIND_UINT64
:
return
compareUint64Double
(
&
val1
->
datum
.
val
,
&
val2
->
datum
.
val
);
return
compareUint64Double
(
&
val1
->
val
,
&
val2
->
val
);
case
FLT_SCL_DATUM_KIND_INT64
:
return
compareInt64Double
(
&
val1
->
datum
.
val
,
&
val2
->
datum
.
val
);
return
compareInt64Double
(
&
val1
->
val
,
&
val2
->
val
);
case
FLT_SCL_DATUM_KIND_FLOAT64
:
{
return
compareDoubleVal
(
&
val1
->
datum
.
val
,
&
val2
->
datum
.
val
);
return
compareDoubleVal
(
&
val1
->
val
,
&
val2
->
val
);
}
//TODO: varchar, nchar
default:
...
...
@@ -3998,11 +3998,11 @@ int32_t fltSclCompareWithInt64(SFltSclDatum *val1, SFltSclDatum *val2) {
// val2->kind == int64
switch
(
val1
->
kind
)
{
case
FLT_SCL_DATUM_KIND_UINT64
:
return
compareUint64Int64
(
&
val1
->
datum
.
val
,
&
val2
->
datum
.
val
);
return
compareUint64Int64
(
&
val1
->
val
,
&
val2
->
val
);
case
FLT_SCL_DATUM_KIND_INT64
:
return
compareInt64Val
(
&
val1
->
datum
.
val
,
&
val2
->
datum
.
val
);
return
compareInt64Val
(
&
val1
->
val
,
&
val2
->
val
);
case
FLT_SCL_DATUM_KIND_FLOAT64
:
{
return
compareDoubleInt64
(
&
val1
->
datum
.
val
,
&
val2
->
datum
.
val
);
return
compareDoubleInt64
(
&
val1
->
val
,
&
val2
->
val
);
}
//TODO: varchar, nchar
default:
...
...
@@ -4015,11 +4015,11 @@ int32_t fltSclCompareWithUInt64(SFltSclDatum *val1, SFltSclDatum *val2) {
// val2 kind == uint64
switch
(
val1
->
kind
)
{
case
FLT_SCL_DATUM_KIND_UINT64
:
return
compareUint64Val
(
&
val1
->
datum
.
val
,
&
val2
->
datum
.
val
);
return
compareUint64Val
(
&
val1
->
val
,
&
val2
->
val
);
case
FLT_SCL_DATUM_KIND_INT64
:
return
compareInt64Uint64
(
&
val1
->
datum
.
val
,
&
val2
->
datum
.
val
);
return
compareInt64Uint64
(
&
val1
->
val
,
&
val2
->
val
);
case
FLT_SCL_DATUM_KIND_FLOAT64
:
{
return
compareDoubleUint64
(
&
val1
->
datum
.
val
,
&
val2
->
datum
.
val
);
return
compareDoubleUint64
(
&
val1
->
val
,
&
val2
->
val
);
}
//TODO: varchar, nchar
default:
...
...
@@ -4142,16 +4142,110 @@ typedef struct {
EOperatorType
type
;
}
SFltSclOperator
;
//TODO: column, constant
, operator, and/or/not
//TODO: column, constant
int32_t
fltSclBuildRangeFromOperator
(
SFltSclOperator
*
sclOper
,
SSHashObj
*
obj
)
{
switch
(
sclOper
->
type
)
{
case
OP_TYPE_GREATER_THAN
:
{
typedef
struct
{
SColumnNode
*
colNode
;
SArray
*
points
;
}
SFltSclColumnRange
;
SFltSclColumnRange
*
fltSclGetColumnRange
(
SColumnNode
*
colNode
,
SArray
*
colRangeList
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
colRangeList
);
++
i
)
{
SFltSclColumnRange
*
colRange
=
taosArrayGet
(
colRangeList
,
i
);
if
(
nodesEqualNode
((
SNode
*
)
colRange
->
colNode
,
(
SNode
*
)
colNode
))
{
return
colRange
;
}
}
SFltSclColumnRange
newColRange
=
{.
colNode
=
colNode
,
.
points
=
taosArrayInit
(
4
,
sizeof
(
SFltSclPoint
))};
taosArrayPush
(
colRangeList
,
&
newColRange
);
return
taosArrayGetLast
(
colRangeList
);
}
int32_t
fltSclBuildDatumFromValueNode
(
SFltSclDatum
*
datum
,
SValueNode
*
valNode
)
{
datum
->
type
=
valNode
->
node
.
resType
;
if
(
valNode
->
isNull
)
{
datum
->
kind
=
FLT_SCL_DATUM_KIND_NULL
;
}
else
{
switch
(
valNode
->
node
.
resType
.
type
)
{
case
TSDB_DATA_TYPE_NULL
:
{
datum
->
kind
=
FLT_SCL_DATUM_KIND_NULL
;
break
;
default:
}
case
TSDB_DATA_TYPE_BOOL
:
{
datum
->
kind
=
FLT_SCL_DATUM_KIND_INT64
;
datum
->
val
=
(
valNode
->
datum
.
b
)
?
0
:
1
;
break
;
}
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
{
datum
->
kind
=
FLT_SCL_DATUM_KIND_INT64
;
datum
->
val
=
valNode
->
datum
.
i
;
break
;
}
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
{
datum
->
kind
=
FLT_SCL_DATUM_KIND_UINT64
;
*
(
uint64_t
*
)
&
datum
->
val
=
valNode
->
datum
.
u
;
break
;
}
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_DOUBLE
:
{
datum
->
kind
=
FLT_SCL_DATUM_KIND_FLOAT64
;
*
(
double
*
)
&
datum
->
val
=
valNode
->
datum
.
d
;
break
;
}
//TODO:varchar/nchar/json
default:
{
qError
(
"not supported"
);
break
;
}
}
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
fltSclBuildRangePoints
(
SFltSclOperator
*
oper
,
SArray
*
points
)
{
switch
(
oper
->
type
)
{
case
OP_TYPE_GREATER_THAN
:
{
SFltSclDatum
start
;
fltSclBuildDatumFromValueNode
(
&
start
,
oper
->
valNode
);
SFltSclPoint
startPt
=
{.
start
=
true
,
.
excl
=
true
,
.
val
=
start
};
SFltSclDatum
end
=
{.
kind
=
FLT_SCL_DATUM_KIND_MAX
,
.
type
=
oper
->
colNode
->
node
.
resType
};
SFltSclPoint
endPt
=
{.
start
=
false
,
.
excl
=
false
,
.
val
=
end
};
taosArrayPush
(
points
,
&
start
);
taosArrayPush
(
points
,
&
end
);
break
;
}
default:
{
qError
(
"not supported op"
);
break
;
}
}
return
TSDB_CODE_SUCCESS
;
}
//TODO: process DNF composed of CNF
int32_t
fltSclProcessCNF
(
SArray
*
sclOpList
,
SArray
*
colRangeList
)
{
size_t
sz
=
taosArrayGetSize
(
sclOpList
);
for
(
int32_t
i
=
0
;
i
<
sz
;
++
i
)
{
SFltSclOperator
*
sclOper
=
taosArrayGet
(
sclOpList
,
i
);
SFltSclColumnRange
*
colRange
=
fltSclGetColumnRange
(
sclOper
->
colNode
,
colRangeList
);
SArray
*
points
=
taosArrayInit
(
4
,
sizeof
(
SFltSclPoint
));
fltSclBuildRangePoints
(
sclOper
,
points
);
SArray
*
merged
=
taosArrayInit
(
4
,
sizeof
(
SFltSclPoint
));
int32_t
code
=
fltSclIntersect
(
colRange
->
points
,
points
,
merged
);
taosArrayDestroy
(
colRange
->
points
);
taosArrayDestroy
(
points
);
colRange
->
points
=
merged
;
}
return
TSDB_CODE_SUCCESS
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录