You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "keith-turner (via GitHub)" <gi...@apache.org> on 2023/04/24 17:13:10 UTC

[GitHub] [accumulo] keith-turner commented on a diff in pull request #3331: Reuse already read lastLocation information during location updates

keith-turner commented on code in PR #3331:
URL: https://github.com/apache/accumulo/pull/3331#discussion_r1175575754


##########
server/base/src/main/java/org/apache/accumulo/server/util/ManagerMetadataUtil.java:
##########
@@ -257,14 +257,23 @@ public static Optional<StoredTabletFile> updateTabletDataFile(ServerContext cont
    * @param tabletMutator The mutator being built
    * @param extent The tablet extent
    * @param location The new location
+   * @param prevLastLocation The previous last location, if known
    */
   public static void updateLastForAssignmentMode(ClientContext context, Ample ample,
-      Ample.TabletMutator tabletMutator, KeyExtent extent, TServerInstance location) {
+      Ample.TabletMutator tabletMutator, KeyExtent extent, TServerInstance location,
+      Location prevLastLocation) {
     // if the location mode is assignment, then preserve the current location in the last
     // location value
     if ("assignment".equals(context.getConfiguration().get(Property.TSERV_LAST_LOCATION_MODE))) {
-      TabletMetadata lastMetadata = ample.readTablet(extent, TabletMetadata.ColumnType.LAST);
-      Location lastLocation = (lastMetadata == null ? null : lastMetadata.getLast());
+      // If prevLastLocation is not provided then look it up from metadata
+      final Location lastLocation = Optional.ofNullable(prevLastLocation).orElseGet(() -> {
+        log.trace(
+            "Previous last location for {} not provided to updateLastForAssignmentMode, loading from metadata.",
+            extent);
+        final TabletMetadata lastMetadata =

Review Comment:
   If the last was not present when we read earlier, then we probably do not need to read it again.  Its tricky though because null can have two meanings, it can mean it was never read previously or it was read previously and was not present.  One simplification is that if we assume that all code calling this method has already tried to read the last location, then we never need to read it here when null.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org