Thanks Tyler.

I am able to get the key and value, but it is only for that cell. I tried
my best but could not reference to the other cells for that Map?

For now I have added 2 rows effectively for that Map

mymap: {"1":"value1,"2":"value2"}

Also, the code as below, is returning me a list of cells but there is only
1 cell matching the name "mymap". What is the missing piece in here?

DecoratedKey dkey = StorageService.getPartitioner().decorateKey(rowKey);
QueryFilter qf =  QueryFilter.getIdentityFilter(dkey,
                  baseCfs.metadata.cfName,
                  Calendar.getInstance().getTimeInMillis());
ColumnFamily cf = baseCfs.getColumnFamily(qf);




Regards,
Arindam Bose
+1 469-231-3862


On Wed, Aug 27, 2014 at 1:04 PM, Tyler Hobbs <ty...@datastax.com> wrote:

> Maps (and other collections) are stored in multiple cells, one cell per
> item.  To get the map keys, use cell.name().collectionElement() and
> deserialize with the type for the keys (UTF8Type.instance).  For values,
> use cell.value() and use the value type (also UTF8Type.instance, here).
>
>
> On Wed, Aug 27, 2014 at 12:54 PM, Arindam Bose <arindambos...@gmail.com>
> wrote:
>
> > Added few more information:
> >
> > I need some help in reading CQL3 Collection type values while getting a
> > callback to the Custom Secondary Index (cassandra 2.1.0).
> >
> > Column Family:
> >
> > CREATE TABLE IF NOT EXISTS test1(
> > id text,
> > mymap map<text,text>,
> > PRIMARY KEY(id)
> > )
> >
> > Added value:
> >
> > Insert into test(id, mymap) values ('1', {'1':'value1'});
> >
> > Then in my custom class I am trying to read mymap Cell.value() and
> > deserialize the ByteBuffervalue to get the full map content as below:
> >
> > To get the row data based on a rowKey in callback:
> >
> > DecoratedKey dkey = StorageService.getPartitioner().decorateKey(rowKey);
> > QueryFilter qf =  QueryFilter.getIdentityFilter(dkey,
> >                   baseCfs.metadata.cfName,
> >                   Calendar.getInstance().getTimeInMillis());
> > ColumnFamily cf = baseCfs.getColumnFamily(qf);
> >
> > for (Cell cell : cf)
> > {
> >     if( cell name is "mymap" )
> >     {
> >         LOGGER.debug("for column mymap");
> >
> >         Map<String, String> mymap= MapType.getInstance(UTF8Type.instance,
> >          UTF8Type.instance).compose(cell.value().duplicate());
> >         for(String key: mymap.keySet())
> >         {
> >             LOGGER.debug("mymapkey [{}]: [{}]", key, mymap.get(key));
> >         }
> >     }
> > }
> >
> > But I am not getting the values in the persisted in the Map. It says
> *"Not
> > enough bytes to read a map"*
> >
> > Is there anyone who can help?
> >
> >
> >
> > Regards,
> > Arindam Bose
> >
> >
> >
> > On Wed, Aug 27, 2014 at 11:21 AM, Arindam Bose <arindambos...@gmail.com>
> > wrote:
> >
> > > Hello,
> > >
> > > I need some help in reading CQL3 Collection type values while getting a
> > > callback to the Custom Secondary Index.
> > >
> > > Column Family:
> > >
> > > CREATE TABLE IF NOT EXISTS test1(
> > > id text,
> > > mymap map<text,text>,
> > > PRIMARY KEY(id)
> > > )
> > >
> > > Added value:
> > >
> > > Insert into test(id, mymap) values ('1', {'1':'value1'});
> > >
> > > Then in my custom class I am trying to read mymap Cell.value() and
> > > deserialize the ByteBuffervalue to get the full map content.
> > >
> > > But I am not getting the values as persisted in the mymap Column within
> > > Cassandra.
> > >
> > > Is there anyone who can help?
> > >
> > >
> > > Regards,
> > > Arindam Bose
> > >
> >
>
>
>
> --
> Tyler Hobbs
> DataStax <http://datastax.com/>
>

Reply via email to