On Fri, Jan 7, 2011 at 12:12 PM, Arijit Mukherjee <ariji...@gmail.com>wrote:

> Thank you. And is it similar if I want to search a subcolumn within a
> given supercolumn? I mean I have the supercolumn key and the subcolumn
> key - can I fetch the particular subcolumn?
>
> Can you share a small piece of example code for both?
>

Have you gone through the examples  @
https://github.com/rantav/hector/blob/master/core/src/test/java/me/prettyprint/hector/api/ApiV2SystemTest.java?

For now, here are some snippets to help you:

1) So, say, for a given row and a given super-column, if u want to fetch one
particular sub-column, this is how you can do it:

SubSliceQuery subSliceQuery = HFactory.createSubSliceQuery(keyspace, .., ..,
.., ..)
subSliceQuery.setColumnFamily(<name_of_col_family>)
.setKey(<row_key>).setSuperColumn(<super-column-key>).setRange(subCol,
subCol, false, 1)

You can manipulate the range, if you want more than 1 sub-column from there.

2) Inserting a new super-column (with its sub-columns) in a row

HSuperColumn superCol = HFactory.createSuperColumn(<super-column-key>,
                   [HFactory.createColumn(<sub-column-key>, new byte[0], US,
BAS)],
                   SS, US, BAS) - /* SS, US, etc are serializers used here.
*/

mutator.addInsertion(<row-key>, <name_of_col_family>, superCol)

This example inserts in a row a new super-column that has 1 sub-column (you
can add as many as u like to the list of sub-cols being passed)


<#12d5f46d9509473c_>
<#12d5f46d9509473c_>             <#12d5f46d9509473c_>
<#12d5f46d9509473c_>
                                                   <#>
<#>
<#>       <#>

Reply via email to