milleruntime commented on a change in pull request #1243: Fix #1242 - Update MasterMetadataUtil.getUpdateForTabletDataFile URL: https://github.com/apache/accumulo/pull/1243#discussion_r300058998
########## File path: server/base/src/main/java/org/apache/accumulo/server/util/MasterMetadataUtil.java ########## @@ -247,61 +243,58 @@ public static void updateTabletDataFile(ServerContext context, KeyExtent extent, String address, ZooLock zooLock, Set<String> unusedWalLogs, TServerInstance lastLocation, long flushId) { if (extent.isRootTablet()) { - if (unusedWalLogs != null) { - updateRootTabletDataFile(context, unusedWalLogs); - } - return; + updateRootTabletDataFile(context, unusedWalLogs); + } else { + updateForTabletDataFile(context, extent, path, mergeFile, dfv, time, filesInUseByScans, + address, zooLock, unusedWalLogs, lastLocation, flushId); } - Mutation m = getUpdateForTabletDataFile(extent, path, mergeFile, dfv, time, filesInUseByScans, - address, zooLock, unusedWalLogs, lastLocation, flushId); - MetadataTableUtil.update(context, zooLock, m, extent); + } /** * Update the data file for the root tablet */ private static void updateRootTabletDataFile(ServerContext context, Set<String> unusedWalLogs) { - TabletMutator tablet = context.getAmple().mutateTablet(RootTable.EXTENT); - unusedWalLogs.forEach(tablet::deleteWal); - tablet.mutate(); + if (unusedWalLogs != null) { + TabletMutator tablet = context.getAmple().mutateTablet(RootTable.EXTENT); + unusedWalLogs.forEach(tablet::deleteWal); + tablet.mutate(); + } } /** * Create an update that updates a tablet * - * @return A Mutation to update a tablet from the given information */ - private static Mutation getUpdateForTabletDataFile(KeyExtent extent, FileRef path, + private static void updateForTabletDataFile(ServerContext context, KeyExtent extent, FileRef path, FileRef mergeFile, DataFileValue dfv, String time, Set<FileRef> filesInUseByScans, String address, ZooLock zooLock, Set<String> unusedWalLogs, TServerInstance lastLocation, long flushId) { - Mutation m = new Mutation(extent.getMetadataEntry()); + + TabletMutator tablet = context.getAmple().mutateTablet(extent); if (dfv.getNumEntries() > 0) { - m.put(DataFileColumnFamily.NAME, path.meta(), new Value(dfv.encode())); - TabletsSection.ServerColumnFamily.TIME_COLUMN.put(m, new Value(time.getBytes(UTF_8))); - // stuff in this location + tablet.putFile(path, dfv); + tablet.putTime(time); + TServerInstance self = getTServerInstance(address, zooLock); - self.putLastLocation(m); - // erase the old location - if (lastLocation != null && !lastLocation.equals(self)) - lastLocation.clearLastLocation(m); Review comment: I usually do a separate refactor PR like: Remove unused code. It is easier to review if its all just unused code being removed. ---------------------------------------------------------------- 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