HBASE-24937 table.rb use LocalDateTime to replace Instant (#2351)

Signed-off-by: Pankaj Kumar<pankajkumar@apache.org>
This commit is contained in:
Bo Cui 2020-09-04 22:50:39 +08:00 committed by GitHub
parent 19d0140562
commit 1e8db480b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -750,8 +750,9 @@ EOF
[spec.family, spec.qualifier] [spec.family, spec.qualifier]
end end
def toISO8601(millis) def toLocalDateTime(millis)
return java.time.Instant.ofEpochMilli(millis).toString 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 # Make a String of the passed kv
@ -762,7 +763,7 @@ EOF
column.start_with?('info:merge') column.start_with?('info:merge')
hri = org.apache.hadoop.hbase.client.RegionInfo.parseFromOrNull(kv.getValueArray, hri = org.apache.hadoop.hbase.client.RegionInfo.parseFromOrNull(kv.getValueArray,
kv.getValueOffset, kv.getValueLength) kv.getValueOffset, kv.getValueLength)
return format('timestamp=%s, value=%s', toISO8601(kv.getTimestamp), return format('timestamp=%s, value=%s', toLocalDateTime(kv.getTimestamp),
hri.nil? ? '' : hri.toString) hri.nil? ? '' : hri.toString)
end end
if column == 'info:serverstartcode' if column == 'info:serverstartcode'
@ -773,14 +774,14 @@ EOF
str_val = org.apache.hadoop.hbase.util.Bytes.toStringBinary(kv.getValueArray, str_val = org.apache.hadoop.hbase.util.Bytes.toStringBinary(kv.getValueArray,
kv.getValueOffset, kv.getValueLength) kv.getValueOffset, kv.getValueLength)
end end
return format('timestamp=%s, value=%s', toISO8601(kv.getTimestamp), str_val) return format('timestamp=%s, value=%s', toLocalDateTime(kv.getTimestamp), str_val)
end end
end end
if org.apache.hadoop.hbase.CellUtil.isDelete(kv) if org.apache.hadoop.hbase.CellUtil.isDelete(kv)
val = "timestamp=#{toISO8601(kv.getTimestamp)}, type=#{org.apache.hadoop.hbase.KeyValue::Type.codeToType(kv.getTypeByte)}" val = "timestamp=#{toLocalDateTime(kv.getTimestamp)}, type=#{org.apache.hadoop.hbase.KeyValue::Type.codeToType(kv.getTypeByte)}"
else else
val = "timestamp=#{toISO8601(kv.getTimestamp)}, value=#{convert(column, kv, converter_class, converter)}" val = "timestamp=#{toLocalDateTime(kv.getTimestamp)}, value=#{convert(column, kv, converter_class, converter)}"
end end
maxlength != -1 ? val[0, maxlength] : val maxlength != -1 ? val[0, maxlength] : val
end end