This is an automated email from the ASF dual-hosted git repository.

elserj pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.4 by this push:
     new 06ef9e9  HBASE-26512 Make timestamp format configurable in HBase shell 
scan output
06ef9e9 is described below

commit 06ef9e9778ae2e1747b44bf994b241b890f07895
Author: Istvan Toth <st...@stoty.hu>
AuthorDate: Mon Nov 29 11:34:24 2021 +0100

    HBASE-26512 Make timestamp format configurable in HBase shell scan output
    
    Signed-off-by: Josh Elser <els...@apache.org
    Signed-off-by: Peter Somogyi <psomo...@apache.org>
---
 .../src/main/java/org/apache/hadoop/hbase/HConstants.java     |  5 +++++
 hbase-shell/src/main/ruby/hbase/table.rb                      | 11 +++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
index 13dc401..dab33d3 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
@@ -1668,6 +1668,11 @@ public final class HConstants {
     "hbase.regionserver.slowlog.systable.enabled";
   public static final boolean DEFAULT_SLOW_LOG_SYS_TABLE_ENABLED_KEY = false;
 
+  public static final String SHELL_TIMESTAMP_FORMAT_EPOCH_KEY =
+      "hbase.shell.timestamp.format.epoch";
+
+  public static final boolean DEFAULT_SHELL_TIMESTAMP_FORMAT_EPOCH = false;
+
   /**
    * Number of rows in a batch operation above which a warning will be logged.
    */
diff --git a/hbase-shell/src/main/ruby/hbase/table.rb 
b/hbase-shell/src/main/ruby/hbase/table.rb
index 7351676..3fc6c85 100644
--- a/hbase-shell/src/main/ruby/hbase/table.rb
+++ b/hbase-shell/src/main/ruby/hbase/table.rb
@@ -119,6 +119,9 @@ EOF
       @name = @table.getName.getNameAsString
       @shell = shell
       @converters = {}
+      @timestamp_format_epoch = table.getConfiguration.getBoolean(
+          HConstants::SHELL_TIMESTAMP_FORMAT_EPOCH_KEY,
+          HConstants::DEFAULT_SHELL_TIMESTAMP_FORMAT_EPOCH)
     end
 
     def close
@@ -751,8 +754,12 @@ EOF
     end
 
     def toLocalDateTime(millis)
-      instant = java.time.Instant.ofEpochMilli(millis)
-      return java.time.LocalDateTime.ofInstant(instant, 
java.time.ZoneId.systemDefault()).toString
+      if @timestamp_format_epoch
+        return millis
+      else
+        instant = java.time.Instant.ofEpochMilli(millis)
+        return java.time.LocalDateTime.ofInstant(instant, 
java.time.ZoneId.systemDefault()).toString
+      end
     end
 
     # Make a String of the passed kv

Reply via email to