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


##########
core/src/main/java/org/apache/accumulo/core/metadata/StoredTabletFile.java:
##########
@@ -291,9 +291,41 @@ public TabletFileCq(Path path, Range range) {
     }
   }
 
-  private static class TabletFileCqMetadataGson {
+  static class TabletFileCqMetadataGson {
     private String path;
     private byte[] startRow;
     private byte[] endRow;
+
+    TabletFileCqMetadataGson() {}
+
+    TabletFileCqMetadataGson(AbstractTabletFile<?> atf) {
+      path = Objects.requireNonNull(atf.path.toString());
+      startRow = encodeRow(atf.range.getStartKey());
+      endRow = encodeRow(atf.range.getEndKey());
+    }
+
+    ReferencedTabletFile toReferencedTabletFile() {
+      return new ReferencedTabletFile(new Path(URI.create(path)),
+          new Range(decodeRow(startRow), true, decodeRow(endRow), false));
+    }
+
+    StoredTabletFile toStoredTabletFile() {
+      return new StoredTabletFile(new TabletFileCq(new Path(URI.create(path)),
+          new Range(decodeRow(startRow), true, decodeRow(endRow), false)));
+    }
+  }
+
+  static StoredTabletFile fomTabletFileCqMetadataGson(String serialized) {
+    return new StoredTabletFile(deserialize(serialized));
+  }

Review Comment:
   This method does not seem to be used.



##########
core/src/main/java/org/apache/accumulo/core/metadata/StoredTabletFile.java:
##########
@@ -291,9 +291,41 @@ public TabletFileCq(Path path, Range range) {
     }
   }
 
-  private static class TabletFileCqMetadataGson {
+  static class TabletFileCqMetadataGson {
     private String path;
     private byte[] startRow;
     private byte[] endRow;
+
+    TabletFileCqMetadataGson() {}
+
+    TabletFileCqMetadataGson(AbstractTabletFile<?> atf) {
+      path = Objects.requireNonNull(atf.path.toString());
+      startRow = encodeRow(atf.range.getStartKey());
+      endRow = encodeRow(atf.range.getEndKey());
+    }
+
+    ReferencedTabletFile toReferencedTabletFile() {
+      return new ReferencedTabletFile(new Path(URI.create(path)),
+          new Range(decodeRow(startRow), true, decodeRow(endRow), false));
+    }
+
+    StoredTabletFile toStoredTabletFile() {
+      return new StoredTabletFile(new TabletFileCq(new Path(URI.create(path)),
+          new Range(decodeRow(startRow), true, decodeRow(endRow), false)));
+    }
+  }
+
+  static StoredTabletFile fomTabletFileCqMetadataGson(String serialized) {
+    return new StoredTabletFile(deserialize(serialized));
+  }
+
+  TabletFileCqMetadataGson toTabletFileCqMetadataGson() {
+    requireKeyExtentDataRange(range);
+    final TabletFileCqMetadataGson metadata = new TabletFileCqMetadataGson();
+    metadata.path = Objects.requireNonNull(path).toString();
+    metadata.startRow = encodeRow(range.getStartKey());
+    metadata.endRow = encodeRow(range.getEndKey());
+    return metadata;

Review Comment:
   May be able to do the following not sure.  Also the 
requireKeyExtentDataRange() call may not be needed because StoredTableFile is 
immutable and the range should be verified already, but not completely sure 
about this.
   
   ```suggestion
     TabletFileCqMetadataGson toTabletFileCqMetadataGson() {
          return new TabletFileCqMetadataGson(this);
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to