/**---------------------------------------------------------------------- * The request to dispatch the compaction asynchronous task. * The method returns true if compaction was successfully dispatched, or false if there * is already an ongoing compaction or no segments to compact. */ public boolean start() throws IOException { if (!compactingMemStore.hasImmutableSegments()) { // no compaction on empty pipeline return false; } // get a snapshot of the list of the segments from the pipeline, // this local copy of the list is marked with specific version versionedList = compactingMemStore.getImmutableSegments(); LOG.trace("Speculative compaction starting on {}/{}", compactingMemStore.getStore().getHRegion().getRegionInfo().getEncodedName(), compactingMemStore.getStore().getColumnFamilyName()); HStore store = compactingMemStore.getStore(); RegionCoprocessorHost cpHost = store.getCoprocessorHost(); if (cpHost != null) { cpHost.preMemStoreCompaction(store); } try { doCompaction(); } finally { if (cpHost != null) { cpHost.postMemStoreCompaction(store); } } return true; }
assertEquals(3, ((CompactingMemStore) memstore).getImmutableSegments().getNumOfCells()); assertEquals(1.0, ((CompactingMemStore) memstore).getImmutableSegments().getEstimatedUniquesFrac(), 0); assertEquals(0, memstore.getSnapshot().getCellsCount()); assertEquals(4, ((CompactingMemStore) memstore).getImmutableSegments().getNumOfCells()); assertEquals(1.0, ((CompactingMemStore) memstore).getImmutableSegments().getEstimatedUniquesFrac(), 0); assertEquals(0, memstore.getSnapshot().getCellsCount()); assertEquals(8, ((CompactingMemStore) memstore).getImmutableSegments().getNumOfCells()); assertEquals((4.0 / 8.0), ((CompactingMemStore) memstore).getImmutableSegments().getEstimatedUniquesFrac(), 0); assertEquals(0, memstore.getSnapshot().getCellsCount()); int numCells = ((CompactingMemStore) memstore).getImmutableSegments().getNumOfCells(); assertTrue(4 == numCells || 11 == numCells); assertEquals(0, memstore.getSnapshot().getCellsCount());
@Test public void testCountOfCellsAfterFlatteningByIterator() throws IOException { String[] keys1 = { "A", "B", "C" }; // A, B, C addRowsByKeysWith50Cols(memstore, keys1); // this should only flatten as there are no duplicates ((CompactingMemStore) memstore).flushInMemory(); while (((CompactingMemStore) memstore).isMemStoreFlushingInMemory()) { Threads.sleep(10); } // Just doing the cnt operation here MemStoreSegmentsIterator itr = new MemStoreMergerSegmentsIterator( ((CompactingMemStore) memstore).getImmutableSegments().getStoreSegments(), CellComparatorImpl.COMPARATOR, 10); int cnt = 0; try { while (itr.next() != null) { cnt++; } } finally { itr.close(); } assertEquals("the count should be ", 150, cnt); }
assertEquals(3, ((CompactingMemStore) memstore).getImmutableSegments().getNumOfCells()); assertEquals(1.0, ((CompactingMemStore) memstore).getImmutableSegments().getEstimatedUniquesFrac(), 0); assertEquals(0, memstore.getSnapshot().getCellsCount()); assertEquals(4, ((CompactingMemStore) memstore).getImmutableSegments().getNumOfCells()); assertEquals(1.0, ((CompactingMemStore) memstore).getImmutableSegments().getEstimatedUniquesFrac(), 0); assertEquals(0, memstore.getSnapshot().getCellsCount()); assertEquals(8, ((CompactingMemStore) memstore).getImmutableSegments().getNumOfCells()); assertEquals((4.0 / 8.0), ((CompactingMemStore) memstore).getImmutableSegments().getEstimatedUniquesFrac(), 0); assertEquals(0, memstore.getSnapshot().getCellsCount()); int numCells = ((CompactingMemStore) memstore).getImmutableSegments().getNumOfCells(); assertTrue(4 == numCells || 11 == numCells); assertEquals(0, memstore.getSnapshot().getCellsCount());
@Test public void testCountOfCellsAfterFlatteningByIterator() throws IOException { String[] keys1 = { "A", "B", "C" }; // A, B, C addRowsByKeysWith50Cols(memstore, keys1); // this should only flatten as there are no duplicates ((CompactingMemStore) memstore).flushInMemory(); while (((CompactingMemStore) memstore).isMemStoreFlushingInMemory()) { Threads.sleep(10); } // Just doing the cnt operation here MemStoreSegmentsIterator itr = new MemStoreMergerSegmentsIterator( ((CompactingMemStore) memstore).getImmutableSegments().getStoreSegments(), CellComparatorImpl.COMPARATOR, 10); int cnt = 0; try { while (itr.next() != null) { cnt++; } } finally { itr.close(); } assertEquals("the count should be ", 150, cnt); }