You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ea...@apache.org on 2019/06/12 12:59:32 UTC

[incubator-iotdb] 01/02: fix overflow bug

This is an automated email from the ASF dual-hosted git repository.

east pushed a commit to branch feature_async_close_tsfile
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 95901a1c0e1a76d81e4b8048946d23810fe11ce6
Author: mdf369 <95...@qq.com>
AuthorDate: Wed Jun 12 20:53:27 2019 +0800

    fix overflow bug
---
 .../org/apache/iotdb/db/engine/overflow/io/OverflowMemtable.java | 9 +++------
 .../apache/iotdb/db/engine/overflow/io/OverflowProcessor.java    | 1 +
 .../apache/iotdb/db/engine/overflow/io/OverflowResourceTest.java | 8 +++++++-
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowMemtable.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowMemtable.java
index 91ef235..f7b3246 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowMemtable.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowMemtable.java
@@ -18,18 +18,13 @@
  */
 package org.apache.iotdb.db.engine.overflow.io;
 
-import static org.apache.iotdb.db.conf.IoTDBConstant.PATH_SEPARATOR;
-
 import java.util.HashMap;
 import java.util.Map;
 import org.apache.iotdb.db.engine.memtable.IMemTable;
 import org.apache.iotdb.db.engine.memtable.PrimitiveMemTable;
-import org.apache.iotdb.db.engine.modification.Deletion;
 import org.apache.iotdb.db.engine.querycontext.ReadOnlyMemChunk;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.file.metadata.statistics.LongStatistics;
-import org.apache.iotdb.tsfile.file.metadata.statistics.Statistics;
-import org.apache.iotdb.tsfile.read.common.BatchData;
 import org.apache.iotdb.tsfile.write.record.TSRecord;
 import org.apache.iotdb.tsfile.write.record.datapoint.DataPoint;
 
@@ -53,6 +48,7 @@ public class OverflowMemtable extends PrimitiveMemTable {
     memTable = new PrimitiveMemTable();
   }
 
+  @Override
   public void insert(TSRecord tsRecord) {
     for (DataPoint dataPoint : tsRecord.dataPointList) {
       memTable.write(tsRecord.deviceId, dataPoint.getMeasurementId(), dataPoint.getType(),
@@ -99,7 +95,7 @@ public class OverflowMemtable extends PrimitiveMemTable {
   }
 
   public IMemTable getMemTabale() {
-    return this;
+    return memTable;
   }
 
   public long getSize() {
@@ -107,6 +103,7 @@ public class OverflowMemtable extends PrimitiveMemTable {
     return 0;
   }
 
+  @Override
   public void clear() {
 //    indexTrees.clear();
     super.clear();
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowProcessor.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowProcessor.java
index 4f77c06..eb13d1a 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowProcessor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowProcessor.java
@@ -588,6 +588,7 @@ public class OverflowProcessor extends Processor {
       overflowFlushMemTables.add(workSupport);
       IMemTable tmpMemTableToFlush = workSupport;
       workSupport = MemTablePool.getInstance().getEmptyMemTable();
+      flushId++;
       flushFuture = FlushManager.getInstance().submit(() -> flushTask("asynchronously",
           tmpMemTableToFlush, walTaskId, flushId, this::removeFlushedMemTable));
 
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/engine/overflow/io/OverflowResourceTest.java b/iotdb/src/test/java/org/apache/iotdb/db/engine/overflow/io/OverflowResourceTest.java
index 24509f1..49457cf 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/engine/overflow/io/OverflowResourceTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/engine/overflow/io/OverflowResourceTest.java
@@ -25,10 +25,12 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.List;
 
+import org.apache.iotdb.db.engine.memtable.IMemTable;
 import org.apache.iotdb.db.engine.version.SysTimeVersionController;
 import org.apache.iotdb.db.query.context.QueryContext;
 import org.apache.iotdb.db.utils.EnvironmentUtils;
 import org.apache.iotdb.tsfile.file.metadata.ChunkMetaData;
+import org.apache.iotdb.tsfile.write.writer.TsFileIOWriter;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -55,12 +57,16 @@ public class OverflowResourceTest {
     EnvironmentUtils.cleanDir(folderPath);
   }
 
+  private void removeFlushedMemTable(IMemTable memTable, TsFileIOWriter overflowIOWriter) {
+    overflowIOWriter.mergeChunkGroupMetaData();
+  }
+
   @Test
   public void testOverflowInsert() throws IOException {
     OverflowTestUtils.produceInsertData(memtable);
     QueryContext context = new QueryContext();
     work.flush(OverflowTestUtils.getFileSchema(), memtable.getMemTabale(),
-        "processorName", 0, (k,v)->{});
+        "processorName", 0, this::removeFlushedMemTable);
     List<ChunkMetaData> chunkMetaDatas = work.getInsertMetadatas(OverflowTestUtils.deviceId1,
         OverflowTestUtils.measurementId1, OverflowTestUtils.dataType2, context);
     assertEquals(0, chunkMetaDatas.size());