jt2594838 commented on a change in pull request #258: [IOTDB-143]Development of 
merge
URL: https://github.com/apache/incubator-iotdb/pull/258#discussion_r314574372
 
 

 ##########
 File path: 
server/src/main/java/org/apache/iotdb/db/engine/merge/task/MergeMultiChunkTask.java
 ##########
 @@ -0,0 +1,424 @@
+/**
+ * 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.merge.task;
+
+import static org.apache.iotdb.db.utils.MergeUtils.writeBatchPoint;
+import static org.apache.iotdb.db.utils.MergeUtils.writeTVPair;
+import static org.apache.iotdb.db.utils.QueryUtils.modifyChunkMetaData;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.PriorityQueue;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.engine.merge.manage.MergeContext;
+import org.apache.iotdb.db.engine.merge.manage.MergeManager;
+import org.apache.iotdb.db.engine.merge.manage.MergeResource;
+import org.apache.iotdb.db.engine.merge.recover.MergeLogger;
+import org.apache.iotdb.db.engine.merge.selector.MergePathSelector;
+import org.apache.iotdb.db.engine.merge.selector.NaivePathSelector;
+import org.apache.iotdb.db.engine.modification.Modification;
+import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
+import org.apache.iotdb.db.query.reader.IPointReader;
+import org.apache.iotdb.db.utils.MergeUtils;
+import org.apache.iotdb.db.utils.MergeUtils.MetaListEntry;
+import org.apache.iotdb.db.utils.TimeValuePair;
+import org.apache.iotdb.tsfile.file.metadata.ChunkMetaData;
+import org.apache.iotdb.tsfile.read.TsFileSequenceReader;
+import org.apache.iotdb.tsfile.read.common.BatchData;
+import org.apache.iotdb.tsfile.read.common.Chunk;
+import org.apache.iotdb.tsfile.read.common.Path;
+import org.apache.iotdb.tsfile.read.reader.chunk.ChunkReader;
+import org.apache.iotdb.tsfile.read.reader.chunk.ChunkReaderWithoutFilter;
+import org.apache.iotdb.tsfile.write.chunk.IChunkWriter;
+import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
+import org.apache.iotdb.tsfile.write.writer.RestorableTsFileIOWriter;
+import org.apache.iotdb.tsfile.write.writer.TsFileIOWriter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+class MergeMultiChunkTask {
+
+  private static final Logger logger = 
LoggerFactory.getLogger(MergeMultiChunkTask.class);
+  private static int minChunkPointNum = 
IoTDBDescriptor.getInstance().getConfig()
+      .getChunkMergePointThreshold();
+
+  private MergeLogger mergeLogger;
+  private List<Path> unmergedSeries;
+
+  private String taskName;
+  private MergeResource resource;
+  private TimeValuePair[] currTimeValuePairs;
+  private boolean fullMerge;
+
+  private MergeContext mergeContext;
+
+  private AtomicInteger mergedChunkNum = new AtomicInteger();
+  private AtomicInteger unmergedChunkNum = new AtomicInteger();
+  private int mergedSeriesCnt;
+  private double progress;
+
+  private int concurrentMergeSeriesNum;
+  private List<Path> currMergingPaths = new ArrayList<>();
+
+  MergeMultiChunkTask(MergeContext context, String taskName, MergeLogger 
mergeLogger,
+      MergeResource mergeResource, boolean fullMerge, List<Path> 
unmergedSeries,
+      int concurrentMergeSeriesNum) {
+    this.mergeContext = context;
+    this.taskName = taskName;
+    this.mergeLogger = mergeLogger;
+    this.resource = mergeResource;
+    this.fullMerge = fullMerge;
+    this.unmergedSeries = unmergedSeries;
+    this.concurrentMergeSeriesNum = concurrentMergeSeriesNum;
+  }
+
+  void mergeSeries() throws IOException {
+    if (logger.isInfoEnabled()) {
+      logger.info("{} starts to merge {} series", taskName, 
unmergedSeries.size());
+    }
+    long startTime = System.currentTimeMillis();
+    for (TsFileResource seqFile : resource.getSeqFiles()) {
+      mergeContext.getUnmergedChunkStartTimes().put(seqFile, new HashMap<>());
+    }
+    // merge each series and write data into each seqFile's corresponding temp 
merge file
+    List<List<Path>> devicePaths = 
MergeUtils.splitPathsByDevice(unmergedSeries);
 
 Review comment:
    Now I am getting the paths from MManager.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to