Search code examples
astyanax

astyanax how to create a columnfamily with compositecolumn


I need to create 3 column families with composite name in every column of these types

  1. Col Family 1 needs UTF8 and byte[]
  2. Col Family 2 needs BigDecimal and byte[]
  3. Col Family 3 needs BigInteger and byte[]

How do I create the column family in astyanax. I see a setComparatorType(String) but I want the comparator to be the UTF8, BigDecimal, or BigInteger (ie. the first part of the composite key)...I do not care what order the byte[] are in so that can be random...don't really care.

also, do I need to set anything else on the ColumnFamilyDefinition object of astyanax at all to create this column family?

Also, I see the example on putting values with the self-created annotated composite type. I am assumeing I just call the colMutation.putColumn(compositeTypeInst, value, theTime) to put it into cassandra?

thanks, Dean


Solution

  • ah, actually that did work, the complex exception was from persisting the save of the composite. The create of the column family worked great using

        ColumnFamilyDefinition def = cluster.makeColumnFamilyDefinition()
                .setName(colFamily)
                .setKeyspace(keyspace.getKeyspaceName())
                            .setComparatorType("CompositeType(UTF8Type, BytesType)");