Skip to content

Commit

Permalink
HBASE-26512 Make timestamp format configurable in HBase shell scan ou…
Browse files Browse the repository at this point in the history
…tput

Signed-off-by: Josh Elser <[email protected]
Signed-off-by: Peter Somogyi <[email protected]>
  • Loading branch information
stoty authored and joshelser committed Dec 1, 2021
1 parent 6fc5bbc commit 061ccff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1685,6 +1685,11 @@ public enum OperationStatusCode {
"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.
*/
Expand Down
11 changes: 9 additions & 2 deletions hbase-shell/src/main/ruby/hbase/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ def initialize(table, shell)
@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
Expand Down Expand Up @@ -751,8 +754,12 @@ def parse_column_name(column)
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
Expand Down

0 comments on commit 061ccff

Please sign in to comment.