You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by su...@apache.org on 2020/10/19 12:10:12 UTC
[iotdb] 18/22: remove useless code
This is an automated email from the ASF dual-hosted git repository.
sunzesong pushed a commit to branch pr_1758
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit a818b26b62280c686bdd3295e269e99546c770fb
Author: 张凌哲 <44...@qq.com>
AuthorDate: Wed Oct 14 16:48:33 2020 +0800
remove useless code
---
.../db/engine/cache/FileChunkPointSizeCache.java | 86 ----------------------
.../db/engine/storagegroup/TsFileProcessor.java | 23 ------
2 files changed, 109 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/cache/FileChunkPointSizeCache.java b/server/src/main/java/org/apache/iotdb/db/engine/cache/FileChunkPointSizeCache.java
deleted file mode 100644
index b331521..0000000
--- a/server/src/main/java/org/apache/iotdb/db/engine/cache/FileChunkPointSizeCache.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.engine.cache;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.iotdb.tsfile.file.metadata.ChunkMetadata;
-import org.apache.iotdb.tsfile.read.TsFileSequenceReader;
-import org.apache.iotdb.tsfile.read.common.Path;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class FileChunkPointSizeCache {
-
- private static final Logger logger = LoggerFactory.getLogger(FileChunkPointSizeCache.class);
-
- // (absolute path,avg chunk point size)
- private Map<String, Map<String, Long>> tsfileDeviceChunkPointCache;
-
- private FileChunkPointSizeCache() {
- tsfileDeviceChunkPointCache = new HashMap<>();
- }
-
- public static FileChunkPointSizeCache getInstance() {
- return FileChunkPointSizeCacheHolder.INSTANCE;
- }
-
- public Map<String, Long> get(File tsfile) {
- String path = tsfile.getAbsolutePath();
- return tsfileDeviceChunkPointCache.computeIfAbsent(path, k -> {
- Map<String, Long> deviceChunkPointMap = new HashMap<>();
- try {
- if (tsfile.exists()) {
- TsFileSequenceReader reader = new TsFileSequenceReader(path);
- List<Path> pathList = reader.getAllPaths();
- for (Path sensorPath : pathList) {
- String device = sensorPath.getDevice();
- long chunkPointNum = deviceChunkPointMap.getOrDefault(device, 0L);
- List<ChunkMetadata> chunkMetadataList = reader.getChunkMetadataList(sensorPath);
- for (ChunkMetadata chunkMetadata : chunkMetadataList) {
- chunkPointNum += chunkMetadata.getNumOfPoints();
- }
- deviceChunkPointMap.put(device, chunkPointNum);
- }
- } else {
- logger.info("{} tsfile does not exist", path);
- }
- } catch (IOException e) {
- logger.error(
- "{} tsfile reader creates error", path, e);
- }
- return deviceChunkPointMap;
- });
- }
-
- public void put(String tsfilePath, Map<String, Long> deviceChunkPointMap) {
- tsfileDeviceChunkPointCache.put(tsfilePath, deviceChunkPointMap);
- }
-
- /**
- * singleton pattern.
- */
- private static class FileChunkPointSizeCacheHolder {
-
- private static final FileChunkPointSizeCache INSTANCE = new FileChunkPointSizeCache();
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java
index 327d9f3..94cf00f 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java
@@ -24,10 +24,8 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -37,7 +35,6 @@ import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.conf.adapter.ActiveTimeSeriesCounter;
import org.apache.iotdb.db.conf.adapter.CompressionRatio;
import org.apache.iotdb.db.conf.adapter.IoTDBConfigDynamicAdapter;
-import org.apache.iotdb.db.engine.cache.FileChunkPointSizeCache;
import org.apache.iotdb.db.engine.flush.FlushManager;
import org.apache.iotdb.db.engine.flush.MemTableFlushTask;
import org.apache.iotdb.db.engine.flush.NotifyFlushMemTable;
@@ -651,26 +648,6 @@ public class TsFileProcessor {
}
}
- private void updateDeviceChunkPointSizeCache() {
- Map<String, Map<String, List<ChunkMetadata>>> deviceMeasurementChunkMetadataMap = writer
- .getMetadatasForQuery();
- Map<String, Long> deviceChunkPointMap = new HashMap<>();
- for (Entry<String, Map<String, List<ChunkMetadata>>> deviceMeasurementChunkMetadataEntry : deviceMeasurementChunkMetadataMap
- .entrySet()) {
- String device = deviceMeasurementChunkMetadataEntry.getKey();
- long chunkPointNum = 0;
- for (Entry<String, List<ChunkMetadata>> measurementChunkMetadataEntry : deviceMeasurementChunkMetadataEntry
- .getValue().entrySet()) {
- for (ChunkMetadata chunkMetadata : measurementChunkMetadataEntry.getValue()) {
- chunkPointNum += chunkMetadata.getNumOfPoints();
- }
- }
- deviceChunkPointMap.put(device, chunkPointNum);
- }
- FileChunkPointSizeCache.getInstance()
- .put(tsFileResource.getTsFile().getAbsolutePath(), deviceChunkPointMap);
- }
-
private void endFile() throws IOException, TsFileProcessorException {
long closeStartTime = System.currentTimeMillis();
// updateDeviceChunkPointSizeCache();