You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2020/02/28 21:10:19 UTC

[GitHub] [accumulo] keith-turner commented on a change in pull request #1537: Add PrintInfo options to dump full keys, apply formatter

keith-turner commented on a change in pull request #1537: Add PrintInfo options to dump full keys, apply formatter
URL: https://github.com/apache/accumulo/pull/1537#discussion_r385922287
 
 

 ##########
 File path: core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
 ##########
 @@ -192,23 +268,43 @@ public void execute(final String[] args) throws Exception {
           }
         }
 
+        Formatter formatter = null;
+        if (opts.formatterClazz != null) {
+          final Class<? extends Formatter> formatterClass = getFormater(opts.formatterClazz);
+          FormatterConfig config = new FormatterConfig();
+          config.setPrintTimestamps(true);
+          formatter =
+              FormatterFactory.getFormatter(formatterClass, new FormatterAdapter(dataIter), config);
+        }
+
         for (String lgName : localityGroupCF.keySet()) {
           LocalityGroupUtil.seek(dataIter, new Range(), lgName, localityGroupCF);
-          while (dataIter.hasTop()) {
-            Key key = dataIter.getTopKey();
-            Value value = dataIter.getTopValue();
-            if (opts.dump) {
-              System.out.println(key + " -> " + value);
-              if (System.out.checkError())
+
+          if (formatter != null) {
+            while (formatter.hasNext()) {
+              System.out.print(formatter.next());
+              if (System.out.checkError()) {
                 return;
+              }
             }
-            if (opts.histogram) {
-              kvHistogram.add(key.getSize() + value.getSize());
-            }
-            if (opts.keyStats) {
-              dataKeyStats.add(key);
+          } else {
+            while (dataIter.hasTop()) {
+              Key key = dataIter.getTopKey();
+              Value value = dataIter.getTopValue();
+              if (opts.dump || opts.fullKeys) {
+                System.out
+                    .println((opts.fullKeys ? key.toStringNoTruncate() : key) + " -> " + value);
 
 Review comment:
   ```suggestion
                 if (formatter != null) {
                   System.out
                       .println(formatter.apply(key,value));
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services