Permalink
Browse files

Added hbaseShellId method to get an id compatible with hbase shell

  • Loading branch information...
1 parent f5337e8 commit 2194411ce4baac28919aaa6e408c0e183172f4a9 @xstevens xstevens committed Feb 12, 2013
Showing with 17 additions and 0 deletions.
  1. +17 −0 src/main/java/com/mozilla/bagheera/util/IdUtil.java
View
17 src/main/java/com/mozilla/bagheera/util/IdUtil.java
@@ -80,4 +80,21 @@
return buf.array();
}
+ /**
+ * Takes a given id and gives you an hbase shell compatible string that you can
+ * use for get command.
+ * @param id
+ * @param d
+ * @return
+ * @throws IOException
+ */
+ public static String hbaseShellId(String id, Date d) throws IOException {
+ byte[] idBytes = IdUtil.nonRandByteBucketizeId(id, d);
+ StringBuilder sb = new StringBuilder("\"\\x");
+ sb.append(String.format("%02x", idBytes[0]));
+ sb.append((new String(idBytes)).substring(1));
+ sb.append("\"");
+ return sb.toString();
+ }
+
}

0 comments on commit 2194411

Please sign in to comment.