private Map < String , Object > buildThriftCounterSuperColumn ( String tableName , String superColumnName , EmbeddableType superColumn , Object counterSuperColumnObject ) { Map < String , Object > thriftCounterSuperColumns = new HashMap < String , Object > ( ) ; Iterator < Attribute > iter = superColumn . getAttributes ( ) . iterator ( ) ; List < CounterColumn > thriftColumns = new ArrayList < CounterColumn > ( ) ; while ( iter . hasNext ( ) ) { Attribute column = iter . next ( ) ; Field field = ( Field ) column . getJavaMember ( ) ; String name = ( ( AbstractAttribute ) column ) . getJPAColumnName ( ) ; String value = null ; try { value = PropertyAccessorHelper . getString ( counterSuperColumnObject , field ) ; } catch ( PropertyAccessException exp ) { // This is an entity column to be persisted in a super column // family. It will be stored as a super column that would // have just one column with the same name if ( log . isInfoEnabled ( ) ) { log . info ( exp . getMessage ( ) + ". Possible case of entity column in a super column family. Will be treated as a super column." ) ; } value = counterSuperColumnObject . toString ( ) ; } if ( null != value ) { try { CounterColumn thriftColumn = new CounterColumn ( ) ; thriftColumn . setName ( PropertyAccessorFactory . STRING . toBytes ( name ) ) ; thriftColumn . setValue ( Long . parseLong ( value ) ) ; thriftColumns . add ( thriftColumn ) ; tableName = ( ( AbstractAttribute ) column ) . getTableName ( ) != null ? ( ( AbstractAttribute ) column ) . getTableName ( ) : tableName ; CounterSuperColumn thriftSuperColumn = ( CounterSuperColumn ) thriftCounterSuperColumns . get ( tableName ) ; if ( thriftSuperColumn == null ) { thriftSuperColumn = new CounterSuperColumn ( ) ; thriftSuperColumn . setName ( PropertyAccessorFactory . STRING . toBytes ( superColumnName ) ) ; thriftCounterSuperColumns . put ( tableName , thriftSuperColumn ) ; } thriftSuperColumn . addToColumns ( thriftColumn ) ; } catch ( NumberFormatException nfe ) { log . error ( "For counter column arguments should be numeric type, Caused by: ." , nfe ) ; throw new KunderaException ( nfe ) ; } } } return thriftCounterSuperColumns ; }
Builds the thrift counter super column .