cshannon commented on code in PR #3480:
URL: https://github.com/apache/accumulo/pull/3480#discussion_r1263698145


##########
core/src/main/java/org/apache/accumulo/core/metadata/StoredTabletFile.java:
##########
@@ -121,11 +150,105 @@ public String toString() {
    * Validates that the provided metadata string for the StoredTabletFile is 
valid.
    */
   public static void validate(String metadataEntry) {
-    ReferencedTabletFile.parsePath(new Path(URI.create(metadataEntry)));
+    ReferencedTabletFile.parsePath(deserialize(metadataEntry).path);
+  }
+
+  public static StoredTabletFile of(final Text metadataEntry) {
+    return new 
StoredTabletFile(Objects.requireNonNull(metadataEntry).toString());
   }
 
   public static StoredTabletFile of(final String metadataEntry) {
     return new StoredTabletFile(metadataEntry);
   }
 
+  public static StoredTabletFile of(final URI path, Range range) {
+    return of(new Path(Objects.requireNonNull(path)), range);
+  }
+
+  public static StoredTabletFile of(final Path path, Range range) {
+    return new StoredTabletFile(new TabletFileCq(Objects.requireNonNull(path), 
range));
+  }
+
+  private static final Gson gson = 
ByteArrayToBase64TypeAdapter.createBase64Gson();
+
+  private static TabletFileCq deserialize(String json) {
+    final TabletFileCqMetadataGson metadata =
+        gson.fromJson(Objects.requireNonNull(json), 
TabletFileCqMetadataGson.class);
+    // If we have previously enforced the exclusive/inclusive of a range then 
can just set that here
+    return new TabletFileCq(new Path(URI.create(metadata.path)),
+        new Range(decodeRow(metadata.startRow), false, 
decodeRow(metadata.endRow), true));

Review Comment:
   Wouldn't this cause potential issues with things like equality? The problem 
I see is that the original Range is constructed using false/true for the 
start/end row inclusive and then we would reconstruct with the opposite. So I 
could see scenarios where we'd end up with Ranges that are equal but equality 
returns false due to those flags being backwards.



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