C
- type of the row key in the main column family. Such row key will
be the column name in the secondary index column.D
- type of the denormalized data to set as the value in the indexed
columns.public class AllRowsSecondaryIndex<C extends Serializable & Comparable<C>,D> extends Object implements ColumnFamilyHandler
All Rows Secondary Index Column Family:
column_family_name { "rows": { id_1: <data provided by the denormalizer>, ... id_n: <data provided by the denormalizer>, } }See
IndexEntryHandler
for a recipe to update secondary indexes.Constructor and Description |
---|
AllRowsSecondaryIndex(String columnFamilyName,
CassDataTypes indexedColumnNameDataType,
com.netflix.astyanax.Serializer<C> indexedColumnNameSerializer,
Denormalizer<C,D> denormalizer)
Creates a custom secondary index.
|
Modifier and Type | Method and Description |
---|---|
void |
clear(DataStoreContext context)
Updates the index after deleting all rows from the main column family.
|
long |
count(DataStoreContext context)
Counts all the rows in the main column family or the number of columns in the index column
family.
|
void |
delete(C indexEntry,
DataStoreContext context)
Updates the index after a row has been deleted from the main column family.
|
Collection<ColumnFamilyDefinition<?,?>> |
getColumnFamilyDefinitions()
Gets the definition of all column families this handler reads from and writes into.
|
void |
insert(C indexEntry,
D denormalizedData,
DataStoreContext context)
Updates the index after a row has been inserted into the main column family.
|
List<Column<C,D>> |
read(DataStoreContext context)
Reads the index entries.
|
List<Column<C,D>> |
read(List<C> indexEntries,
DataStoreContext context)
Reads the index entries.
|
public AllRowsSecondaryIndex(String columnFamilyName, CassDataTypes indexedColumnNameDataType, com.netflix.astyanax.Serializer<C> indexedColumnNameSerializer, Denormalizer<C,D> denormalizer)
columnFamilyName
- name for the column family this index will keep data into.indexedColumnNameDataType
- type of the secondary index column name.indexedColumnNameSerializer
- secondary index column name serializer.denormalizer
- strategy to handle denormalized data included as part of the indexed
columns. null
if no denormalization will be used.public Collection<ColumnFamilyDefinition<?,?>> getColumnFamilyDefinitions()
ColumnFamilyHandler
getColumnFamilyDefinitions
in interface ColumnFamilyHandler
public void insert(C indexEntry, D denormalizedData, DataStoreContext context)
indexEntry
- key of the row inserted in the main column family.denormalizedData
- denormalized data to include as part of the indexed columns.
null
if no denormalization is used. Note: A Denormalizer
must be
set at construction time to handle denormalizedData
if it is not null.context
- data store context.public void delete(C indexEntry, DataStoreContext context)
indexEntry
- key of the row removed from the main column family.context
- data store context.public void clear(DataStoreContext context)
context
- data store context.public long count(DataStoreContext context)
context
- data store context.public List<Column<C,D>> read(DataStoreContext context)
Note that it is simpler to read the entire main column family. This method just guarantees sorting by row key but then the rows will need to be loaded from the main column family.
context
- data store context.public List<Column<C,D>> read(List<C> indexEntries, DataStoreContext context)
An index is normally used to get rows (from the main column family) that match a specific
indexed value, not to load entries known to match the indexed value - like in this method.
This method has been defined to allow secondary indexes to be used by a
SecondaryIndexIntegrator.SecondaryIndexReader
.
indexEntries
- index entries to read.context
- data store context.indexEntries
that doesn't exist is not included in the result.Copyright © 2016. All Rights Reserved.