You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hu...@apache.org on 2023/03/27 01:58:07 UTC
[iotdb] 01/13: (tmp save)
This is an automated email from the ASF dual-hosted git repository.
hui pushed a commit to branch lmh/fileScan
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 1d63214b3c838ee9013746e1ef5404420c22de70
Author: Minghui Liu <li...@foxmail.com>
AuthorDate: Fri Mar 3 10:44:47 2023 +0800
(tmp save)
---
.../execution/operator/source/FileScanUtil.java | 61 ++++++++++++++++++++++
.../materializer/TsFileResourceMaterializer.java | 56 ++++++++++++++++++++
2 files changed, 117 insertions(+)
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/source/FileScanUtil.java b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/source/FileScanUtil.java
new file mode 100644
index 0000000000..bb0bd014d8
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/source/FileScanUtil.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.execution.operator.source;
+
+import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.db.engine.querycontext.QueryDataSource;
+import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
+import org.apache.iotdb.db.mpp.aggregation.Aggregator;
+import org.apache.iotdb.db.query.reader.materializer.TsFileResourceMaterializer;
+import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
+import org.apache.iotdb.tsfile.file.metadata.ITimeSeriesMetadata;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeSet;
+
+public class FileScanUtil {
+
+ private final Map<PartialPath, List<Aggregator>> pathToAggregatorsMap;
+
+ private final TsFileResourceMaterializer fileResourceMaterializer;
+
+ private final TreeSet<ChunkMetadata> chunkMetadataList =
+ new TreeSet<>(
+ Comparator.comparingLong(ChunkMetadata::getVersion)
+ .thenComparingLong(ChunkMetadata::getOffsetOfChunkHeader));
+
+ public FileScanUtil(
+ Map<PartialPath, List<Aggregator>> pathToAggregatorsMap, QueryDataSource dataSource) {
+ this.pathToAggregatorsMap = pathToAggregatorsMap;
+ this.fileResourceMaterializer = new TsFileResourceMaterializer(dataSource);
+ }
+
+ public boolean hasNextFile() {
+ return fileResourceMaterializer.hasNext();
+ }
+
+ public void consume() {
+ TsFileResource nextFile = fileResourceMaterializer.next();
+
+ List<ITimeSeriesMetadata> timeSeriesMetadata;
+ }
+}
diff --git a/server/src/main/java/org/apache/iotdb/db/query/reader/materializer/TsFileResourceMaterializer.java b/server/src/main/java/org/apache/iotdb/db/query/reader/materializer/TsFileResourceMaterializer.java
new file mode 100644
index 0000000000..e5e1c0bc77
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/query/reader/materializer/TsFileResourceMaterializer.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.query.reader.materializer;
+
+import org.apache.iotdb.db.engine.querycontext.QueryDataSource;
+import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
+
+public class TsFileResourceMaterializer {
+
+ private final QueryDataSource tsFileResourceSource;
+
+ // file index
+ private int curSeqFileIndex;
+ private int curUnSeqFileIndex;
+
+ public TsFileResourceMaterializer(QueryDataSource tsFileResourceSource) {
+ this.tsFileResourceSource = tsFileResourceSource;
+ curSeqFileIndex = curUnSeqFileIndex = 0;
+ }
+
+ public boolean hasNext() {
+ return tsFileResourceSource.hasNextSeqResource(curSeqFileIndex, true)
+ || tsFileResourceSource.hasNextUnseqResource(curUnSeqFileIndex);
+ }
+
+ public TsFileResource next() {
+ if (tsFileResourceSource.hasNextSeqResource(curSeqFileIndex, true)) {
+ TsFileResource nextFile = tsFileResourceSource.getSeqResourceByIndex(curUnSeqFileIndex);
+ curSeqFileIndex++;
+ return nextFile;
+ } else if (tsFileResourceSource.hasNextUnseqResource(curUnSeqFileIndex)) {
+ TsFileResource nextFile = tsFileResourceSource.getUnseqResourceByIndex(curUnSeqFileIndex);
+ curUnSeqFileIndex++;
+ return nextFile;
+ } else {
+ throw new IllegalStateException("");
+ }
+ }
+}