Skip to content

Instantly share code, notes, and snippets.

@kevinpet
Created October 22, 2009 21:31
Show Gist options
  • Save kevinpet/216354 to your computer and use it in GitHub Desktop.
Save kevinpet/216354 to your computer and use it in GitHub Desktop.
# 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