This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch QueryMetrics0.13
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/QueryMetrics0.13 by this push:
new a41ef78a2b fix bug
a41ef78a2b is described below
commit a41ef78a2bc9a460aeba75311d3f970781ac6c21
Author: JackieTien97 <[email protected]>
AuthorDate: Fri Nov 11 13:54:49 2022 +0800
fix bug
---
.../iotdb/db/query/control/QueryStatistics.java | 2 -
.../reader/series/SeriesRawDataBatchReader.java | 66 +++++++++-------------
.../db/service/thrift/impl/TSServiceImpl.java | 17 +++---
3 files changed, 38 insertions(+), 47 deletions(-)
diff --git
a/server/src/main/java/org/apache/iotdb/db/query/control/QueryStatistics.java
b/server/src/main/java/org/apache/iotdb/db/query/control/QueryStatistics.java
index af40cc1bd4..c07fb59310 100644
---
a/server/src/main/java/org/apache/iotdb/db/query/control/QueryStatistics.java
+++
b/server/src/main/java/org/apache/iotdb/db/query/control/QueryStatistics.java
@@ -49,8 +49,6 @@ public class QueryStatistics {
public static final String INIT_QUERY_DATASET = "InitQueryDataset";
public static final String QUERY_EXECUTION = "QueryExecution";
- public static final String SERIES_RAW_DATA_BATCH_READER_NEXT =
- "SeriesRawDataBatchReader.nextBatch()";
public static final String SERIES_RAW_DATA_BATCH_READER_HAS_NEXT =
"SeriesRawDataBatchReader.hasNextBatch()";
public static final String PAGE_READER = "PageReader";
diff --git
a/server/src/main/java/org/apache/iotdb/db/query/reader/series/SeriesRawDataBatchReader.java
b/server/src/main/java/org/apache/iotdb/db/query/reader/series/SeriesRawDataBatchReader.java
index 693cee134b..beb0c96903 100644
---
a/server/src/main/java/org/apache/iotdb/db/query/reader/series/SeriesRawDataBatchReader.java
+++
b/server/src/main/java/org/apache/iotdb/db/query/reader/series/SeriesRawDataBatchReader.java
@@ -104,58 +104,48 @@ public class SeriesRawDataBatchReader implements
ManagedSeriesReader {
public boolean hasNextBatch() throws IOException {
long startTime = System.nanoTime();
- if (hasCachedBatchData) {
- QUERY_STATISTICS.addCost(
- QueryStatistics.SERIES_RAW_DATA_BATCH_READER_HAS_NEXT,
System.nanoTime() - startTime);
- return true;
- }
-
- /*
- * consume page data firstly
- */
- if (readPageData()) {
- hasCachedBatchData = true;
- QUERY_STATISTICS.addCost(
- QueryStatistics.SERIES_RAW_DATA_BATCH_READER_HAS_NEXT,
System.nanoTime() - startTime);
- return true;
- }
+ try {
+ if (hasCachedBatchData) {
+ return true;
+ }
- /*
- * consume chunk data secondly
- */
- if (readChunkData()) {
- hasCachedBatchData = true;
- QUERY_STATISTICS.addCost(
- QueryStatistics.SERIES_RAW_DATA_BATCH_READER_HAS_NEXT,
System.nanoTime() - startTime);
- return true;
- }
+ /*
+ * consume page data firstly
+ */
+ if (readPageData()) {
+ hasCachedBatchData = true;
+ return true;
+ }
- /*
- * consume next file finally
- */
- while (seriesReader.hasNextFile()) {
+ /*
+ * consume chunk data secondly
+ */
if (readChunkData()) {
hasCachedBatchData = true;
- QUERY_STATISTICS.addCost(
- QueryStatistics.SERIES_RAW_DATA_BATCH_READER_HAS_NEXT,
System.nanoTime() - startTime);
return true;
}
- }
- QUERY_STATISTICS.addCost(
- QueryStatistics.SERIES_RAW_DATA_BATCH_READER_HAS_NEXT,
System.nanoTime() - startTime);
- return hasCachedBatchData;
+ /*
+ * consume next file finally
+ */
+ while (seriesReader.hasNextFile()) {
+ if (readChunkData()) {
+ hasCachedBatchData = true;
+ return true;
+ }
+ }
+ return hasCachedBatchData;
+ } finally {
+ QUERY_STATISTICS.addCost(
+ QueryStatistics.SERIES_RAW_DATA_BATCH_READER_HAS_NEXT,
System.nanoTime() - startTime);
+ }
}
@Override
public BatchData nextBatch() throws IOException {
- long startTime = System.nanoTime();
if (hasCachedBatchData || hasNextBatch()) {
hasCachedBatchData = false;
-
- QUERY_STATISTICS.addCost(
- QueryStatistics.SERIES_RAW_DATA_BATCH_READER_NEXT, System.nanoTime()
- startTime);
return batchData;
}
throw new IOException("no next batch");
diff --git
a/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java
b/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java
index e0b99aae43..d8102cbe08 100644
---
a/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java
+++
b/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/TSServiceImpl.java
@@ -855,10 +855,7 @@ public class TSServiceImpl implements TSIService.Iface {
resp.setNonAlignQueryDataSet(fillRpcNonAlignReturnData(fetchSize,
newDataSet, username));
} else {
try {
- long startTime = System.nanoTime();
TSQueryDataSet tsQueryDataSet = fillRpcReturnData(fetchSize,
newDataSet, username);
- QueryStatistics.getInstance()
- .addCost(QueryStatistics.QUERY_EXECUTION, System.nanoTime() -
startTime);
resp.setQueryDataSet(tsQueryDataSet);
} catch (RedirectException e) {
if (plan.isEnableRedirect()) {
@@ -1035,10 +1032,16 @@ public class TSServiceImpl implements TSIService.Iface {
private TSQueryDataSet fillRpcReturnData(
int fetchSize, QueryDataSet queryDataSet, String userName)
throws TException, AuthException, IOException, InterruptedException,
QueryProcessException {
- WatermarkEncoder encoder = getWatermarkEncoder(userName);
- return queryDataSet instanceof DirectAlignByTimeDataSet
- ? ((DirectAlignByTimeDataSet) queryDataSet).fillBuffer(fetchSize,
encoder)
- : QueryDataSetUtils.convertQueryDataSetByFetchSize(queryDataSet,
fetchSize, encoder);
+ long startTime = System.nanoTime();
+ try {
+ WatermarkEncoder encoder = getWatermarkEncoder(userName);
+ return queryDataSet instanceof DirectAlignByTimeDataSet
+ ? ((DirectAlignByTimeDataSet) queryDataSet).fillBuffer(fetchSize,
encoder)
+ : QueryDataSetUtils.convertQueryDataSetByFetchSize(queryDataSet,
fetchSize, encoder);
+ } finally {
+ QueryStatistics.getInstance()
+ .addCost(QueryStatistics.QUERY_EXECUTION, System.nanoTime() -
startTime);
+ }
}
private TSQueryNonAlignDataSet fillRpcNonAlignReturnData(