incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aaron morton <aa...@thelastpickle.com>
Subject Re: Composite column/key creation via Hector
Date Thu, 12 Jul 2012 22:25:44 GMT
You may have better luck on the Hector Mailing list… https://groups.google.com/forum/?fromgroups#!forum/hector-users


Here is something I found in the docs though http://hector-client.github.com/hector/build/html/content/composite_with_templates.html

Cheers

-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 12/07/2012, at 9:04 AM, Michael Cherkasov wrote:

> 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