jmark99 commented on code in PR #2910:
URL: https://github.com/apache/accumulo/pull/2910#discussion_r961077160


##########
core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java:
##########
@@ -2011,6 +2015,34 @@ public ImportDestinationArguments importDirectory(String 
directory) {
     return new BulkImport(directory, context);
   }
 
+  @Override
+  public TimeType getTimeType(final String tableName) throws 
TableNotFoundException {
+    if (tableName.equals(RootTable.NAME)) {
+      throw new IllegalArgumentException("accumulo.root table has no 
TimeType");
+    }
+    String systemTableToCheck =
+        MetadataTable.NAME.equals(tableName) ? RootTable.NAME : 
MetadataTable.NAME;
+    final Scanner scanner = context.createScanner(systemTableToCheck, 
Authorizations.EMPTY);
+    String tableId = tableIdMap().get(tableName);
+    if (tableId == null) {
+      throw new TableNotFoundException(null, tableName, "specified table does 
not exist");
+    }
+    final Text start = new Text(tableId);
+    final Text end = new Text(start);
+    start.append(new byte[] {'<'}, 0, 1);
+    end.append(new byte[] {'<'}, 0, 1);
+    scanner.setRange(new Range(start, end));
+    
MetadataSchema.TabletsSection.ServerColumnFamily.TIME_COLUMN.fetch(scanner);
+    Entry<Key,Value> next = scanner.iterator().next();
+    Value val = next.getValue();
+    if (val.toString().startsWith("L")) {
+      return TimeType.LOGICAL;
+    } else if (val.toString().startsWith("M")) {
+      return TimeType.MILLIS;
+    }
+    throw new RuntimeException("Failed to retrieve TimeType");

Review Comment:
   @keith-turner thanks for the suggestion. I forgot about the use of ample. I 
made a few slight tweaks. 1) forTable requires a TableID vs a String, and 2) I 
updated to return a TimeType rather than a TableMetadata object.



-- 
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-unsubscr...@accumulo.apache.org

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

Reply via email to