From 082a1e97fe926388541ba1726b82e57e7cd06d5f Mon Sep 17 00:00:00 2001 From: gsheffi Date: Mon, 29 Jan 2018 11:20:52 +0200 Subject: [PATCH] for creating patch HBASE-19658.006.patch --- .../TestCompactingToCellFlatMapMemStore.java | 42 +++++++++++++++++----- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactingToCellFlatMapMemStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactingToCellFlatMapMemStore.java index 91a4b04170..feff287982 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactingToCellFlatMapMemStore.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactingToCellFlatMapMemStore.java @@ -752,9 +752,9 @@ public class TestCompactingToCellFlatMapMemStore extends TestCompactingMemStore // set memstore to flat into CellChunkMap MemoryCompactionPolicy compactionType = MemoryCompactionPolicy.BASIC; memstore.getConfiguration().set(CompactingMemStore.COMPACTING_MEMSTORE_TYPE_KEY, - String.valueOf(compactionType)); - ((MyCompactingMemStore)memstore).initiateType(compactionType, memstore.getConfiguration()); - ((CompactingMemStore)memstore).setIndexType(CompactingMemStore.IndexType.CHUNK_MAP); + String.valueOf(compactionType)); + ((MyCompactingMemStore) memstore).initiateType(compactionType, memstore.getConfiguration()); + ((CompactingMemStore) memstore).setIndexType(CompactingMemStore.IndexType.CHUNK_MAP); int numOfCells = 1; char[] chars = new char[MemStoreLAB.CHUNK_SIZE_DEFAULT]; @@ -762,7 +762,7 @@ public class TestCompactingToCellFlatMapMemStore extends TestCompactingMemStore chars[i] = 'A'; } String bigVal = new String(chars); - String[] keys1 = { "A"}; + String[] keys1 = {"A"}; // make one cell byte[] row = Bytes.toBytes(keys1[0]); @@ -782,7 +782,7 @@ public class TestCompactingToCellFlatMapMemStore extends TestCompactingMemStore assertEquals(totalCellsLen, regionServicesForStores.getMemStoreSize()); assertEquals(totalHeapSize, ((CompactingMemStore) memstore).heapSize()); - ((CompactingMemStore)memstore).flushInMemory(); // push keys to pipeline and flatten + ((CompactingMemStore) memstore).flushInMemory(); // push keys to pipeline and flatten while (((CompactingMemStore) memstore).isMemStoreFlushingInMemory()) { Threads.sleep(10); } @@ -807,14 +807,38 @@ public class TestCompactingToCellFlatMapMemStore extends TestCompactingMemStore memstore.clearSnapshot(snapshot.getId()); - String[] keys2 = { "C", "D", "E"}; + // Allocating three big cells (too big for being copied into a regular chunk). + String[] keys2 = {"C", "D", "E"}; addRowsByKeys(memstore, keys2, val); while (((CompactingMemStore) memstore).isMemStoreFlushingInMemory()) { Threads.sleep(10); } - totalHeapSize = 1 * oneCellOnCSLMHeapSize + MutableSegment.DEEP_OVERHEAD - + CellChunkImmutableSegment.DEEP_OVERHEAD_CCM - + 2 * oneCellOnCCMHeapSize; + + // When the inMemoryFlushSize is bigger than the size of three big cells, + // no cell is being flattened. When either the inMemoryFlushSize is smaller than + // the size of a single big cell, or that the inMemoryFlushSize is bigger than + // the size of two cells but smaller than the size of three cells, all three cells + // are flattened. When the inMemoryFlushSize is bigger than the size of a single cell + // but smaller than the size of two cells, exactly two cells are flattened. + long inMemoryFlushSize = ((CompactingMemStore) memstore).getInmemoryFlushSize(); + if (3 * oneCellOnCSLMHeapSize + MutableSegment.DEEP_OVERHEAD < inMemoryFlushSize) { + totalHeapSize = MutableSegment.DEEP_OVERHEAD + + 3 * oneCellOnCSLMHeapSize; + } else if (oneCellOnCSLMHeapSize + MutableSegment.DEEP_OVERHEAD > inMemoryFlushSize) { + totalHeapSize = MutableSegment.DEEP_OVERHEAD + + CellChunkImmutableSegment.DEEP_OVERHEAD_CCM + + 3 * oneCellOnCCMHeapSize; + } else if (2 * oneCellOnCSLMHeapSize + MutableSegment.DEEP_OVERHEAD > inMemoryFlushSize) { + totalHeapSize = oneCellOnCSLMHeapSize + + MutableSegment.DEEP_OVERHEAD + + CellChunkImmutableSegment.DEEP_OVERHEAD_CCM + + 2 * oneCellOnCCMHeapSize; + } else { + totalHeapSize = MutableSegment.DEEP_OVERHEAD + + CellChunkImmutableSegment.DEEP_OVERHEAD_CCM + + 3 * oneCellOnCCMHeapSize; + } + assertEquals(totalHeapSize, ((CompactingMemStore) memstore).heapSize()); } -- 2.12.2