This is an automated email from the ASF dual-hosted git repository.
suyue pushed a commit to branch aggregate
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/aggregate by this push:
new e53204c fix bug of no time-bound filling
e53204c is described below
commit e53204ccb52ccdf67e4652d73aae1bce5eafba80
Author: suyue <[email protected]>
AuthorDate: Mon Mar 25 09:27:02 2019 +0800
fix bug of no time-bound filling
---
.../org/apache/iotdb/db/query/fill/LinearFill.java | 6 +++
.../iotdb/db/integration/IOTDBFillTestIT.java | 49 ++++++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/query/fill/LinearFill.java
b/iotdb/src/main/java/org/apache/iotdb/db/query/fill/LinearFill.java
index cab3f36..4f8d489 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/query/fill/LinearFill.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/query/fill/LinearFill.java
@@ -98,6 +98,12 @@ public class LinearFill extends IFill {
if (afterPair == null) {
afterPair = allDataReader.next();
}
+
+ //if afterRange equals -1, this means that there is no time-bound filling.
+ if (afterRange == -1) {
+ return new TimeValuePairPointReader(average(beforePair, afterPair));
+ }
+
if (afterPair.getTimestamp() > queryTime + afterRange) {
return new TimeValuePairPointReader(null);
}
diff --git
a/iotdb/src/test/java/org/apache/iotdb/db/integration/IOTDBFillTestIT.java
b/iotdb/src/test/java/org/apache/iotdb/db/integration/IOTDBFillTestIT.java
index 7479f6e..b39e6b7 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/integration/IOTDBFillTestIT.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/integration/IOTDBFillTestIT.java
@@ -220,6 +220,55 @@ public class IOTDBFillTestIT {
}
}
+ @Test
+ public void EmptyTimeRangeFillTest() throws SQLException {
+ String[] retArray1 = new String[]{
+ "3,3.3,false,33",
+ "70,70.34,false,374"
+ };
+ Connection connection = null;
+ try {
+ connection = DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/",
"root", "root");
+ Statement statement = connection.createStatement();
+ boolean hasResultSet = statement.execute("select temperature,status,
hardware from root.ln.wf01.wt01 where time = 3 "
+ + "Fill(int32[linear], double[linear], boolean[previous])");
+
+ Assert.assertTrue(hasResultSet);
+ ResultSet resultSet = statement.getResultSet();
+ int cnt = 0;
+ while (resultSet.next()) {
+ String ans = resultSet.getString(TIMESTAMP_STR) + "," +
resultSet.getString("root.ln.wf01.wt01.temperature")
+ + "," + resultSet.getString("root.ln.wf01.wt01.status")+ "," +
resultSet.getString("root.ln.wf01.wt01.hardware");
+ Assert.assertEquals(retArray1[cnt], ans);
+ cnt++;
+ }
+ statement.close();
+
+ statement = connection.createStatement();
+ hasResultSet = statement.execute("select temperature,status, hardware
from root.ln.wf01.wt01 where time = 70 "
+ + "Fill(int32[linear], double[linear], boolean[previous])");
+
+ Assert.assertTrue(hasResultSet);
+ resultSet = statement.getResultSet();
+ while (resultSet.next()) {
+ String ans = resultSet.getString(TIMESTAMP_STR) + "," +
resultSet.getString("root.ln.wf01.wt01.temperature")
+ + "," + resultSet.getString("root.ln.wf01.wt01.status")+ "," +
resultSet.getString("root.ln.wf01.wt01.hardware");
+ Assert.assertEquals(retArray1[cnt], ans);
+ cnt++;
+ System.out.println(ans);
+ }
+ statement.close();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ }
+ }
+
private void prepareData() throws SQLException {
Connection connection = null;
try {