Tuesday, August 3, 2010

Implementing the comments: Writing a comment as a supercolumn

So far we have looked at simple column families but now it’s time to tackle super columns. We are still working with the BloggyAppy design from Arin Sarkissian. We are using some code from Hector’s test code.

Following Arin’s specification the Comments Column Family is going to look like this

Comments: {
 Blog-Slug:{
  Time_UUID_1:{
   Coment: A Comment,
   Email: andy@abc.com
},
Time_UUID_2:{
   Coment: A Comment,
   Email: andy@abc.com
}
}
}

Lets be clear Blog-Slug will be the Slug entry for the blog that is being commented on. This is the key we will be looking for. Under that are the supercolumn entries, with a key of type UUID. This contains a number of columns that are the entries for the comments. So to add a comment we can do this:
Keyspace ks = client.getKeyspace("BloggyAppy");
ColumnPath cp = new ColumnPath("Comments");
java.util.UUID timeUUID=getTimeUUID();              
cp.setSuper_column(asByteArray(timeUUID));
cp.setColumn(bytes("email"));
ks.insert(slugValue, cp, bytes("andy@abc.com"));
cp.setColumn(bytes("Comment"));
ks.insert(slugValue, cp, bytes("AComment"));


SlugValue is essentially the title. Note that getTimeUUID is defined as:

public static java.util.UUID getTimeUUID()
     {
return java.util.UUID.fromString(new com.eaio.uuid.UUID().toString());
     }

8 comments:

  1. Awesome information. I am really surprised with this topic. Keep up the good work and post more here to read.

    ケムサーチ

    ReplyDelete
    Replies
    1. Thanks for the informative and useful information shared on the blog. I really enjoyed reading the article. Low Cost Website Design Company

      Delete
  2. Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share.

    commercial trash receptacles

    ReplyDelete
  3. Thanks so much with this fantastic new web site. I'm very fired up to show it to anyone. It makes me so satisfied your vast understanding and wisdom have a new channel on the world.

    ReplyDelete
  4. I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
    Read More: App development Company
    Mobial App development Company

    ReplyDelete
  5. Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. Web development belize

    ReplyDelete
  6. Nice post this one is, thanks for sharing this information with us.
    Shopify Development Company

    ReplyDelete