Skip to content
This repository
Browse code

Added hbaseShellId method to get an id compatible with hbase shell

  • Loading branch information...
commit 2194411ce4baac28919aaa6e408c0e183172f4a9 1 parent f5337e8
Xavier xstevens authored

Showing 1 changed file with 17 additions and 0 deletions. Show diff stats Hide diff stats

  1. +17 0 src/main/java/com/mozilla/bagheera/util/IdUtil.java
17 src/main/java/com/mozilla/bagheera/util/IdUtil.java
@@ -80,4 +80,21 @@
80 80 return buf.array();
81 81 }
82 82
  83 + /**
  84 + * Takes a given id and gives you an hbase shell compatible string that you can
  85 + * use for get command.
  86 + * @param id
  87 + * @param d
  88 + * @return
  89 + * @throws IOException
  90 + */
  91 + public static String hbaseShellId(String id, Date d) throws IOException {
  92 + byte[] idBytes = IdUtil.nonRandByteBucketizeId(id, d);
  93 + StringBuilder sb = new StringBuilder("\"\\x");
  94 + sb.append(String.format("%02x", idBytes[0]));
  95 + sb.append((new String(idBytes)).substring(1));
  96 + sb.append("\"");
  97 + return sb.toString();
  98 + }
  99 +
83 100 }

0 comments on commit 2194411

Please sign in to comment.
Something went wrong with that request. Please try again.