You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Sylvain Lebresne (JIRA)" <ji...@apache.org> on 2012/10/26 12:03:12 UTC

[jira] [Commented] (CASSANDRA-4468) Temporally unreachable Dynamic Composite column names.

    [ https://issues.apache.org/jira/browse/CASSANDRA-4468?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13484823#comment-13484823 ] 

Sylvain Lebresne commented on CASSANDRA-4468:
---------------------------------------------

{quote}
This is a real interesting feature but actually I fear it couldn't help me. 
In the code I developed I insert in the same CF more 'maps' which use different types of data as key. 
{quote}

So a fix is attached to CASSANDRA-4711, but for the record I do think that collections would likely work for what you are doing (at least based on the information provided). Namely, what you are doing is equivalent to defining in CQL3:
{noformat}
CREATE TABLE foo (
  row_key text PRIMARY KEY,
  s set<string>,
  i set<int>,
  d set<double>,
  ...
)
{noformat}
And yes you do declare one CQL column for each type you're using, but that has no performance impact whatsoever and you do have to declare the aliases when you use DynamicCompositeType so it's the same. The advantages of doing this with CQL3 sets being that the API will be much nicer (CQL3 regroups all the value of the same time for you basically instead of having you needing to do that manually). 
                
> Temporally unreachable Dynamic Composite column names.
> ------------------------------------------------------
>
>                 Key: CASSANDRA-4468
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-4468
>             Project: Cassandra
>          Issue Type: Bug
>    Affects Versions: 1.1.0, 1.1.1, 1.1.2
>         Environment: linux, 
>            Reporter: Cesare Cugnasco
>            Priority: Minor
>              Labels: persistence
>         Attachments: BugFinder.java
>
>
> I was working on a Column family with a DynamicComposite column sorter when I noticed that sometimes, after the insertion of a column with a column name composed by a single string (eg 's@step'),it was possible to be reach the column only by slice query but not by direct access. For example using the cassandra-cli it is possible to query: 
> get frame[int(26)];
> RowKey: 0000001a
> ....
>  (column=i@19, value=00000013, timestamp=1343495134729000)
> => (column=s@step, value=746573742076616c7565, timestamp=1343495134680000)
> but typing 'get frame[int(26)]['s@step']' I got no result.
> I tested this behavior using also other clients such as Hector, Astyanax, Pycassa and directly Thrift. 
> I wrote this java code with hector-core-1.1.0 to reproduce this bug.
> public static void main(String[] args) {
>         String kname = "testspace3";
>         Cluster myCluster = HFactory.getOrCreateCluster("Test-cluster", System.getProperty("location", "localhost:9160"));
>         //creating the keyspace and Column family
>         if (myCluster.describeKeyspace(kname) != null) {
>             myCluster.dropKeyspace(kname, true);
>         }        
>         ColumnFamilyDefinition cfd = HFactory.createColumnFamilyDefinition(kname, "frame", ComparatorType.DYNAMICCOMPOSITETYPE);
>         cfd.setComparatorTypeAlias(DynamicComposite.DEFAULT_DYNAMIC_COMPOSITE_ALIASES);
>         KeyspaceDefinition kdf = HFactory.createKeyspaceDefinition(kname, "SimpleStrategy", 1, Arrays.asList(cfd));
>         myCluster.addKeyspace(kdf, true);
>         Keyspace ksp = HFactory.createKeyspace(kname, myCluster);
>         //Hector template definition
>         ColumnFamilyTemplate<Integer, DynamicComposite> template =
>                 new ThriftColumnFamilyTemplate<Integer, DynamicComposite>(
>                 ksp,
>                 "frame",
>                 IntegerSerializer.get(),
>                 DynamicCompositeSerializer.get());
>         
>         DynamicComposite dc = new DynamicComposite();
>         dc.addComponent("step", StringSerializer.get());
>         DynamicComposite numdc = new DynamicComposite();
>         numdc.addComponent(BigInteger.valueOf(62), BigIntegerSerializer.get());
>         ColumnFamilyUpdater<Integer, DynamicComposite> cf = template.createUpdater(26);
>         cf.setString(dc, "test value");
>         cf.setString(numdc, "altro valore");
>         template.update(cf);
>         //without this parts it works. It works also with less then 4 insertions
>         cf = template.createUpdater(26);
>         for (int i = 0; i < 4; i++) {
>             DynamicComposite num = new DynamicComposite();
>             num.addComponent(BigInteger.valueOf(i), BigIntegerSerializer.get());
>             cf.setInteger(num, i);
>         }
>         template.update(cf);
>         // end part
>         HColumn<DynamicComposite, String> res = template.querySingleColumn(26, dc, StringSerializer.get());
>         if (res == null) {
>             System.out.println("[FAIL] Row not found");
>         } else {
>             System.out.println("[SUCCESS] Returned name " + res.getName().get(0).toString() + " - with value: " + res.getValue());
>         }
>     }
> The code acts three tasks: configure keyspace an CF, insert the data and try to retrieve it. After running the code the data are visible (by list for example) but not reachable directly. Restarting Cassandra the row is again reachable. 
> Furthermore, after running that code, if I run on the cassandra-cli 
> set frame[int(26)]['s@step']=utf8(test);
> with a "list frame[int(26)]'
> RowKey: 0000001a
> => (column=s@step, value=test value, timestamp=1343499335791000)
> => (column=i@0, value=00000000, timestamp=1343499335816000)
> => (column=i@1, value=00000001, timestamp=1343499335816000)
> => (column=i@2, value=00000002, timestamp=1343499335816000)
> => (column=i@3, value=00000003, timestamp=1343499335816000)
> => (column=s@step, value=test, timestamp=1343499384630000)
> I found 2 column with the apparently the same column name. 
> How is it possible?
> Best regards,
> Cesare

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira