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


##########
server/base/src/main/java/org/apache/accumulo/server/init/FileSystemInitializer.java:
##########
@@ -62,81 +60,109 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-class FileSystemInitializer {
+public class FileSystemInitializer {
   private static final String TABLE_TABLETS_TABLET_DIR = "table_info";
   private static final Logger log = 
LoggerFactory.getLogger(FileSystemInitializer.class);
+  private static final Text SPLIT_POINT =
+      MetadataSchema.TabletsSection.getRange().getEndKey().getRow();
 
   // config only for root table
   private final InitialConfiguration initConfig;
 
-  FileSystemInitializer(InitialConfiguration initConfig, ZooReaderWriter zoo, 
InstanceId uuid) {
+  public FileSystemInitializer(InitialConfiguration initConfig) {
     this.initConfig = initConfig;
   }
 
-  private static class Tablet {
+  public static class InitialTablet {
     TableId tableId;
     String dirName;
-    Text prevEndRow, endRow;
+    Text prevEndRow, endRow, extent;
     String[] files;
 
-    Tablet(TableId tableId, String dirName, Text prevEndRow, Text endRow, 
String... files) {
+    InitialTablet(TableId tableId, String dirName, Text prevEndRow, Text 
endRow, String... files) {
       this.tableId = tableId;
       this.dirName = dirName;
       this.prevEndRow = prevEndRow;
       this.endRow = endRow;
       this.files = files;
+      this.extent = new 
Text(MetadataSchema.TabletsSection.encodeRow(this.tableId, this.endRow));
     }
+
+    private TreeMap<Key,Value> createEntries() {
+      TreeMap<Key,Value> sorted = new TreeMap<>();
+      Value EMPTY_SIZE = new DataFileValue(0, 0).encodeAsValue();
+      sorted.put(new Key(this.extent, DIRECTORY_COLUMN.getColumnFamily(),
+          DIRECTORY_COLUMN.getColumnQualifier(), 0), new Value(this.dirName));
+      sorted.put(
+          new Key(this.extent, TIME_COLUMN.getColumnFamily(), 
TIME_COLUMN.getColumnQualifier(), 0),
+          new Value(new MetadataTime(0, TimeType.LOGICAL).encode()));
+      sorted.put(
+          new Key(this.extent, PREV_ROW_COLUMN.getColumnFamily(),
+              PREV_ROW_COLUMN.getColumnQualifier(), 0),
+          
MetadataSchema.TabletsSection.TabletColumnFamily.encodePrevEndRow(this.prevEndRow));
+      for (String file : this.files) {
+        var col =
+            new 
ColumnFQ(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME, new 
Text(file));
+        sorted.put(new Key(extent, col.getColumnFamily(), 
col.getColumnQualifier()), EMPTY_SIZE);
+      }
+      return sorted;

Review Comment:
    Could use the tablet metadata builder to simplify this code.  The following 
should create the key values and reuse code for serializing tablet metadata.  
However I think the tablet metadata builder may only exists in elasticity, but 
not completely sure. 
   
   ```java
       KeyExtent keyExtent = new KeyExtent(tableId, endRow, prevEndRow);
       var builder = 
TabletMetadata.builder(keyExtent).putDirName(dirName).putTime(new 
MetadataTime(0, TimeType.LOGICAL));
       for (String file : files) {
         builder.putFile(new ReferencedTabletFile(new Path(file)).insert(),  
new DataFileValue(0, 0));
       }
       return builder.build().getKeyValues();
   ```



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