qiaojialin commented on a change in pull request #1100:
URL: https://github.com/apache/incubator-iotdb/pull/1100#discussion_r416282064
##########
File path:
spark-tsfile/src/main/scala/org/apache/iotdb/spark/tsfile/WideConverter.scala
##########
@@ -92,7 +92,7 @@ object WideConverter extends Converter {
val in = new HDFSInput(f.getPath, conf)
val reader = new TsFileSequenceReader(in)
val tsFileMetaData = reader.readFileMetadata
- val devices = tsFileMetaData.getDeviceMetadataIndex.keySet()
+ val devices = tsFileMetaData.getMetadataIndex
Review comment:
getAllDevices
##########
File path:
server/src/main/java/org/apache/iotdb/db/writelog/recover/TsFileRecoverPerformer.java
##########
@@ -157,11 +156,7 @@ private void recoverResourceFromFile() throws IOException {
private void recoverResourceFromReader() throws IOException {
try (TsFileSequenceReader reader =
new TsFileSequenceReader(resource.getFile().getAbsolutePath(), false))
{
- TsFileMetadata fileMetadata = reader.readFileMetadata();
-
- Map<String, Pair<Long, Integer>> deviceMetaDataMap =
fileMetadata.getDeviceMetadataIndex();
- for (Map.Entry<String, Pair<Long, Integer>> entry:
deviceMetaDataMap.entrySet()) {
- String deviceId = entry.getKey();
+ for (String deviceId : reader.getAllDevices()) {
Review comment:
readAllTimeseriesMetadata
##########
File path:
spark-tsfile/src/main/scala/org/apache/iotdb/spark/tsfile/WideConverter.scala
##########
@@ -133,7 +133,7 @@ object WideConverter extends Converter {
} else { // Remove nonexistent schema according to the current file's
metadata.
// This may happen when queried TsFiles in the same folder do not have
the same schema.
- val devices = tsFileMetaData.getDeviceMetadataIndex.keySet()
+ val devices = tsFileMetaData.getMetadataIndex
Review comment:
getAllDevices
##########
File path:
spark-tsfile/src/main/scala/org/apache/iotdb/spark/tsfile/WideConverter.scala
##########
@@ -62,7 +62,7 @@ object WideConverter extends Converter {
def getSeries(tsFileMetaData: TsFileMetadata, reader: TsFileSequenceReader):
util.ArrayList[Series] = {
val series = new util.ArrayList[Series]()
- val devices = tsFileMetaData.getDeviceMetadataIndex.keySet()
+ val devices = tsFileMetaData.getMetadataIndex
Review comment:
this should be getAllDevices
##########
File path:
tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/MetadataIndexNode.java
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.tsfile.file.metadata;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import org.apache.iotdb.tsfile.file.metadata.enums.MetadataIndexNodeType;
+import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
+
+public class MetadataIndexNode {
+
+ private String name;
+ private long offset;
+ private MetadataIndexNodeType metadataIndexNodeType;
Review comment:
```suggestion
// type of the child node at offset
private MetadataIndexNodeType childNodeType;
```
##########
File path:
tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/MetadataIndexNodeType.java
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.tsfile.file.metadata.enums;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+public enum MetadataIndexNodeType {
+ INTERNAL_DEVICE, LEAF_DEVICE, INTERNAL_MEASUREMENT, LEAF_MEASUREMENT;
+
+ /**
+ * deserialize short number.
+ *
+ * @param i short number
+ * @return MetadataIndexNodeType
+ */
+ public static MetadataIndexNodeType deserialize(short i) {
Review comment:
use one byte is enough
##########
File path: server/src/main/java/org/apache/iotdb/db/utils/FileLoaderUtils.java
##########
@@ -70,9 +64,9 @@ public static void checkTsFileResource(TsFileResource
tsFileResource) throws IOE
tsFileResource.setClosed(true);
}
- public static void updateTsFileResource(TsFileMetadata metaData,
TsFileSequenceReader reader,
+ public static void updateTsFileResource(TsFileSequenceReader reader,
TsFileResource tsFileResource) throws IOException {
- for (String device : metaData.getDeviceMetadataIndex().keySet()) {
+ for (String device : reader.getAllDevices()) {
Review comment:
add a method getAllTimeseriesMetadata(), seek and IO all
timeseriesMetadata once.
##########
File path:
tsfile/src/main/java/org/apache/iotdb/tsfile/write/writer/TsFileIOWriter.java
##########
@@ -273,10 +278,11 @@ public void endFile() throws IOException {
}
/**
- * Flush ChunkMetadataList and TimeseriesMetaData
- * @return DeviceMetaDataMap in TsFileMetaData
+ * Flush TsFileMetadata, including ChunkMetadataList and TimeseriesMetaData
+ *
+ * @return MetadataIndexNode list in TsFileMetadata
*/
- private Map<String, Pair<Long, Integer>> flushAllChunkMetadataList(
+ private List<MetadataIndexNode> flushTsFileMetadata(
Review comment:
flushMetadataIndex
##########
File path:
tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileConfig.java
##########
@@ -82,6 +82,10 @@
* The maximum number of data points in a page, default value is 1024 * 1024.
*/
private int maxNumberOfPointsInPage = 1024 * 1024;
+ /**
+ * The maximum number of index items in a metadataIndex node, default value
is 1024
+ */
+ private int maxDegreeOfIndexNode = 5;
Review comment:
```suggestion
private int maxDegreeOfIndexNode = 1024;
```
only set 5 in test
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]