Inorder to create a super column we ll need to have a columnFamily with type super .
So let us add a columnFamily Supermaster to the KeySpace "Prototype"
<Keyspace Name="Prototype">
<ColumnFamily Name="master" CompareWith="UTF8Type" />
<ColumnFamily ColumnType="Super" CompareWith="UTF8Type" Name="Supermaster" />
<ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
<ReplicationFactor>1</ReplicationFactor>
<EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
</Keyspace>
Now lets try inserting some data into it.
cassandra> set Prototype.Supermaster['1']['address']['apt']='B-5C'
Value inserted.
Here 'address' is the Super-Column and apt is the column of the super column
Now lets fetch it :
cassandra> get Prototype.Supermaster['1']
=> (super_column=address,
(column=617074, value=B-5C, timestamp=1286273186596000))
Returned 1 results.
Adding few more entries to the super column for the rowKey :
cassandra> set Prototype.Supermaster['1']['address']['flat']='CDS, RPG'
Value inserted.
cassandra> set Prototype.Supermaster['1']['address']['area']='velachery'
Value inserted.
cassandra> set Prototype.Supermaster['1']['address']['city']='chennai'
Value inserted.
Fetching all the 4 columns in the Super-Column 'address'
cassandra> get Prototype.Supermaster['1']['address']
=> (column=flat, value=CDS, RPG, timestamp=1286273243882000)
=> (column=city, value=chennai, timestamp=1286273287246000)
=> (column=area, value=velachery, timestamp=1286273267318000)
=> (column=apt, value=B-5C, timestamp=1286273186596000)
Returned 4 results.
No comments:
Post a Comment