ctubbsii commented on code in PR #4898:
URL: https://github.com/apache/accumulo/pull/4898#discussion_r1765427603


##########
core/src/main/java/org/apache/accumulo/core/data/LoadPlan.java:
##########
@@ -228,4 +246,88 @@ public LoadPlan build() {
       }
     };
   }
+
+  private static final TableId FAKE_ID = TableId.of("999");
+
+  private static class JsonDestination {
+    String fileName;
+    String startRow;
+    String endRow;
+    RangeType rangeType;
+
+    JsonDestination() {}
+
+    JsonDestination(Destination destination) {
+      fileName = destination.getFileName();
+      startRow = destination.getStartRow() == null ? null
+          : Base64.getUrlEncoder().encodeToString(destination.getStartRow());
+      endRow = destination.getEndRow() == null ? null
+          : Base64.getUrlEncoder().encodeToString(destination.getEndRow());
+      rangeType = destination.getRangeType();
+    }
+
+    Destination toDestination() {
+      return new Destination(fileName, rangeType,
+          startRow == null ? null : Base64.getUrlDecoder().decode(startRow),
+          endRow == null ? null : Base64.getUrlDecoder().decode(endRow));
+    }
+  }
+
+  private static final class JsonAll {
+    List<JsonDestination> destinations;
+
+    JsonAll() {}
+
+    JsonAll(List<Destination> destinations) {
+      this.destinations =
+          
destinations.stream().map(JsonDestination::new).collect(Collectors.toList());
+    }
+
+  }
+
+  private static final Gson gson = new 
GsonBuilder().disableJdkUnsafe().create();
+
+  // TODO javadoc
+  public String toJson() {
+    return gson.toJson(new JsonAll(destinations));
+  }
+
+  // TODO javadoc
+  public static LoadPlan fromJson(String json) {
+    var dests = gson.fromJson(json, JsonAll.class).destinations.stream()
+        
.map(JsonDestination::toDestination).collect(Collectors.toUnmodifiableList());
+    return new LoadPlan(dests);
+  }
+
+  // TODO javadoc
+  public static LoadPlan compute(URI file, SortedSet<Text> splits) throws 
IOException {
+
+    // TODO if the files needed a crypto service how could it be instantiated? 
Was trying to make

Review Comment:
   You can look at how the rfile PrintInfo command does this. It calls:
   
   ```java
          CryptoService cs = 
CryptoFactoryLoader.getServiceForClient(CryptoEnvironment.Scope.TABLE,
              siteConfig.getAllCryptoProperties());
   ```
   
   As a server-side utility, you could make certain assumptions that it has the 
ability to read the accumulo properties file on the server side, like that 
utility does. However, as a purely client-side API, you may need to just pass 
in the CryptoService directly, or pass in other options, so it can set up the 
right config (crypto, compression, etc.) to be able to read the files.



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