Skip to content

Commit 7845d00

Browse files
stotyjoshelser
authored andcommitted
HBASE-26512 Make timestamp format configurable in HBase shell scan output
Signed-off-by: Josh Elser <[email protected] Signed-off-by: Peter Somogyi <[email protected]>
1 parent ea824df commit 7845d00

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,6 +1602,11 @@ public enum OperationStatusCode {
16021602
"hbase.regionserver.slowlog.systable.enabled";
16031603
public static final boolean DEFAULT_SLOW_LOG_SYS_TABLE_ENABLED_KEY = false;
16041604

1605+
public static final String SHELL_TIMESTAMP_FORMAT_EPOCH_KEY =
1606+
"hbase.shell.timestamp.format.epoch";
1607+
1608+
public static final boolean DEFAULT_SHELL_TIMESTAMP_FORMAT_EPOCH = false;
1609+
16051610
/**
16061611
* Number of rows in a batch operation above which a warning will be logged.
16071612
*/

hbase-shell/src/main/ruby/hbase/table.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ def initialize(table, shell)
119119
@name = @table.getName.getNameAsString
120120
@shell = shell
121121
@converters = {}
122+
@timestamp_format_epoch = table.getConfiguration.getBoolean(
123+
HConstants::SHELL_TIMESTAMP_FORMAT_EPOCH_KEY,
124+
HConstants::DEFAULT_SHELL_TIMESTAMP_FORMAT_EPOCH)
122125
end
123126

124127
def close
@@ -751,8 +754,12 @@ def parse_column_name(column)
751754
end
752755

753756
def toLocalDateTime(millis)
754-
instant = java.time.Instant.ofEpochMilli(millis)
755-
return java.time.LocalDateTime.ofInstant(instant, java.time.ZoneId.systemDefault()).toString
757+
if @timestamp_format_epoch
758+
return millis
759+
else
760+
instant = java.time.Instant.ofEpochMilli(millis)
761+
return java.time.LocalDateTime.ofInstant(instant, java.time.ZoneId.systemDefault()).toString
762+
end
756763
end
757764

758765
# Make a String of the passed kv

0 commit comments

Comments
 (0)