busbey commented on a change in pull request #623: HBASE-22749: Distributed MOB compactions URL: https://github.com/apache/hbase/pull/623#discussion_r327144872
########## File path: hbase-server/src/main/java/org/apache/hadoop/hbase/mob/DefaultMobStoreCompactor.java ########## @@ -362,11 +508,375 @@ protected boolean performCompaction(FileDetails fd, InternalScanner scanner, Cel abortWriter(mobFileWriter); } } + // Commit or abort generational writers + if (mobWriters != null) { + for (StoreFileWriter w: mobWriters.getOutputWriters()) { + Long mobs = mobWriters.getMobCountForOutputWriter(w); + if (mobs != null && mobs > 0) { + mobRefSet.get().add(w.getPath().getName()); + w.appendMetadata(fd.maxSeqId, major, mobs); + w.close(); + mobStore.commitFile(w.getPath(), path); + } else { + abortWriter(w); + } + } + } mobStore.updateCellsCountCompactedFromMob(cellsCountCompactedFromMob); mobStore.updateCellsCountCompactedToMob(cellsCountCompactedToMob); mobStore.updateCellsSizeCompactedFromMob(cellsSizeCompactedFromMob); mobStore.updateCellsSizeCompactedToMob(cellsSizeCompactedToMob); progress.complete(); return true; } + + protected static String createKey(TableName tableName, String encodedName, + String columnFamilyName) { + return tableName.getNameAsString()+ "_" + encodedName + "_"+ columnFamilyName; + } + + @Override + protected List<Path> commitWriter(StoreFileWriter writer, FileDetails fd, + CompactionRequestImpl request) throws IOException { + List<Path> newFiles = Lists.newArrayList(writer.getPath()); + writer.appendMetadata(fd.maxSeqId, request.isAllFiles(), request.getFiles()); + // Append MOB references + Set<String> refSet = mobRefSet.get(); + writer.appendMobMetadata(refSet); + writer.close(); + return newFiles; + } + + private List<Path> getReferencedMobFiles(Collection<HStoreFile> storeFiles) { + Path mobDir = MobUtils.getMobFamilyPath(conf, store.getTableName(), store.getColumnFamilyName()); + Set<String> mobSet = new HashSet<String>(); + for (HStoreFile sf: storeFiles) { + byte[] value = sf.getMetadataValue(HStoreFile.MOB_FILE_REFS); + if (value != null) { + String s = new String(value); + String[] all = s.split(","); + Collections.addAll(mobSet, all); + } + } + List<Path> retList = new ArrayList<Path>(); + for(String name: mobSet) { + retList.add(new Path(mobDir, name)); + } + return retList; + } +} + +class FileSelection implements Comparable<FileSelection> { + + public final static String NULL_REGION = ""; + private Path path; + private long earliestTs; + private Configuration conf; + + public FileSelection(Path path, Configuration conf) throws IOException { + this.path = path; + this.conf = conf; + readEarliestTimestamp(); + } + + public String getEncodedRegionName() { + String fileName = path.getName(); + String[] parts = fileName.split("_"); Review comment: why are there multiple implementations for getting a region name out of a path? There's one here and a different one in `Generations` and IIRC there's also one in `MobFileName`. Can we consolidate? ---------------------------------------------------------------- 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