HBASE-23930 Shell should attempt to format `timestamp` attributes as ISO-8601
Make display of Cell timestamp be ISO8601 format instead of pure milliseconds.
This commit is contained in:
parent
6f1e8abc30
commit
cf121227aa
|
@ -734,6 +734,10 @@ EOF
|
|||
[split[0], split.length > 1 ? split[1] : nil]
|
||||
end
|
||||
|
||||
def toISO8601(millis)
|
||||
return java.time.Instant.ofEpochMilli(millis).toString
|
||||
end
|
||||
|
||||
# Make a String of the passed kv
|
||||
# Intercept cells whose format we know such as the info:regioninfo in hbase:meta
|
||||
def to_string(column, kv, maxlength = -1, converter_class = nil, converter = nil)
|
||||
|
@ -741,8 +745,9 @@ EOF
|
|||
if column == 'info:regioninfo' || column == 'info:splitA' || column == 'info:splitB' || \
|
||||
column.start_with?('info:merge')
|
||||
hri = org.apache.hadoop.hbase.HRegionInfo.parseFromOrNull(kv.getValueArray,
|
||||
kv.getValueOffset, kv.getValueLength)
|
||||
return format('timestamp=%d, value=%s', kv.getTimestamp, hri.nil? ? '' : hri.toString)
|
||||
kv.getValueOffset, kv.getValueLength)
|
||||
return format('timestamp=%s, value=%s', toISO8601(kv.getTimestamp),
|
||||
hri.nil? ? '' : hri.toString)
|
||||
end
|
||||
if column == 'info:serverstartcode'
|
||||
if kv.getValueLength > 0
|
||||
|
@ -752,14 +757,14 @@ EOF
|
|||
str_val = org.apache.hadoop.hbase.util.Bytes.toStringBinary(kv.getValueArray,
|
||||
kv.getValueOffset, kv.getValueLength)
|
||||
end
|
||||
return format('timestamp=%d, value=%s', kv.getTimestamp, str_val)
|
||||
return format('timestamp=%s, value=%s', toISO8601(kv.getTimestamp), str_val)
|
||||
end
|
||||
end
|
||||
|
||||
if org.apache.hadoop.hbase.CellUtil.isDelete(kv)
|
||||
val = "timestamp=#{kv.getTimestamp}, type=#{org.apache.hadoop.hbase.KeyValue::Type.codeToType(kv.getTypeByte)}"
|
||||
val = "timestamp=#{toISO8601(kv.getTimestamp)}, type=#{org.apache.hadoop.hbase.KeyValue::Type.codeToType(kv.getTypeByte)}"
|
||||
else
|
||||
val = "timestamp=#{kv.getTimestamp}, value=#{convert(column, kv, converter_class, converter)}"
|
||||
val = "timestamp=#{toISO8601(kv.getTimestamp)}, value=#{convert(column, kv, converter_class, converter)}"
|
||||
end
|
||||
maxlength != -1 ? val[0, maxlength] : val
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue