Hello,
I am having an issue with custom secondary index and retrieving column for
the clustering columns from the basecomparator.
*Env: *cassandra:2.0.9.
*Intent: *I am using custom secondary index. Created the column family as
below:
*Create CF:* CREATE TABLE test1_cf3 ( col1 text, col2 text, col3 text, col4
text, col5 text, custom_search text, PRIMARY KEY ((col1),col2,col3) ) WITH
comment='Create table for custom row index';
*Create Custom Row Index:* CREATE CUSTOM INDEX
test1_ks_test1_cf3_esquery_search_index ON test1_cf3 (esquery_search) USING
'';
*Inserting Data:* INSERT INTO test1_cf3(col1,col2,col3,col4, col5) VALUES
('1','11','12','13','14');
*custom_row_indexer_class:*
public void index( final ByteBuffer rowKey, final ColumnFamily cf ) {
for (Column column: cf){
CompositeType baseComparator = (CompositeType) baseCfs.getComparator();
List<AbstractType<?>> types = baseComparator.types;
ByteBuffer[] components = baseComparator.split(column.name());
int column_name_offset = types.get(types.size() - 1)
instanceof ColumnToCollectionType ?
types.size() - 2 : types.size() - 1;
String columnName =
CFDefinition.definitionType.getString(components[column_name_offset]);
LOGGER.debug("column name: " + columnName);
}
}
*output:*
DEBUG 09:42:20,490 column name:
DEBUG 09:42:29,421 column name: col4
DEBUG 09:42:32,554 column name: col5
*Question:* As per the clustering keys below, can i get the
c_name/clustering key column names here by using some other validator or
this clustering key column_name is always going to return me back only the
data slices?
/** * Index on a CLUSTERING_KEY column definition. * * A cell indexed by
this index will have the general form: * ck_0 ... ck_n c_name : v * where
ck_i are the cluster keys, c_name the last component of the cell *
composite name (or second to last if collections are in use, but this * has
no impact) and v the cell value. * * Such a cell is always indexed by this
index (or rather, it is indexed if * n >= columnDef.componentIndex, which
will always be the case in practice) * and it will generate
(makeIndexColumnName()) an index entry whose: * - row key will be ck_i
(getIndexedValue()) where i == columnDef.componentIndex. * - cell name will
* rk ck_0 ... ck_{i-1} ck_{i+1} ck_n *
where rk is the row key of the initial cell and i ==
columnDef.componentIndex. */
Regards,
Arindam Bose
+1 469-231-3862