Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
7b1f5c4e
I
Iotdb
项目概览
apache
/
Iotdb
12 个月 前同步成功
通知
25
Star
3344
Fork
916
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iotdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7b1f5c4e
编写于
1月 17, 2022
作者:
X
Xiangwei Wei
提交者:
GitHub
1月 17, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[IOTDB-2415] Slimit wrong result data in align by device
上级
30e5aa29
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
77 addition
and
12 deletion
+77
-12
integration/src/test/java/org/apache/iotdb/db/integration/IoTDBAlignByDeviceIT.java
...org/apache/iotdb/db/integration/IoTDBAlignByDeviceIT.java
+46
-0
server/src/main/java/org/apache/iotdb/db/qp/logical/crud/QueryOperator.java
...va/org/apache/iotdb/db/qp/logical/crud/QueryOperator.java
+17
-12
server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AlignByDevicePlan.java
...g/apache/iotdb/db/qp/physical/crud/AlignByDevicePlan.java
+14
-0
未找到文件。
integration/src/test/java/org/apache/iotdb/db/integration/IoTDBAlignByDeviceIT.java
浏览文件 @
7b1f5c4e
...
...
@@ -304,6 +304,52 @@ public class IoTDBAlignByDeviceIT {
}
}
@Test
public
void
selectSlimitTest2
()
{
String
[]
retArray
=
new
String
[]
{
"1,root.vehicle.d0,null,101,1101,"
,
};
try
(
Connection
connection
=
EnvFactory
.
getEnv
().
getConnection
();
Statement
statement
=
connection
.
createStatement
())
{
boolean
hasResultSet
=
statement
.
execute
(
"select * from root.vehicle.d0 limit 1 slimit 3 soffset 1 align by device"
);
Assert
.
assertTrue
(
hasResultSet
);
try
(
ResultSet
resultSet
=
statement
.
getResultSet
())
{
ResultSetMetaData
resultSetMetaData
=
resultSet
.
getMetaData
();
List
<
Integer
>
actualIndexToExpectedIndexList
=
checkHeader
(
resultSetMetaData
,
"Time,Device,s4,s0,s1"
,
new
int
[]
{
Types
.
TIMESTAMP
,
Types
.
VARCHAR
,
Types
.
BOOLEAN
,
Types
.
INTEGER
,
Types
.
BIGINT
,
});
int
cnt
=
0
;
while
(
resultSet
.
next
())
{
String
[]
expectedStrings
=
retArray
[
cnt
].
split
(
","
);
StringBuilder
expectedBuilder
=
new
StringBuilder
();
StringBuilder
actualBuilder
=
new
StringBuilder
();
for
(
int
i
=
1
;
i
<=
resultSetMetaData
.
getColumnCount
();
i
++)
{
actualBuilder
.
append
(
resultSet
.
getString
(
i
)).
append
(
","
);
expectedBuilder
.
append
(
expectedStrings
[
actualIndexToExpectedIndexList
.
get
(
i
-
1
)])
.
append
(
","
);
}
Assert
.
assertEquals
(
expectedBuilder
.
toString
(),
actualBuilder
.
toString
());
cnt
++;
}
Assert
.
assertEquals
(
1
,
cnt
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
fail
(
e
.
getMessage
());
}
}
@Test
public
void
selectSlimitTest
()
{
String
[]
retArray
=
...
...
server/src/main/java/org/apache/iotdb/db/qp/logical/crud/QueryOperator.java
浏览文件 @
7b1f5c4e
...
...
@@ -243,8 +243,7 @@ public class QueryOperator extends Operator {
// remove stars in fromPaths and get deviceId with deduplication
List
<
PartialPath
>
devices
=
removeStarsInDeviceWithUnique
(
fromComponent
.
getPrefixPaths
());
List
<
ResultColumn
>
resultColumns
=
convertSpecialClauseValues
(
alignByDevicePlan
,
selectComponent
.
getResultColumns
());
List
<
ResultColumn
>
resultColumns
=
selectComponent
.
getResultColumns
();
List
<
String
>
aggregationFuncs
=
selectComponent
.
getAggregationFunctions
();
// to record result measurement columns
List
<
String
>
measurements
=
new
ArrayList
<>();
...
...
@@ -305,10 +304,17 @@ public class QueryOperator extends Operator {
// therefore the final measurements is [s1,s2,s3,s1].
measurements
.
addAll
(
measurementSetOfGivenSuffix
);
}
if
(
specialClauseComponent
.
hasSlimit
()
&&
measurements
.
size
()
>=
specialClauseComponent
.
getSeriesLimit
()
+
specialClauseComponent
.
getSeriesOffset
())
{
break
;
}
}
// assigns to alignByDevicePlan
alignByDevicePlan
.
setMeasurements
(
measurements
);
alignByDevicePlan
.
setMeasurements
(
convertSpecialClauseValues
(
alignByDevicePlan
,
measurements
)
);
alignByDevicePlan
.
setPaths
(
paths
);
alignByDevicePlan
.
setAggregations
(
aggregations
);
alignByDevicePlan
.
setMeasurementInfoMap
(
measurementInfoMap
);
...
...
@@ -345,16 +351,16 @@ public class QueryOperator extends Operator {
}
}
private
List
<
ResultColumn
>
convertSpecialClauseValues
(
QueryPlan
queryPlan
,
List
<
ResultColumn
>
resultColumns
)
throws
QueryProcessException
{
private
List
<
String
>
convertSpecialClauseValues
(
QueryPlan
queryPlan
,
List
<
String
>
measurements
)
throws
QueryProcessException
{
convertSpecialClauseValues
(
queryPlan
);
// sLimit trim on the measurementColumnList
if
(
specialClauseComponent
.
hasSlimit
())
{
int
seriesSLimit
=
specialClauseComponent
.
getSeriesLimit
();
int
seriesOffset
=
specialClauseComponent
.
getSeriesOffset
();
return
slimitTrimColumn
(
resultColumn
s
,
seriesSLimit
,
seriesOffset
);
return
slimitTrimColumn
(
measurement
s
,
seriesSLimit
,
seriesOffset
);
}
return
resultColumn
s
;
return
measurement
s
;
}
private
List
<
PartialPath
>
removeStarsInDeviceWithUnique
(
List
<
PartialPath
>
paths
)
...
...
@@ -391,10 +397,9 @@ public class QueryOperator extends Operator {
return
initialMeasurement
;
}
private
List
<
ResultColumn
>
slimitTrimColumn
(
List
<
ResultColumn
>
resultColumns
,
int
seriesLimit
,
int
seriesOffset
)
throws
QueryProcessException
{
int
size
=
resultColumns
.
size
();
private
List
<
String
>
slimitTrimColumn
(
List
<
String
>
measurements
,
int
seriesLimit
,
int
seriesOffset
)
throws
QueryProcessException
{
int
size
=
measurements
.
size
();
// check parameter range
if
(
seriesOffset
>=
size
)
{
...
...
@@ -408,7 +413,7 @@ public class QueryOperator extends Operator {
}
// trim seriesPath list
return
new
ArrayList
<>(
resultColumn
s
.
subList
(
seriesOffset
,
endPosition
));
return
new
ArrayList
<>(
measurement
s
.
subList
(
seriesOffset
,
endPosition
));
}
// e.g. translate "select * from root.ln.d1, root.ln.d2 where s1 < 20 AND s2 > 10" to
...
...
server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AlignByDevicePlan.java
浏览文件 @
7b1f5c4e
...
...
@@ -30,6 +30,7 @@ import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import
org.apache.iotdb.tsfile.read.expression.IExpression
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
...
...
@@ -68,9 +69,14 @@ public class AlignByDevicePlan extends QueryPlan {
public
void
deduplicate
(
PhysicalGenerator
physicalGenerator
)
{
Set
<
String
>
pathWithAggregationSet
=
new
LinkedHashSet
<>();
List
<
String
>
deduplicatedAggregations
=
new
ArrayList
<>();
HashSet
<
String
>
measurements
=
new
HashSet
<>(
getMeasurements
());
for
(
int
i
=
0
;
i
<
paths
.
size
();
i
++)
{
PartialPath
path
=
paths
.
get
(
i
);
String
aggregation
=
aggregations
!=
null
?
aggregations
.
get
(
i
)
:
null
;
String
measurementWithAggregation
=
getMeasurementStrWithAggregation
(
path
,
aggregation
);
if
(!
measurements
.
contains
(
measurementWithAggregation
))
{
continue
;
}
String
pathStrWithAggregation
=
getPathStrWithAggregation
(
path
,
aggregation
);
if
(!
pathWithAggregationSet
.
contains
(
pathStrWithAggregation
))
{
pathWithAggregationSet
.
add
(
pathStrWithAggregation
);
...
...
@@ -209,6 +215,14 @@ public class AlignByDevicePlan extends QueryPlan {
this
.
setOperatorType
(
Operator
.
OperatorType
.
AGGREGATION
);
}
private
String
getMeasurementStrWithAggregation
(
PartialPath
path
,
String
aggregation
)
{
String
measurement
=
path
.
getMeasurement
();
if
(
aggregation
!=
null
)
{
measurement
=
aggregation
+
"("
+
measurement
+
")"
;
}
return
measurement
;
}
private
String
getPathStrWithAggregation
(
PartialPath
path
,
String
aggregation
)
{
String
initialPath
=
path
.
getFullPath
();
if
(
aggregation
!=
null
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录