use batch_insert when you are inserting more than one simple column at a time.

On Fri, Dec 11, 2009 at 5:39 PM, matt...@mustardgrain.com
<matt...@mustardgrain.com> wrote:
> Hello,
> I'm working on a project in Java using Cassandra, and I'm trying to
> implement SuperColumns into the program. The problem is that I really don't
> know how to insert a SuperColumn into Cassandra. I can create the
> SuperColumn with the list of Columns but I really don't know where to go
> from there:
>       Column ageColumn = new Column("age".getBytes(), ageString.getBytes(),
> timestamp);
>       Column emailAddressColumn = new Column("email".getBytes(),
> emailAddress.getBytes(), timestamp);
>       Column firstNameColumn = new Column("firstName".getBytes(),
> firstName.getBytes(), timestamp);
>       Column lastNameColumn = new Column("lastName".getBytes(),
> lastName.getBytes(), timestamp);
>       List<Column> userColumnList = new ArrayList<Column>();
>       userColumnList.add(ageColumn);
>       userColumnList.add(emailAddressColumn);
>       userColumnList.add(firstNameColumn);
>       userColumnList.add(lastNameColumn);
>       SuperColumn userInfo = new SuperColumn("user".getBytes(),
> userColumnList);
>
> After this code I have an insert method, but at the moment the only thing I
> can get it to do with the SuperColumn is take the list and loop through and
> insert each of them:
>
>     for (Column c : columnList) {
>           ColumnPath cp = new ColumnPath(getColumnFamily(),
> superColumn.getBytes(), c.getName());
>           client.insert("Keyspace1", id, cp, c.value, timestamp,
> ConsistencyLevel.ONE);
>      }
>
> I'm new at Cassandra so for all I know I'm barking up the wrong tree, but
> I'm trying to avoid making multiple calls to Cassandra to insert one atomic
> value. The goal for me is to have the values for a User inserted at once to
> avoid performance issues and data corruption.
>
> Thanks,
>   Matthew.
>

Reply via email to