Skip to content

Instantly share code, notes, and snippets.

@trygvea
Created December 15, 2015 08:44
Show Gist options
  • Save trygvea/a35999de8ee0ee14bcc5 to your computer and use it in GitHub Desktop.
Save trygvea/a35999de8ee0ee14bcc5 to your computer and use it in GitHub Desktop.
Some groovy/java utilities for HBase shell. Note that IntelliJ has groovy console built-in!
import java.nio.ByteBuffer
public static byte[] bytes(long l) {
ByteBuffer.allocate(Long.BYTES).putLong(l).array();
}
def pretty(byte[] b) {
def sb = new StringBuilder()
for(i=0;i<b.length;i++){
sb.append(String.format("\\x%02X", b[i]))
}
sb.toString()
}
def long2hex(l) {pretty(bytes(l))}
// hbase shell:
// scan 'forecast-availability', { STARTROW => "\x00\x00\x00\x00\x06\x69\x96\xB4", ENDROW => "\x00\x00\x00\x00\x06\x69\x96\xB4\xFF" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment