Hi.
What is the best practice in hbase when it comes to creating "mapping"
tables between objects?
Let's say you want to create two tables named "User" and "Role" where the
user can be in many roles.
User->Role
I guess you could create some specially, proprietary cells like role:someuid
which contains the ref to the Role table but this seems a little strange.
Another quite normal example (for me at lesast) is to tag various content.
Eg:
BlogEntry<-BlogEntryCategory->Category
where in a rdbms the BlogEntryCategory would just contain two cols
blogEntryId and categoryId.
Howto model that with column families ?
Right now I'm creating Serializers which can serialize arrays back and forth
Eg StringArraySerializer
public byte[] serialize(Object object) throws IOException
{
String[] a = (String[])object;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < a.length; i++)
{
sb.append(a[i]);
if(i < (a.length - 1))
{
sb.append(this.delimiter);
}
}
return sb.toString().getBytes("UTF-8");
}
public Object deserialize(byte[] bytes) throws IOException
{
String str = new String(bytes, "UTF-8");
StringTokenizer st = new StringTokenizer(str, delimiter);
List<String> list = new ArrayList();
while(st.hasMoreTokens())
{
String token = st.nextToken();
list.add(token);
}
return list.toArray(new String[list.size()]);
}
and then store the byte[] in hbase. Ugly....
Please guide my sorry ass.
Kindly
//Marcus
--
Marcus Herou CTO and co-founder Tailsweep AB
+46702561312
[EMAIL PROTECTED]
http://www.tailsweep.com/
http://blogg.tailsweep.com/