primaryRegion.compactStores(); List<HRegion> regions = new ArrayList<>(); regions.add(primaryRegion);
region.compactStores();
assertEquals("Before compaction: referenced mob file count", 0, countReferencedMobFiles()); region.compactStores();
for (HRegion region : regions) { region.compactStores(); // min is 2 so will compact and archive
/** * During compaction, cells smaller than the threshold won't be affected. */ @Test public void testSmallerValue() throws Exception { init(UTIL.getConfiguration(), 500); byte[] dummyData = makeDummyData(300); // smaller than mob threshold Table loader = new RegionAsTable(region); // one hfile per row for (int i = 0; i < compactionThreshold; i++) { Put p = createPut(i, dummyData); loader.put(p); region.flush(true); } assertEquals("Before compaction: store files", compactionThreshold, countStoreFiles()); assertEquals("Before compaction: mob file count", 0, countMobFiles()); assertEquals("Before compaction: rows", compactionThreshold, UTIL.countRows(region)); assertEquals("Before compaction: mob rows", 0, countMobRows()); region.compactStores(); assertEquals("After compaction: store files", 1, countStoreFiles()); assertEquals("After compaction: mob file count", 0, countMobFiles()); assertEquals("After compaction: referenced mob file count", 0, countReferencedMobFiles()); assertEquals("After compaction: rows", compactionThreshold, UTIL.countRows(region)); assertEquals("After compaction: mob rows", 0, countMobRows()); }
/** * During compaction, the mob threshold size is changed. */ @Test public void testLargerValue() throws Exception { init(UTIL.getConfiguration(), 200); byte[] dummyData = makeDummyData(300); // larger than mob threshold Table loader = new RegionAsTable(region); for (int i = 0; i < compactionThreshold; i++) { Put p = createPut(i, dummyData); loader.put(p); region.flush(true); } assertEquals("Before compaction: store files", compactionThreshold, countStoreFiles()); assertEquals("Before compaction: mob file count", compactionThreshold, countMobFiles()); assertEquals("Before compaction: rows", compactionThreshold, UTIL.countRows(region)); assertEquals("Before compaction: mob rows", compactionThreshold, countMobRows()); assertEquals("Before compaction: number of mob cells", compactionThreshold, countMobCellsInMetadata()); // Change the threshold larger than the data size setMobThreshold(region, COLUMN_FAMILY, 500); region.initialize(); region.compactStores(); assertEquals("After compaction: store files", 1, countStoreFiles()); assertEquals("After compaction: mob file count", compactionThreshold, countMobFiles()); assertEquals("After compaction: referenced mob file count", 0, countReferencedMobFiles()); assertEquals("After compaction: rows", compactionThreshold, UTIL.countRows(region)); assertEquals("After compaction: mob rows", 0, countMobRows()); }
@Override public void compact(boolean majorCompact) throws IOException { region.compactStores(majorCompact); }
@Override public void compact(boolean majorCompact) throws IOException { region.compactStores(majorCompact); }
@Override public void compact(boolean majorCompact) throws IOException { region.compactStores(majorCompact); }
@Override public void compact(boolean majorCompact) throws IOException { region.compactStores(majorCompact); }
@Override public void compact(boolean majorCompact) throws IOException { region.compactStores(majorCompact); }
/** * This is a helper function that compact all the stores synchronously * It is used by utilities and testing * * @param majorCompaction True to force a major compaction regardless of thresholds * @throws IOException e */ public void compactStores(final boolean majorCompaction) throws IOException { if (majorCompaction) { this.triggerMajorCompaction(); } compactStores(); }
@Override public void run() { try { region.compactStores(majorCompact); } catch (IOException e) { throw Throwables.propagate(e); } } };
private synchronized HRegion openRootRegion() throws IOException { if (this.rootRegion != null) { return this.rootRegion; } this.rootRegion = HRegion.openHRegion(HRegionInfo.ROOT_REGIONINFO, HTableDescriptor.ROOT_TABLEDESC, getLog(), this.conf); this.rootRegion.compactStores(); return this.rootRegion; }
private HRegion openMetaRegion(HRegionInfo metaInfo) throws IOException { HRegion meta = HRegion.openHRegion(metaInfo, HTableDescriptor.META_TABLEDESC, getLog(), this.conf); meta.compactStores(); return meta; }
private synchronized HRegion openMetaRegion() throws IOException { if (this.metaRegion != null) { return this.metaRegion; } this.metaRegion = HRegion.openHRegion(HRegionInfo.FIRST_META_REGIONINFO, descriptors.get(TableName.META_TABLE_NAME), getLog(HRegionInfo.FIRST_META_REGIONINFO), this.conf); this.metaRegion.compactStores(); return this.metaRegion; } }
assertEquals("Before compaction: referenced mob file count", 0, countReferencedMobFiles()); region.compactStores();
/** * During compaction, cells smaller than the threshold won't be affected. */ @Test public void testSmallerValue() throws Exception { init(UTIL.getConfiguration(), 500); byte[] dummyData = makeDummyData(300); // smaller than mob threshold Table loader = new RegionAsTable(region); // one hfile per row for (int i = 0; i < compactionThreshold; i++) { Put p = createPut(i, dummyData); loader.put(p); region.flush(true); } assertEquals("Before compaction: store files", compactionThreshold, countStoreFiles()); assertEquals("Before compaction: mob file count", 0, countMobFiles()); assertEquals("Before compaction: rows", compactionThreshold, UTIL.countRows(region)); assertEquals("Before compaction: mob rows", 0, countMobRows()); region.compactStores(); assertEquals("After compaction: store files", 1, countStoreFiles()); assertEquals("After compaction: mob file count", 0, countMobFiles()); assertEquals("After compaction: referenced mob file count", 0, countReferencedMobFiles()); assertEquals("After compaction: rows", compactionThreshold, UTIL.countRows(region)); assertEquals("After compaction: mob rows", 0, countMobRows()); }
/** * During compaction, the mob threshold size is changed. */ @Test public void testLargerValue() throws Exception { init(UTIL.getConfiguration(), 200); byte[] dummyData = makeDummyData(300); // larger than mob threshold Table loader = new RegionAsTable(region); for (int i = 0; i < compactionThreshold; i++) { Put p = createPut(i, dummyData); loader.put(p); region.flush(true); } assertEquals("Before compaction: store files", compactionThreshold, countStoreFiles()); assertEquals("Before compaction: mob file count", compactionThreshold, countMobFiles()); assertEquals("Before compaction: rows", compactionThreshold, UTIL.countRows(region)); assertEquals("Before compaction: mob rows", compactionThreshold, countMobRows()); assertEquals("Before compaction: number of mob cells", compactionThreshold, countMobCellsInMetadata()); // Change the threshold larger than the data size setMobThreshold(region, COLUMN_FAMILY, 500); region.initialize(); region.compactStores(); assertEquals("After compaction: store files", 1, countStoreFiles()); assertEquals("After compaction: mob file count", compactionThreshold, countMobFiles()); assertEquals("After compaction: referenced mob file count", 0, countReferencedMobFiles()); assertEquals("After compaction: rows", compactionThreshold, UTIL.countRows(region)); assertEquals("After compaction: mob rows", 0, countMobRows()); }