You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Markus Wiesenbacher (JIRA)" <ji...@apache.org> on 2011/02/21 23:30:38 UTC
[jira] Updated: (CASSANDRA-2210) butch_mutate (java) does overwrite
instead of updating
[ https://issues.apache.org/jira/browse/CASSANDRA-2210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Markus Wiesenbacher updated CASSANDRA-2210:
-------------------------------------------
Description:
I want to insert a supercolumn, and I don´t know what I could use instead of batch_mutate. I am using this method:
[CODE]
client.set_keyspace(keyspace);
List<Column> columns = new ArrayList<Column>();
for (String key : values.keySet())
columns.add(new Column(ByteBuffer.wrap(key.getBytes()), ByteBuffer.wrap(values.get(key).getBytes()), System.currentTimeMillis()));
SuperColumn superColumn = new SuperColumn(ByteBuffer.wrap(name_SuperColumn.getBytes("UTF-8")), columns);
ColumnOrSuperColumn columnOrSuperColumn = new ColumnOrSuperColumn();
columnOrSuperColumn.setSuper_column(superColumn);
Mutation mutation = new Mutation();
mutation.setColumn_or_supercolumn(columnOrSuperColumn);
// map<rowkey : string, map<column_family : string, list<Mutation>>>
// To be more specific, the outer map key is a row key, the inner map key is the column family name.
Map<ByteBuffer, Map<String, List<Mutation>>> muts = new HashMap<ByteBuffer, Map<String,List<Mutation>>>();
Map<String, List<Mutation>> mut = new HashMap<String, List<Mutation>>();
List<Mutation> mu = new ArrayList<Mutation>();
mu.add(mutation);
mut.put(column_family, mu);
muts.put(ByteBuffer.wrap(rowKey.getBytes()), mut);
client.batch_mutate(muts, ConsistencyLevel.ONE);
[/CODE]
I am calling the method with this:
f.insertSuper("TEST", "super", "testrow1", "id#1", values);
f.insertSuper("TEST", "super", "testrow1", "id#2", values);
TEST = keyspace
super = column family
testrow1 = row key
id#1 = super column key
values = Map of key value pairs
I would expect two entries, one with id#1 and one with id#2, but there´s only id#2? Is this a bug or do I have to select all columns and have to rewrite it again? I hope not ... ;)
Best regards
wiesi :)
was:
I am using this method:
[CODE]
client.set_keyspace(keyspace);
List<Column> columns = new ArrayList<Column>();
for (String key : values.keySet())
columns.add(new Column(ByteBuffer.wrap(key.getBytes()), ByteBuffer.wrap(values.get(key).getBytes()), System.currentTimeMillis()));
SuperColumn superColumn = new SuperColumn(ByteBuffer.wrap(name_SuperColumn.getBytes("UTF-8")), columns);
ColumnOrSuperColumn columnOrSuperColumn = new ColumnOrSuperColumn();
columnOrSuperColumn.setSuper_column(superColumn);
Mutation mutation = new Mutation();
mutation.setColumn_or_supercolumn(columnOrSuperColumn);
// map<rowkey : string, map<column_family : string, list<Mutation>>>
// To be more specific, the outer map key is a row key, the inner map key is the column family name.
Map<ByteBuffer, Map<String, List<Mutation>>> muts = new HashMap<ByteBuffer, Map<String,List<Mutation>>>();
Map<String, List<Mutation>> mut = new HashMap<String, List<Mutation>>();
List<Mutation> mu = new ArrayList<Mutation>();
mu.add(mutation);
mut.put(column_family, mu);
muts.put(ByteBuffer.wrap(rowKey.getBytes()), mut);
client.batch_mutate(muts, ConsistencyLevel.ONE);
[/CODE]
I am calling the method with this:
f.insertSuper("TEST", "super", "testrow1", "id#1", values);
f.insertSuper("TEST", "super", "testrow1", "id#2", values);
TEST = keyspace
super = column family
testrow1 = row key
id#1 = super column key
values = Map of key value pairs
I would expect two entries, one with id#1 and one with id#2, but there´s only id#2?
> butch_mutate (java) does overwrite instead of updating
> ------------------------------------------------------
>
> Key: CASSANDRA-2210
> URL: https://issues.apache.org/jira/browse/CASSANDRA-2210
> Project: Cassandra
> Issue Type: Bug
> Components: API
> Affects Versions: 0.7.2
> Reporter: Markus Wiesenbacher
>
> I want to insert a supercolumn, and I don´t know what I could use instead of batch_mutate. I am using this method:
> [CODE]
> client.set_keyspace(keyspace);
> List<Column> columns = new ArrayList<Column>();
> for (String key : values.keySet())
> columns.add(new Column(ByteBuffer.wrap(key.getBytes()), ByteBuffer.wrap(values.get(key).getBytes()), System.currentTimeMillis()));
> SuperColumn superColumn = new SuperColumn(ByteBuffer.wrap(name_SuperColumn.getBytes("UTF-8")), columns);
> ColumnOrSuperColumn columnOrSuperColumn = new ColumnOrSuperColumn();
> columnOrSuperColumn.setSuper_column(superColumn);
>
> Mutation mutation = new Mutation();
> mutation.setColumn_or_supercolumn(columnOrSuperColumn);
>
> // map<rowkey : string, map<column_family : string, list<Mutation>>>
> // To be more specific, the outer map key is a row key, the inner map key is the column family name.
> Map<ByteBuffer, Map<String, List<Mutation>>> muts = new HashMap<ByteBuffer, Map<String,List<Mutation>>>();
> Map<String, List<Mutation>> mut = new HashMap<String, List<Mutation>>();
> List<Mutation> mu = new ArrayList<Mutation>();
> mu.add(mutation);
> mut.put(column_family, mu);
> muts.put(ByteBuffer.wrap(rowKey.getBytes()), mut);
>
> client.batch_mutate(muts, ConsistencyLevel.ONE);
> [/CODE]
> I am calling the method with this:
> f.insertSuper("TEST", "super", "testrow1", "id#1", values);
> f.insertSuper("TEST", "super", "testrow1", "id#2", values);
> TEST = keyspace
> super = column family
> testrow1 = row key
> id#1 = super column key
> values = Map of key value pairs
> I would expect two entries, one with id#1 and one with id#2, but there´s only id#2? Is this a bug or do I have to select all columns and have to rewrite it again? I hope not ... ;)
> Best regards
> wiesi :)
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira