This is an automated email from the ASF dual-hosted git repository.
hui pushed a commit to branch lmh/groupByTest
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/lmh/groupByTest by this push:
new 4a9813e3a1 add more metric
4a9813e3a1 is described below
commit 4a9813e3a19e0a4442077038928e8e9bf9b70dd1
Author: Minghui Liu <[email protected]>
AuthorDate: Wed Apr 12 11:12:26 2023 +0800
add more metric
---
.../operator/source/AlignedSeriesScanUtil.java | 122 ++++---
.../execution/operator/source/SeriesScanUtil.java | 390 ++++++++++++---------
.../iotdb/db/mpp/statistics/QueryStatistics.java | 48 +++
3 files changed, 339 insertions(+), 221 deletions(-)
diff --git
a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/source/AlignedSeriesScanUtil.java
b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/source/AlignedSeriesScanUtil.java
index ebfe5f87b1..1e1cdd0967 100644
---
a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/source/AlignedSeriesScanUtil.java
+++
b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/source/AlignedSeriesScanUtil.java
@@ -24,6 +24,7 @@ import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
import org.apache.iotdb.db.mpp.execution.fragment.FragmentInstanceContext;
import org.apache.iotdb.db.mpp.plan.planner.plan.parameter.SeriesScanOptions;
import org.apache.iotdb.db.mpp.plan.statement.component.Ordering;
+import org.apache.iotdb.db.mpp.statistics.QueryStatistics;
import org.apache.iotdb.db.query.context.QueryContext;
import
org.apache.iotdb.db.query.reader.universal.AlignedDescPriorityMergeReader;
import org.apache.iotdb.db.query.reader.universal.AlignedPriorityMergeReader;
@@ -130,68 +131,87 @@ public class AlignedSeriesScanUtil extends SeriesScanUtil
{
@Override
protected void filterFirstTimeSeriesMetadata() throws IOException {
- if (firstTimeSeriesMetadata != null
- && !isFileOverlapped()
- && !firstTimeSeriesMetadata.isModified()) {
- Filter queryFilter = scanOptions.getQueryFilter();
- if (queryFilter != null) {
- // TODO accept valueStatisticsList to filter
- if (!queryFilter.satisfy(firstTimeSeriesMetadata.getStatistics())) {
- skipCurrentFile();
- }
- } else {
- // For aligned series, When we only query some measurements under an
aligned device, if the
- // values of these queried measurements at a timestamp are all null,
the timestamp will not
- // be selected.
- // NOTE: if we change the query semantic in the future for aligned
series, we need to remove
- // this check here.
- long rowCount =
- ((AlignedTimeSeriesMetadata)
firstTimeSeriesMetadata).getTimeStatistics().getCount();
- for (Statistics statistics :
- ((AlignedTimeSeriesMetadata)
firstTimeSeriesMetadata).getValueStatisticsList()) {
- if (statistics == null || statistics.hasNullValue(rowCount)) {
- return;
+ long startTime = System.nanoTime();
+ try {
+ if (firstTimeSeriesMetadata != null
+ && !isFileOverlapped()
+ && !firstTimeSeriesMetadata.isModified()) {
+ Filter queryFilter = scanOptions.getQueryFilter();
+ if (queryFilter != null) {
+ // TODO accept valueStatisticsList to filter
+ if (!queryFilter.satisfy(firstTimeSeriesMetadata.getStatistics())) {
+ skipCurrentFile();
+ }
+ } else {
+ // For aligned series, When we only query some measurements under an
aligned device, if
+ // the
+ // values of these queried measurements at a timestamp are all null,
the timestamp will
+ // not
+ // be selected.
+ // NOTE: if we change the query semantic in the future for aligned
series, we need to
+ // remove
+ // this check here.
+ long rowCount =
+ ((AlignedTimeSeriesMetadata)
firstTimeSeriesMetadata).getTimeStatistics().getCount();
+ for (Statistics statistics :
+ ((AlignedTimeSeriesMetadata)
firstTimeSeriesMetadata).getValueStatisticsList()) {
+ if (statistics == null || statistics.hasNullValue(rowCount)) {
+ return;
+ }
+ }
+ // When the number of points in all value chunk groups is the same
as that in the time
+ // chunk
+ // group, it means that there is no null value, and all timestamps
will be selected.
+ if (paginationController.hasCurOffset(rowCount)) {
+ skipCurrentFile();
+ paginationController.consumeOffset(rowCount);
}
- }
- // When the number of points in all value chunk groups is the same as
that in the time chunk
- // group, it means that there is no null value, and all timestamps
will be selected.
- if (paginationController.hasCurOffset(rowCount)) {
- skipCurrentFile();
- paginationController.consumeOffset(rowCount);
}
}
+ } finally {
+ QueryStatistics.getInstance()
+ .addCost(QueryStatistics.FILTER_FIRST_TIMESERIES_METADATA,
System.nanoTime() - startTime);
}
}
@Override
protected void filterFirstChunkMetadata() throws IOException {
- if (firstChunkMetadata != null && !isChunkOverlapped() &&
!firstChunkMetadata.isModified()) {
- Filter queryFilter = scanOptions.getQueryFilter();
- if (queryFilter != null) {
- // TODO accept valueStatisticsList to filter
- if (!queryFilter.satisfy(firstChunkMetadata.getStatistics())) {
- skipCurrentChunk();
- }
- } else {
- // For aligned series, When we only query some measurements under an
aligned device, if the
- // values of these queried measurements at a timestamp are all null,
the timestamp will not
- // be selected.
- // NOTE: if we change the query semantic in the future for aligned
series, we need to remove
- // this check here.
- long rowCount = firstChunkMetadata.getStatistics().getCount();
- for (Statistics statistics :
- ((AlignedChunkMetadata)
firstChunkMetadata).getValueStatisticsList()) {
- if (statistics == null || statistics.hasNullValue(rowCount)) {
- return;
+ long startTime = System.nanoTime();
+ try {
+ if (firstChunkMetadata != null && !isChunkOverlapped() &&
!firstChunkMetadata.isModified()) {
+ Filter queryFilter = scanOptions.getQueryFilter();
+ if (queryFilter != null) {
+ // TODO accept valueStatisticsList to filter
+ if (!queryFilter.satisfy(firstChunkMetadata.getStatistics())) {
+ skipCurrentChunk();
+ }
+ } else {
+ // For aligned series, When we only query some measurements under an
aligned device, if
+ // the
+ // values of these queried measurements at a timestamp are all null,
the timestamp will
+ // not
+ // be selected.
+ // NOTE: if we change the query semantic in the future for aligned
series, we need to
+ // remove
+ // this check here.
+ long rowCount = firstChunkMetadata.getStatistics().getCount();
+ for (Statistics statistics :
+ ((AlignedChunkMetadata)
firstChunkMetadata).getValueStatisticsList()) {
+ if (statistics == null || statistics.hasNullValue(rowCount)) {
+ return;
+ }
+ }
+ // When the number of points in all value chunks is the same as that
in the time chunk, it
+ // means that there is no null value, and all timestamps will be
selected.
+ if (paginationController.hasCurOffset(rowCount)) {
+ skipCurrentChunk();
+ paginationController.consumeOffset(rowCount);
}
- }
- // When the number of points in all value chunks is the same as that
in the time chunk, it
- // means that there is no null value, and all timestamps will be
selected.
- if (paginationController.hasCurOffset(rowCount)) {
- skipCurrentChunk();
- paginationController.consumeOffset(rowCount);
}
}
+ } finally {
+ QueryStatistics.getInstance()
+ .addCost(QueryStatistics.FILTER_FIRST_CHUNK_METADATA,
System.nanoTime() - startTime);
}
}
}
diff --git
a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/source/SeriesScanUtil.java
b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/source/SeriesScanUtil.java
index e9a63abaae..4d5fa8a243 100644
---
a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/source/SeriesScanUtil.java
+++
b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/source/SeriesScanUtil.java
@@ -176,42 +176,48 @@ public class SeriesScanUtil {
}
public boolean hasNextFile() throws IOException {
- if (!paginationController.hasCurLimit()) {
- return false;
- }
+ long startTime = System.nanoTime();
+ try {
+ if (!paginationController.hasCurLimit()) {
+ return false;
+ }
- if (!unSeqPageReaders.isEmpty()
- || firstPageReader != null
- || mergeReader.hasNextTimeValuePair()) {
- throw new IOException(
- "all cached pages should be consumed first
unSeqPageReaders.isEmpty() is "
- + unSeqPageReaders.isEmpty()
- + " firstPageReader != null is "
- + (firstPageReader != null)
- + " mergeReader.hasNextTimeValuePair() = "
- + mergeReader.hasNextTimeValuePair());
- }
+ if (!unSeqPageReaders.isEmpty()
+ || firstPageReader != null
+ || mergeReader.hasNextTimeValuePair()) {
+ throw new IOException(
+ "all cached pages should be consumed first
unSeqPageReaders.isEmpty() is "
+ + unSeqPageReaders.isEmpty()
+ + " firstPageReader != null is "
+ + (firstPageReader != null)
+ + " mergeReader.hasNextTimeValuePair() = "
+ + mergeReader.hasNextTimeValuePair());
+ }
- if (firstChunkMetadata != null || !cachedChunkMetadata.isEmpty()) {
- throw new IOException("all cached chunks should be consumed first");
- }
+ if (firstChunkMetadata != null || !cachedChunkMetadata.isEmpty()) {
+ throw new IOException("all cached chunks should be consumed first");
+ }
- if (firstTimeSeriesMetadata != null) {
- return true;
- }
+ if (firstTimeSeriesMetadata != null) {
+ return true;
+ }
- while (firstTimeSeriesMetadata == null
- && (orderUtils.hasNextSeqResource()
- || orderUtils.hasNextUnseqResource()
- || !seqTimeSeriesMetadata.isEmpty()
- || !unSeqTimeSeriesMetadata.isEmpty())) {
- // init first time series metadata whose startTime is minimum
- tryToUnpackAllOverlappedFilesToTimeSeriesMetadata();
- // filter file based on push-down conditions
- filterFirstTimeSeriesMetadata();
- }
+ while (firstTimeSeriesMetadata == null
+ && (orderUtils.hasNextSeqResource()
+ || orderUtils.hasNextUnseqResource()
+ || !seqTimeSeriesMetadata.isEmpty()
+ || !unSeqTimeSeriesMetadata.isEmpty())) {
+ // init first time series metadata whose startTime is minimum
+ tryToUnpackAllOverlappedFilesToTimeSeriesMetadata();
+ // filter file based on push-down conditions
+ filterFirstTimeSeriesMetadata();
+ }
- return firstTimeSeriesMetadata != null;
+ return firstTimeSeriesMetadata != null;
+ } finally {
+ QueryStatistics.getInstance()
+ .addCost(QueryStatistics.HAS_NEXT_FILE, System.nanoTime() -
startTime);
+ }
}
boolean isFileOverlapped() throws IOException {
@@ -256,52 +262,64 @@ public class SeriesScanUtil {
* overlapped chunks are consumed
*/
public boolean hasNextChunk() throws IOException {
- if (!paginationController.hasCurLimit()) {
- return false;
- }
+ long startTime = System.nanoTime();
+ try {
+ if (!paginationController.hasCurLimit()) {
+ return false;
+ }
- if (!unSeqPageReaders.isEmpty()
- || firstPageReader != null
- || mergeReader.hasNextTimeValuePair()) {
- throw new IOException(
- "all cached pages should be consumed first
unSeqPageReaders.isEmpty() is "
- + unSeqPageReaders.isEmpty()
- + " firstPageReader != null is "
- + (firstPageReader != null)
- + " mergeReader.hasNextTimeValuePair() = "
- + mergeReader.hasNextTimeValuePair());
- }
+ if (!unSeqPageReaders.isEmpty()
+ || firstPageReader != null
+ || mergeReader.hasNextTimeValuePair()) {
+ throw new IOException(
+ "all cached pages should be consumed first
unSeqPageReaders.isEmpty() is "
+ + unSeqPageReaders.isEmpty()
+ + " firstPageReader != null is "
+ + (firstPageReader != null)
+ + " mergeReader.hasNextTimeValuePair() = "
+ + mergeReader.hasNextTimeValuePair());
+ }
- if (firstChunkMetadata != null) {
- return true;
- // hasNextFile() has not been invoked
- } else if (firstTimeSeriesMetadata == null &&
cachedChunkMetadata.isEmpty()) {
- return false;
- }
+ if (firstChunkMetadata != null) {
+ return true;
+ // hasNextFile() has not been invoked
+ } else if (firstTimeSeriesMetadata == null &&
cachedChunkMetadata.isEmpty()) {
+ return false;
+ }
- while (firstChunkMetadata == null && (!cachedChunkMetadata.isEmpty() ||
hasNextFile())) {
- initFirstChunkMetadata();
- // filter chunk based on push-down conditions
- filterFirstChunkMetadata();
+ while (firstChunkMetadata == null && (!cachedChunkMetadata.isEmpty() ||
hasNextFile())) {
+ initFirstChunkMetadata();
+ // filter chunk based on push-down conditions
+ filterFirstChunkMetadata();
+ }
+ return firstChunkMetadata != null;
+ } finally {
+ QueryStatistics.getInstance()
+ .addCost(QueryStatistics.HAS_NEXT_CHUNK, System.nanoTime() -
startTime);
}
- return firstChunkMetadata != null;
}
protected void filterFirstChunkMetadata() throws IOException {
- if (firstChunkMetadata != null && !isChunkOverlapped() &&
!firstChunkMetadata.isModified()) {
- Filter queryFilter = scanOptions.getQueryFilter();
- if (queryFilter != null) {
- if (!queryFilter.satisfy(firstChunkMetadata.getStatistics())) {
- skipCurrentChunk();
- }
- // TODO implement allSatisfied interface for filter, then we can still
skip offset.
- } else {
- long rowCount = firstChunkMetadata.getStatistics().getCount();
- if (paginationController.hasCurOffset(rowCount)) {
- skipCurrentChunk();
- paginationController.consumeOffset(rowCount);
+ long startTime = System.nanoTime();
+ try {
+ if (firstChunkMetadata != null && !isChunkOverlapped() &&
!firstChunkMetadata.isModified()) {
+ Filter queryFilter = scanOptions.getQueryFilter();
+ if (queryFilter != null) {
+ if (!queryFilter.satisfy(firstChunkMetadata.getStatistics())) {
+ skipCurrentChunk();
+ }
+ // TODO implement allSatisfied interface for filter, then we can
still skip offset.
+ } else {
+ long rowCount = firstChunkMetadata.getStatistics().getCount();
+ if (paginationController.hasCurOffset(rowCount)) {
+ skipCurrentChunk();
+ paginationController.consumeOffset(rowCount);
+ }
}
}
+ } finally {
+ QueryStatistics.getInstance()
+ .addCost(QueryStatistics.FILTER_FIRST_CHUNK_METADATA,
System.nanoTime() - startTime);
}
}
@@ -405,60 +423,67 @@ public class SeriesScanUtil {
@SuppressWarnings("squid:S3776")
// Suppress high Cognitive Complexity warning
public boolean hasNextPage() throws IOException {
- if (!paginationController.hasCurLimit()) {
- return false;
- }
+ long startTime = System.nanoTime();
+ try {
+ if (!paginationController.hasCurLimit()) {
+ return false;
+ }
- /*
- * has overlapped data before
- */
- if (hasCachedNextOverlappedPage) {
- return true;
- } else if (mergeReader.hasNextTimeValuePair() || firstPageOverlapped()) {
- if (hasNextOverlappedPage()) {
- cachedTsBlock = nextOverlappedPage();
- if (cachedTsBlock != null && !cachedTsBlock.isEmpty()) {
- hasCachedNextOverlappedPage = true;
- return true;
+ /*
+ * has overlapped data before
+ */
+ if (hasCachedNextOverlappedPage) {
+ return true;
+ } else if (mergeReader.hasNextTimeValuePair() || firstPageOverlapped()) {
+ if (hasNextOverlappedPage()) {
+ cachedTsBlock = nextOverlappedPage();
+ if (cachedTsBlock != null && !cachedTsBlock.isEmpty()) {
+ hasCachedNextOverlappedPage = true;
+ return true;
+ }
}
}
- }
- if (firstPageReader != null) {
- return true;
- }
+ if (firstPageReader != null) {
+ return true;
+ }
- /*
- * construct first page reader
- */
- if (firstChunkMetadata != null) {
/*
- * try to unpack all overlapped ChunkMetadata to cachedPageReaders
+ * construct first page reader
*/
- unpackAllOverlappedChunkMetadataToPageReaders(
- orderUtils.getOverlapCheckTime(firstChunkMetadata.getStatistics()),
true);
- } else {
- /*
- * first chunk metadata is already unpacked, consume cached pages
- */
- initFirstPageReader();
- }
+ if (firstChunkMetadata != null) {
+ /*
+ * try to unpack all overlapped ChunkMetadata to cachedPageReaders
+ */
+ unpackAllOverlappedChunkMetadataToPageReaders(
+
orderUtils.getOverlapCheckTime(firstChunkMetadata.getStatistics()), true);
+ } else {
+ /*
+ * first chunk metadata is already unpacked, consume cached pages
+ */
+ initFirstPageReader();
+ }
- if (isExistOverlappedPage()) {
- return true;
- }
+ if (isExistOverlappedPage()) {
+ return true;
+ }
- // make sure firstPageReader won't be null while the unSeqPageReaders has
more cached page
- // readers
- while (firstPageReader == null && (!seqPageReaders.isEmpty() ||
!unSeqPageReaders.isEmpty())) {
+ // make sure firstPageReader won't be null while the unSeqPageReaders
has more cached page
+ // readers
+ while (firstPageReader == null
+ && (!seqPageReaders.isEmpty() || !unSeqPageReaders.isEmpty())) {
- initFirstPageReader();
+ initFirstPageReader();
- if (isExistOverlappedPage()) {
- return true;
+ if (isExistOverlappedPage()) {
+ return true;
+ }
}
+ return firstPageReader != null;
+ } finally {
+ QueryStatistics.getInstance()
+ .addCost(QueryStatistics.HAS_NEXT_PAGE, System.nanoTime() -
startTime);
}
- return firstPageReader != null;
}
private boolean isExistOverlappedPage() throws IOException {
@@ -847,11 +872,13 @@ public class SeriesScanUtil {
}
}
} finally {
+ long costTime = System.nanoTime() - startTime;
QUERY_METRICS.recordSeriesScanCost(
isAligned
? BUILD_TSBLOCK_FROM_MERGE_READER_ALIGNED
: BUILD_TSBLOCK_FROM_MERGE_READER_NONALIGNED,
- System.nanoTime() - startTime);
+ costTime);
+
QueryStatistics.getInstance().addCost(QueryStatistics.HAS_NEXT_OVERLAPPED_PAGE,
costTime);
}
}
@@ -893,31 +920,37 @@ public class SeriesScanUtil {
}
private void initFirstPageReader() throws IOException {
- while (this.firstPageReader == null) {
- VersionPageReader firstPageReader =
getFirstPageReaderFromCachedReaders();
-
- // unpack overlapped page using current page reader
- if (firstPageReader != null) {
- long overlapCheckTime =
orderUtils.getOverlapCheckTime(firstPageReader.getStatistics());
- unpackAllOverlappedTsFilesToTimeSeriesMetadata(overlapCheckTime);
-
unpackAllOverlappedTimeSeriesMetadataToCachedChunkMetadata(overlapCheckTime,
false);
- unpackAllOverlappedChunkMetadataToPageReaders(overlapCheckTime, false);
-
- // this page after unpacking must be the first page
- if (firstPageReader.equals(getFirstPageReaderFromCachedReaders())) {
- this.firstPageReader = firstPageReader;
- if (!seqPageReaders.isEmpty() &&
firstPageReader.equals(seqPageReaders.get(0))) {
- seqPageReaders.remove(0);
- break;
- } else if (!unSeqPageReaders.isEmpty()
- && firstPageReader.equals(unSeqPageReaders.peek())) {
- unSeqPageReaders.poll();
- break;
+ long startTime = System.nanoTime();
+ try {
+ while (this.firstPageReader == null) {
+ VersionPageReader firstPageReader =
getFirstPageReaderFromCachedReaders();
+
+ // unpack overlapped page using current page reader
+ if (firstPageReader != null) {
+ long overlapCheckTime =
orderUtils.getOverlapCheckTime(firstPageReader.getStatistics());
+ unpackAllOverlappedTsFilesToTimeSeriesMetadata(overlapCheckTime);
+
unpackAllOverlappedTimeSeriesMetadataToCachedChunkMetadata(overlapCheckTime,
false);
+ unpackAllOverlappedChunkMetadataToPageReaders(overlapCheckTime,
false);
+
+ // this page after unpacking must be the first page
+ if (firstPageReader.equals(getFirstPageReaderFromCachedReaders())) {
+ this.firstPageReader = firstPageReader;
+ if (!seqPageReaders.isEmpty() &&
firstPageReader.equals(seqPageReaders.get(0))) {
+ seqPageReaders.remove(0);
+ break;
+ } else if (!unSeqPageReaders.isEmpty()
+ && firstPageReader.equals(unSeqPageReaders.peek())) {
+ unSeqPageReaders.poll();
+ break;
+ }
}
+ } else {
+ return;
}
- } else {
- return;
}
+ } finally {
+ QueryStatistics.getInstance()
+ .addCost(QueryStatistics.INIT_FIRST_PAGE, System.nanoTime() -
startTime);
}
}
@@ -996,18 +1029,23 @@ public class SeriesScanUtil {
* find end time of the first TimeSeriesMetadata
*/
long endTime = -1L;
- if (!seqTimeSeriesMetadata.isEmpty() && unSeqTimeSeriesMetadata.isEmpty())
{
- // only has seq
- endTime =
orderUtils.getOverlapCheckTime(seqTimeSeriesMetadata.get(0).getStatistics());
- } else if (seqTimeSeriesMetadata.isEmpty() &&
!unSeqTimeSeriesMetadata.isEmpty()) {
- // only has unseq
- endTime =
orderUtils.getOverlapCheckTime(unSeqTimeSeriesMetadata.peek().getStatistics());
- } else if (!seqTimeSeriesMetadata.isEmpty()) {
- // has seq and unseq
- endTime =
- orderUtils.getCurrentEndPoint(
- seqTimeSeriesMetadata.get(0).getStatistics(),
- unSeqTimeSeriesMetadata.peek().getStatistics());
+ long t1 = System.nanoTime();
+ try {
+ if (!seqTimeSeriesMetadata.isEmpty() &&
unSeqTimeSeriesMetadata.isEmpty()) {
+ // only has seq
+ endTime =
orderUtils.getOverlapCheckTime(seqTimeSeriesMetadata.get(0).getStatistics());
+ } else if (seqTimeSeriesMetadata.isEmpty() &&
!unSeqTimeSeriesMetadata.isEmpty()) {
+ // only has unseq
+ endTime =
orderUtils.getOverlapCheckTime(unSeqTimeSeriesMetadata.peek().getStatistics());
+ } else if (!seqTimeSeriesMetadata.isEmpty()) {
+ // has seq and unseq
+ endTime =
+ orderUtils.getCurrentEndPoint(
+ seqTimeSeriesMetadata.get(0).getStatistics(),
+ unSeqTimeSeriesMetadata.peek().getStatistics());
+ }
+ } finally {
+ QueryStatistics.getInstance().addCost(QueryStatistics.FIND_END_TIME,
System.nanoTime() - t1);
}
/*
@@ -1020,41 +1058,53 @@ public class SeriesScanUtil {
/*
* update the first TimeSeriesMetadata
*/
- if (!seqTimeSeriesMetadata.isEmpty() && unSeqTimeSeriesMetadata.isEmpty())
{
- // only has seq
- firstTimeSeriesMetadata = seqTimeSeriesMetadata.remove(0);
- } else if (seqTimeSeriesMetadata.isEmpty() &&
!unSeqTimeSeriesMetadata.isEmpty()) {
- // only has unseq
- firstTimeSeriesMetadata = unSeqTimeSeriesMetadata.poll();
- } else if (!seqTimeSeriesMetadata.isEmpty()) {
- // has seq and unseq
- if (orderUtils.isTakeSeqAsFirst(
- seqTimeSeriesMetadata.get(0).getStatistics(),
- unSeqTimeSeriesMetadata.peek().getStatistics())) {
+ t1 = System.nanoTime();
+ try {
+ if (!seqTimeSeriesMetadata.isEmpty() &&
unSeqTimeSeriesMetadata.isEmpty()) {
+ // only has seq
firstTimeSeriesMetadata = seqTimeSeriesMetadata.remove(0);
- } else {
+ } else if (seqTimeSeriesMetadata.isEmpty() &&
!unSeqTimeSeriesMetadata.isEmpty()) {
+ // only has unseq
firstTimeSeriesMetadata = unSeqTimeSeriesMetadata.poll();
+ } else if (!seqTimeSeriesMetadata.isEmpty()) {
+ // has seq and unseq
+ if (orderUtils.isTakeSeqAsFirst(
+ seqTimeSeriesMetadata.get(0).getStatistics(),
+ unSeqTimeSeriesMetadata.peek().getStatistics())) {
+ firstTimeSeriesMetadata = seqTimeSeriesMetadata.remove(0);
+ } else {
+ firstTimeSeriesMetadata = unSeqTimeSeriesMetadata.poll();
+ }
}
+ } finally {
+ QueryStatistics.getInstance()
+ .addCost(QueryStatistics.PICK_FIRST_TIMESERIES_METADATA,
System.nanoTime() - t1);
}
}
protected void filterFirstTimeSeriesMetadata() throws IOException {
- if (firstTimeSeriesMetadata != null
- && !isFileOverlapped()
- && !firstTimeSeriesMetadata.isModified()) {
- Filter queryFilter = scanOptions.getQueryFilter();
- if (queryFilter != null) {
- if (!queryFilter.satisfy(firstTimeSeriesMetadata.getStatistics())) {
- skipCurrentFile();
- }
- // TODO implement allSatisfied interface for filter, then we can still
skip offset.
- } else {
- long rowCount = firstTimeSeriesMetadata.getStatistics().getCount();
- if (paginationController.hasCurOffset(rowCount)) {
- skipCurrentFile();
- paginationController.consumeOffset(rowCount);
+ long startTime = System.nanoTime();
+ try {
+ if (firstTimeSeriesMetadata != null
+ && !isFileOverlapped()
+ && !firstTimeSeriesMetadata.isModified()) {
+ Filter queryFilter = scanOptions.getQueryFilter();
+ if (queryFilter != null) {
+ if (!queryFilter.satisfy(firstTimeSeriesMetadata.getStatistics())) {
+ skipCurrentFile();
+ }
+ // TODO implement allSatisfied interface for filter, then we can
still skip offset.
+ } else {
+ long rowCount = firstTimeSeriesMetadata.getStatistics().getCount();
+ if (paginationController.hasCurOffset(rowCount)) {
+ skipCurrentFile();
+ paginationController.consumeOffset(rowCount);
+ }
}
}
+ } finally {
+ QueryStatistics.getInstance()
+ .addCost(QueryStatistics.FILTER_FIRST_TIMESERIES_METADATA,
System.nanoTime() - startTime);
}
}
diff --git
a/server/src/main/java/org/apache/iotdb/db/mpp/statistics/QueryStatistics.java
b/server/src/main/java/org/apache/iotdb/db/mpp/statistics/QueryStatistics.java
index fbb49c0631..387db02499 100644
---
a/server/src/main/java/org/apache/iotdb/db/mpp/statistics/QueryStatistics.java
+++
b/server/src/main/java/org/apache/iotdb/db/mpp/statistics/QueryStatistics.java
@@ -160,6 +160,18 @@ public class QueryStatistics {
public static final String TIME_SERIES_METADATA_CACHE_MISS =
"TimeSeriesMetadataCacheMiss";
public static final String CHUNK_CACHE_MISS = "ChunkCacheMiss";
+ public static final String HAS_NEXT_FILE = "hasNextFile";
+ public static final String HAS_NEXT_CHUNK = "hasNextChunk";
+ public static final String HAS_NEXT_PAGE = "hasNextPage";
+ public static final String HAS_NEXT_OVERLAPPED_PAGE =
"hasNextOverlappedPage";
+
+ public static final String FILTER_FIRST_TIMESERIES_METADATA =
"filterFirstTimeSeriesMetadata";
+ public static final String FILTER_FIRST_CHUNK_METADATA =
"filterFirstChunkMetadata";
+
+ public static final String FIND_END_TIME = "findEndTime";
+ public static final String PICK_FIRST_TIMESERIES_METADATA =
"pickFirstTimeSeriesMetadata";
+ public static final String INIT_FIRST_PAGE = "initFirstPage";
+
private QueryStatistics() {
ScheduledExecutorService scheduledExecutor =
IoTDBThreadPoolFactory.newScheduledThreadPool(1,
"Query-Statistics-Print");
@@ -346,6 +358,42 @@ public class QueryStatistics {
.append("| | |___BuildAggRes ")
.append(operationStatistics.get(BUILD_AGG_RES))
.append(System.lineSeparator());
+ builder
+ .append("| | |___hasNextFile ")
+ .append(operationStatistics.get(HAS_NEXT_FILE))
+ .append(System.lineSeparator());
+ builder
+ .append("| | |___hasNextChunk ")
+ .append(operationStatistics.get(HAS_NEXT_CHUNK))
+ .append(System.lineSeparator());
+ builder
+ .append("| | |___hasNextPage ")
+ .append(operationStatistics.get(HAS_NEXT_PAGE))
+ .append(System.lineSeparator());
+ builder
+ .append("| | |___hasNextOverlappedPage ")
+ .append(operationStatistics.get(HAS_NEXT_OVERLAPPED_PAGE))
+ .append(System.lineSeparator());
+ builder
+ .append("| | |___filterFirstTimeSeriesMetadata ")
+ .append(operationStatistics.get(FILTER_FIRST_TIMESERIES_METADATA))
+ .append(System.lineSeparator());
+ builder
+ .append("| | |___filterFirstChunkMetadata ")
+ .append(operationStatistics.get(FILTER_FIRST_CHUNK_METADATA))
+ .append(System.lineSeparator());
+ builder
+ .append("| | |___findEndTime ")
+ .append(operationStatistics.get(FIND_END_TIME))
+ .append(System.lineSeparator());
+ builder
+ .append("| | |___pickFirstTimeSeriesMetadata ")
+ .append(operationStatistics.get(PICK_FIRST_TIMESERIES_METADATA))
+ .append(System.lineSeparator());
+ builder
+ .append("| | |___initFirstPage ")
+ .append(operationStatistics.get(INIT_FIRST_PAGE))
+ .append(System.lineSeparator());
builder
.append("| |___SendTsBlock ")
.append(operationStatistics.get(SEND_TSBLOCK))