@ Override public Object [ ] findIdsByColumn ( String schemaName , String tableName , String pKeyName , String columnName , Object columnValue , Class entityClazz ) { List < Object > rowKeys = new ArrayList < Object > ( ) ; if ( getCqlVersion ( ) . equalsIgnoreCase ( CassandraConstants . CQL_VERSION_3_0 ) ) { rowKeys = findIdsByColumnUsingCql ( schemaName , tableName , pKeyName , columnName , columnValue , entityClazz ) ; } else { EntityMetadata metadata = KunderaMetadataManager . getEntityMetadata ( kunderaMetadata , entityClazz ) ; SlicePredicate slicePredicate = new SlicePredicate ( ) ; slicePredicate . setSlice_range ( new SliceRange ( ByteBufferUtil . EMPTY_BYTE_BUFFER , ByteBufferUtil . EMPTY_BYTE_BUFFER , false , Integer . MAX_VALUE ) ) ; String childIdStr = PropertyAccessorHelper . getString ( columnValue ) ; IndexExpression ie = new IndexExpression ( UTF8Type . instance . decompose ( columnName + Constants . JOIN_COLUMN_NAME_SEPARATOR + childIdStr ) , IndexOperator . EQ , UTF8Type . instance . decompose ( childIdStr ) ) ; List < IndexExpression > expressions = new ArrayList < IndexExpression > ( ) ; expressions . add ( ie ) ; IndexClause ix = new IndexClause ( ) ; ix . setStart_key ( ByteBufferUtil . EMPTY_BYTE_BUFFER ) ; ix . setCount ( Integer . MAX_VALUE ) ; ix . setExpressions ( expressions ) ; ColumnParent columnParent = new ColumnParent ( tableName ) ; Connection conn = null ; try { conn = getConnection ( ) ; List < KeySlice > keySlices = conn . getClient ( ) . get_indexed_slices ( columnParent , ix , slicePredicate , getConsistencyLevel ( ) ) ; rowKeys = ThriftDataResultHelper . getRowKeys ( keySlices , metadata ) ; } catch ( InvalidRequestException e ) { log . error ( "Error while fetching key slices of column family {} for column name {} , Caused by: ." , tableName , columnName , e ) ; throw new KunderaException ( e ) ; } catch ( UnavailableException e ) { log . error ( "Error while fetching key slices of column family {} for column name {} , Caused by: ." , tableName , columnName , e ) ; throw new KunderaException ( e ) ; } catch ( TimedOutException e ) { log . error ( "Error while fetching key slices of column family {} for column name {} , Caused by: ." , tableName , columnName , e ) ; throw new KunderaException ( e ) ; } catch ( TException e ) { log . error ( "Error while fetching key slices of column family {} for column name {} , Caused by: ." , tableName , columnName , e ) ; throw new KunderaException ( e ) ; } finally { releaseConnection ( conn ) ; } } if ( rowKeys != null && ! rowKeys . isEmpty ( ) ) { return rowKeys . toArray ( new Object [ 0 ] ) ; } if ( log . isInfoEnabled ( ) ) { log . info ( "No record found!, returning null." ) ; } return null ; }
Retrieves IDs for a given column .