Created
October 22, 2009 21:31
-
-
Save kevinpet/216354 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Return a timestamp from an HBase cell | |
# [cell] the cell itself or its contents | |
def self.time_from_hbase(cell) | |
# unpack 8 bytes in network (big endian) byte order | |
if cell.respond_to? :value | |
a = cell.value | |
else | |
a = cell | |
end | |
halves = a.unpack "NN" | |
millis = (halves[0] << 32) + halves[1] | |
Time.at(millis / 1000) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment