Created
December 15, 2015 08:44
-
-
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!
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
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