This is an automated email from the ASF dual-hosted git repository.
lta pushed a commit to branch fix_bug_of_read_with_filter
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/fix_bug_of_read_with_filter by
this push:
new ee729ca add hasCachedRowRecord
ee729ca is described below
commit ee729caa1f5958c38ae1e96bc2c5a430ab8c8209
Author: lta <[email protected]>
AuthorDate: Mon Apr 8 00:46:01 2019 +0800
add hasCachedRowRecord
---
.../dataset/EngineDataSetWithTimeGenerator.java | 24 +++++++++++-----------
.../iotdb/db/integration/IoTDBLimitSlimitIT.java | 4 ++--
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/query/dataset/EngineDataSetWithTimeGenerator.java
b/iotdb/src/main/java/org/apache/iotdb/db/query/dataset/EngineDataSetWithTimeGenerator.java
index e8ced51..6e76e66 100644
---
a/iotdb/src/main/java/org/apache/iotdb/db/query/dataset/EngineDataSetWithTimeGenerator.java
+++
b/iotdb/src/main/java/org/apache/iotdb/db/query/dataset/EngineDataSetWithTimeGenerator.java
@@ -34,6 +34,7 @@ public class EngineDataSetWithTimeGenerator extends
QueryDataSet {
private EngineTimeGenerator timeGenerator;
private List<EngineReaderByTimeStamp> readers;
+ private boolean hasCachedRowRecord;
private RowRecord cachedRowRecord;
/**
@@ -53,7 +54,7 @@ public class EngineDataSetWithTimeGenerator extends
QueryDataSet {
@Override
public boolean hasNext() throws IOException {
- if (cachedRowRecord != null) {
+ if (hasCachedRowRecord) {
return true;
}
return cacheRowRecord();
@@ -61,12 +62,11 @@ public class EngineDataSetWithTimeGenerator extends
QueryDataSet {
@Override
public RowRecord next() throws IOException {
- if (cachedRowRecord == null) {
- cacheRowRecord();
+ if (!hasCachedRowRecord && !cacheRowRecord()) {
+ return null;
}
- RowRecord tempRecord = cachedRowRecord;
- cachedRowRecord = null;
- return tempRecord;
+ hasCachedRowRecord = false;
+ return cachedRowRecord;
}
/**
@@ -76,7 +76,7 @@ public class EngineDataSetWithTimeGenerator extends
QueryDataSet {
*/
private boolean cacheRowRecord() throws IOException {
while (timeGenerator.hasNext()) {
- boolean markNull = true;
+ boolean hasField = false;
long timestamp = timeGenerator.next();
RowRecord rowRecord = new RowRecord(timestamp);
for (int i = 0; i < readers.size(); i++) {
@@ -85,17 +85,17 @@ public class EngineDataSetWithTimeGenerator extends
QueryDataSet {
if (value == null) {
rowRecord.addField(new Field(null));
} else {
- markNull = false;
+ hasField = true;
rowRecord.addField(getField(value, dataTypes.get(i)));
}
}
- if (!markNull) {
+ if (hasField) {
+ hasCachedRowRecord = true;
cachedRowRecord = rowRecord;
- return true;
+ break;
}
}
- cachedRowRecord = null;
- return false;
+ return hasCachedRowRecord;
}
private Field getField(Object value, TSDataType dataType) {
diff --git
a/iotdb/src/test/java/org/apache/iotdb/db/integration/IoTDBLimitSlimitIT.java
b/iotdb/src/test/java/org/apache/iotdb/db/integration/IoTDBLimitSlimitIT.java
index 6153f69..b3ebbf9 100644
---
a/iotdb/src/test/java/org/apache/iotdb/db/integration/IoTDBLimitSlimitIT.java
+++
b/iotdb/src/test/java/org/apache/iotdb/db/integration/IoTDBLimitSlimitIT.java
@@ -151,7 +151,7 @@ public class IoTDBLimitSlimitIT {
+ "1000,1000.11,\n",
"select * from root.vehicle.d0 where s1>190 or s2 < 10.0 limit 3
offset 1 slimit 1 soffset 2 ",
- "2,2.22,\n" + "3,3.33,\n" + "4,4.44,\n"
+ "3,3.33,\n" + "4,4.44,\n" + "105,11.11,\n"
};
executeSQL(sqlS);
@@ -167,7 +167,7 @@ public class IoTDBLimitSlimitIT {
connection = DriverManager
.getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",
"root");
for (String sql : sqls) {
- // System.out.println("----" + sql);
+// System.out.println("----" + sql);
if (cmp) {
Assert.assertEquals(sql, result);
cmp = false;