Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1f6d894d
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看板
提交
1f6d894d
编写于
5月 19, 2023
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: save work
上级
3e92ec7a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
91 addition
and
30 deletion
+91
-30
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+91
-30
未找到文件。
source/libs/scalar/src/filter.c
浏览文件 @
1f6d894d
...
...
@@ -3958,10 +3958,10 @@ typedef enum {
typedef
struct
{
SFltSclDatumKind
kind
;
union
{
int64_t
val
;
// for int64, uint64 and double and bool (1 true, 0 false)
uint8_t
*
pData
;
// for varchar, nchar
int64_t
val
;
// for int64, uint64 and double and bool (1 true, 0 false)
uint8_t
*
pData
;
// for varchar, nchar
};
SDataType
type
;
// TODO: original data type, may not be used?
SDataType
type
;
// TODO: original data type, may not be used?
}
SFltSclDatum
;
typedef
struct
{
...
...
@@ -3987,7 +3987,7 @@ int32_t fltSclCompareWithFloat64(SFltSclDatum *val1, SFltSclDatum *val2) {
case
FLT_SCL_DATUM_KIND_FLOAT64
:
{
return
compareDoubleVal
(
&
val1
->
val
,
&
val2
->
val
);
}
//TODO: varchar, nchar
//
TODO: varchar, nchar
default:
qError
(
"not support comparsion. %d, %d"
,
val1
->
kind
,
val2
->
kind
);
return
(
val1
->
kind
-
val2
->
kind
);
...
...
@@ -4004,7 +4004,7 @@ int32_t fltSclCompareWithInt64(SFltSclDatum *val1, SFltSclDatum *val2) {
case
FLT_SCL_DATUM_KIND_FLOAT64
:
{
return
compareDoubleInt64
(
&
val1
->
val
,
&
val2
->
val
);
}
//TODO: varchar, nchar
//
TODO: varchar, nchar
default:
qError
(
"not support comparsion. %d, %d"
,
val1
->
kind
,
val2
->
kind
);
return
(
val1
->
kind
-
val2
->
kind
);
...
...
@@ -4021,7 +4021,7 @@ int32_t fltSclCompareWithUInt64(SFltSclDatum *val1, SFltSclDatum *val2) {
case
FLT_SCL_DATUM_KIND_FLOAT64
:
{
return
compareDoubleUint64
(
&
val1
->
val
,
&
val2
->
val
);
}
//TODO: varchar, nchar
//
TODO: varchar, nchar
default:
qError
(
"not support comparsion. %d, %d"
,
val1
->
kind
,
val2
->
kind
);
return
(
val1
->
kind
-
val2
->
kind
);
...
...
@@ -4047,7 +4047,7 @@ int32_t fltSclCompareDatum(SFltSclDatum *val1, SFltSclDatum *val2) {
case
FLT_SCL_DATUM_KIND_FLOAT64
:
{
return
fltSclCompareWithFloat64
(
val1
,
val2
);
}
//TODO: varchar/nchar
//
TODO: varchar/nchar
default:
fltError
(
"not supported kind. just return 0"
);
return
0
;
...
...
@@ -4142,17 +4142,17 @@ typedef struct {
EOperatorType
type
;
}
SFltSclOperator
;
//TODO: column, constant
//
TODO: column, constant
typedef
struct
{
SColumnNode
*
colNode
;
SArray
*
points
;
SColumnNode
*
colNode
;
SArray
*
points
;
}
SFltSclColumnRange
;
SFltSclColumnRange
*
fltSclGetColumnRange
(
SColumnNode
*
colNode
,
SArray
*
colRangeList
)
{
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
))
{
SFltSclColumnRange
*
colRange
=
taosArrayGet
(
colRangeList
,
i
);
if
(
nodesEqualNode
((
SNode
*
)
colRange
->
colNode
,
(
SNode
*
)
colNode
))
{
return
colRange
;
}
}
...
...
@@ -4161,7 +4161,7 @@ SFltSclColumnRange* fltSclGetColumnRange(SColumnNode* colNode, SArray* colRangeL
return
taosArrayGetLast
(
colRangeList
);
}
int32_t
fltSclBuildDatumFromValueNode
(
SFltSclDatum
*
datum
,
SValueNode
*
valNode
)
{
int32_t
fltSclBuildDatumFromValueNode
(
SFltSclDatum
*
datum
,
SValueNode
*
valNode
)
{
datum
->
type
=
valNode
->
node
.
resType
;
if
(
valNode
->
isNull
)
{
...
...
@@ -4200,39 +4200,101 @@ int32_t fltSclBuildDatumFromValueNode(SFltSclDatum* datum, SValueNode* valNode)
*
(
double
*
)
&
datum
->
val
=
valNode
->
datum
.
d
;
break
;
}
//TODO:varchar/nchar/json
//
TODO:varchar/nchar/json
default:
{
qError
(
"not supported"
);
break
;
}
}
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
fltSclBuildRangePoints
(
SFltSclOperator
*
oper
,
SArray
*
points
)
{
int32_t
fltSclBuildRangePoints
(
SFltSclOperator
*
oper
,
SArray
*
points
)
{
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
oper
->
colNode
->
node
.
resType
.
type
)
&&
((
IS_SIGNED_NUMERIC_TYPE
(
oper
->
valNode
->
node
.
resType
.
type
)
&&
oper
->
valNode
->
datum
.
i
<
0
)
||
(
IS_FLOAT_TYPE
(
oper
->
valNode
->
node
.
resType
.
type
)
&&
oper
->
valNode
->
datum
.
d
<
0
)))
{
if
(
oper
->
type
==
OP_TYPE_GREATER_THAN
||
oper
->
type
==
OP_TYPE_GREATER_EQUAL
||
oper
->
type
==
OP_TYPE_NOT_EQUAL
)
{
SFltSclDatum
start
;
fltSclBuildDatumFromValueNode
(
&
start
,
oper
->
valNode
);
start
.
val
=
0
;
SFltSclPoint
startPt
=
{.
start
=
true
,
.
excl
=
false
,
.
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
,
&
startPt
);
taosArrayPush
(
points
,
&
endPt
);
}
return
TSDB_CODE_SUCCESS
;
}
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
};
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
);
taosArrayPush
(
points
,
&
start
Pt
);
taosArrayPush
(
points
,
&
end
Pt
);
break
;
}
case
OP_TYPE_GREATER_EQUAL
:
{
SFltSclDatum
start
;
fltSclBuildDatumFromValueNode
(
&
start
,
oper
->
valNode
);
SFltSclPoint
startPt
=
{.
start
=
true
,
.
excl
=
false
,
.
val
=
start
};
SFltSclDatum
end
=
{.
kind
=
FLT_SCL_DATUM_KIND_MAX
,
.
type
=
oper
->
colNode
->
node
.
resType
};
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
);
taosArrayPush
(
points
,
&
startPt
);
taosArrayPush
(
points
,
&
endPt
);
break
;
}
case
OP_TYPE_LOWER_THAN
:
{
SFltSclDatum
end
;
fltSclBuildDatumFromValueNode
(
&
end
,
oper
->
valNode
);
SFltSclPoint
endPt
=
{.
start
=
false
,
.
excl
=
true
,
.
val
=
end
};
SFltSclDatum
start
=
{.
kind
=
FLT_SCL_DATUM_KIND_MIN
,
.
type
=
oper
->
colNode
->
node
.
resType
};
SFltSclPoint
startPt
=
{.
start
=
true
,
.
excl
=
false
,
.
val
=
start
};
taosArrayPush
(
points
,
&
startPt
);
taosArrayPush
(
points
,
&
endPt
);
break
;
}
case
OP_TYPE_LOWER_EQUAL
:
{
SFltSclDatum
end
;
fltSclBuildDatumFromValueNode
(
&
end
,
oper
->
valNode
);
SFltSclPoint
endPt
=
{.
start
=
false
,
.
excl
=
false
,
.
val
=
end
};
SFltSclDatum
start
=
{.
kind
=
FLT_SCL_DATUM_KIND_MIN
,
.
type
=
oper
->
colNode
->
node
.
resType
};
SFltSclPoint
startPt
=
{.
start
=
true
,
.
excl
=
false
,
.
val
=
start
};
taosArrayPush
(
points
,
&
startPt
);
taosArrayPush
(
points
,
&
endPt
);
break
;
}
case
OP_TYPE_EQUAL
:
{
SFltSclDatum
valDatum
;
fltSclBuildDatumFromValueNode
(
&
valDatum
,
oper
->
valNode
);
SFltSclPoint
startPt
=
{.
start
=
true
,
.
excl
=
false
,
.
val
=
valDatum
};
SFltSclPoint
endPt
=
{.
start
=
false
,
.
excl
=
false
,
.
val
=
valDatum
};
taosArrayPush
(
points
,
&
startPt
);
taosArrayPush
(
points
,
&
endPt
);
break
;
}
case
OP_TYPE_NOT_EQUAL
:
{
SFltSclDatum
valDatum
;
fltSclBuildDatumFromValueNode
(
&
valDatum
,
oper
->
valNode
);
{
SFltSclDatum
start
=
{.
kind
=
FLT_SCL_DATUM_KIND_MIN
,
.
type
=
oper
->
colNode
->
node
.
resType
};
SFltSclPoint
startPt
=
{.
start
=
true
,
.
excl
=
false
,
.
val
=
start
};
SFltSclPoint
endPt
=
{.
start
=
false
,
.
excl
=
true
,
.
val
=
valDatum
};
taosArrayPush
(
points
,
&
startPt
);
taosArrayPush
(
points
,
&
endPt
);
}
{
SFltSclPoint
startPt
=
{.
start
=
true
,
.
excl
=
true
,
.
val
=
valDatum
};
SFltSclDatum
end
=
{.
kind
=
FLT_SCL_DATUM_KIND_MAX
,
.
type
=
oper
->
colNode
->
node
.
resType
};
SFltSclPoint
endPt
=
{.
start
=
false
,
.
excl
=
false
,
.
val
=
end
};
taosArrayPush
(
points
,
&
startPt
);
taosArrayPush
(
points
,
&
endPt
);
}
break
;
}
case
default:
{
qError
(
"not supported op"
);
break
;
...
...
@@ -4241,20 +4303,19 @@ int32_t fltSclBuildRangePoints(SFltSclOperator* oper, SArray* points) {
return
TSDB_CODE_SUCCESS
;
}
//TODO: process DNF composed of CNF
int32_t
fltSclProcessCNF
(
SArray
*
sclOpList
,
SArray
*
colRangeList
)
{
//
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
);
SFltSclOperator
*
sclOper
=
taosArrayGet
(
sclOpList
,
i
);
SFltSclColumnRange
*
colRange
=
fltSclGetColumnRange
(
sclOper
->
colNode
,
colRangeList
);
SArray
*
points
=
taosArrayInit
(
4
,
sizeof
(
SFltSclPoint
));
SArray
*
points
=
taosArrayInit
(
4
,
sizeof
(
SFltSclPoint
));
fltSclBuildRangePoints
(
sclOper
,
points
);
SArray
*
merged
=
taosArrayInit
(
4
,
sizeof
(
SFltSclPoint
));
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录