incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Cherkasov <michael.cherka...@gmail.com>
Subject Composite column/key creation via Hector
Date Wed, 11 Jul 2012 21:04:08 GMT
Hi all,

What is the right way to create CF with dynamic composite column and
composite key?

Now I use code like this:

 private static final String DEFAULT_DYNAMIC_COMPOSITE_ALIAES =

"(a=>AsciiType,b=>BytesType,i=>IntegerType,x=>LexicalUUIDType,l=>LongType,t=>TimeUUIDType,s=>UTF8Type,u=>UUIDType,A=>AsciiType(reversed=true),B=>BytesType(reversed=true),I=>IntegerType(reversed=true),X=>LexicalUUIDType(reversed=true),L=>LongType(reversed=true),T=>TimeUUIDType(reversed=true),S=>UTF8Type(reversed=true),U=>UUIDType(reversed=true))";

for composite columns:
 BasicColumnFamilyDefinition columnFamilyDefinition = new
BasicColumnFamilyDefinition();
        columnFamilyDefinition.setComparatorType(
ComparatorType.DYNAMICCOMPOSITETYPE );
        columnFamilyDefinition.setComparatorTypeAlias(
DEFAULT_DYNAMIC_COMPOSITE_ALIAES );
        columnFamilyDefinition.setKeyspaceName( keyspaceName );
        columnFamilyDefinition.setName( "TestCase" );
        columnFamilyDefinition.setColumnType( ColumnType.STANDARD );
        ColumnFamilyDefinition cfDefStandard = new ThriftCfDef(
columnFamilyDefinition );
        cfDefStandard.setKeyValidationClass(
ComparatorType.UTF8TYPE.getClassName() );
        cfDefStandard.setDefaultValidationClass(
ComparatorType.UTF8TYPE.getClassName() );

for keys:
columnFamilyDefinition = new BasicColumnFamilyDefinition();
        columnFamilyDefinition.setComparatorType( ComparatorType.UTF8TYPE );
        columnFamilyDefinition.setKeyspaceName( keyspaceName );
        columnFamilyDefinition.setName( "Parameter" );
        columnFamilyDefinition.setColumnType( ColumnType.STANDARD );
        cfDefStandard = new ThriftCfDef( columnFamilyDefinition );
        cfDefStandard.setKeyValidationClass(
ComparatorType.DYNAMICCOMPOSITETYPE.getClassName() +
DEFAULT_DYNAMIC_COMPOSITE_ALIAES );
        cfDefStandard.setDefaultValidationClass(
ComparatorType.UTF8TYPE.getClassName() );

Does it correct code? Do I really need
so terrible DEFAULT_DYNAMIC_COMPOSITE_ALIAES ?

Mime
View raw message