K - type of the value (or composite values) of the indexed column
(or columns) in the main column family. This value (or composite
value) will become the row key in the secondary index column.C - type of the column name in the secondary index column family
(row key in the main column family or composite value when sorting
information is included).D - type of the denormalized data to set as the value in the indexed
columns.public class GenericCustomSecondaryIndex<K extends Serializable,C extends Serializable & Comparable<C>,D> extends Object implements CustomSecondaryIndex<K,C,D>
CustomSecondaryIndex| Constructor and Description |
|---|
GenericCustomSecondaryIndex(ColumnFamilyDefinition<K,C> columnFamilyDefinition,
Denormalizer<C,D> denormalizer)
Creates a
CustomSecondaryIndex. |
| Modifier and Type | Method and Description |
|---|---|
void |
clear(DataStoreContext context)
Updates the index after deleting all rows from the main column family.
|
long |
count(K indexKey,
DataStoreContext context)
Counts the number of columns in the index.
|
void |
delete(C indexEntry,
K indexKey,
DataStoreContext context)
Updates the index after a row has been deleted from the main column family.
|
void |
delete(K indexKey,
DataStoreContext context)
Deletes a row in the secondary index column family.
|
Collection<ColumnFamilyDefinition<?,?>> |
getColumnFamilyDefinitions()
Gets the definition of all column families this handler reads from and writes into.
|
Provider<ColumnDecoder<C,?>,ColumnName<C,?>> |
getDecoderProvider()
Returns the decoder provided used to read from the secondary index column family.
|
void |
insert(C indexEntry,
D denormalizedData,
K indexKey,
DataStoreContext context)
Updates the index after a row has been inserted into the main column
family.
|
List<Column<C,D>> |
read(K indexKey,
DataStoreContext context)
Reads the index entries.
|
List<Column<C,D>> |
read(List<C> indexEntries,
K indexKey,
DataStoreContext context)
Reads the index entries.
|
public GenericCustomSecondaryIndex(ColumnFamilyDefinition<K,C> columnFamilyDefinition, Denormalizer<C,D> denormalizer)
CustomSecondaryIndex.columnFamilyDefinition - column family this index will keep data into.denormalizer - strategy to handle denormalized data included as part of the indexed columns. null if no denormalization will be used.
Note: If denormalization is used but a Denormalizer is not set then exceptions will be thrown when reading from the index.public Collection<ColumnFamilyDefinition<?,?>> getColumnFamilyDefinitions()
ColumnFamilyHandlergetColumnFamilyDefinitions in interface ColumnFamilyHandlerpublic void insert(C indexEntry, D denormalizedData, K indexKey, DataStoreContext context)
CustomSecondaryIndexinsert in interface CustomSecondaryIndex<K extends Serializable,C extends Serializable & Comparable<C>,D>indexEntry - row key in the main column family (or composite value
when sorting information is included). Such row key (or
composite value) will become the name of the column in the
secondary index.denormalizedData - denormalized data to include as part of the
indexed columns. null if no denormalization is used.indexKey - value (or composite values) of the indexed column (or
columns) in the main column family. This value (or composite
value) will become the row key in the secondary index column.context - data store context.public void delete(C indexEntry, K indexKey, DataStoreContext context)
CustomSecondaryIndexdelete in interface CustomSecondaryIndex<K extends Serializable,C extends Serializable & Comparable<C>,D>indexEntry - key of the row removed from the main column family.indexKey - value of the indexed column in the main column family.context - data store context.public void delete(K indexKey, DataStoreContext context)
CustomSecondaryIndexThis method should be the preferred way to clear a secondary index if it contains a small well-know set of rows. Truncating a column family is an expensive operation.
delete in interface CustomSecondaryIndex<K extends Serializable,C extends Serializable & Comparable<C>,D>indexKey - value of the indexed column in the main column family.context - data store context.public void clear(DataStoreContext context)
CustomSecondaryIndexclear in interface CustomSecondaryIndex<K extends Serializable,C extends Serializable & Comparable<C>,D>context - data store context.public long count(K indexKey, DataStoreContext context)
CustomSecondaryIndexcount in interface CustomSecondaryIndex<K extends Serializable,C extends Serializable & Comparable<C>,D>indexKey - value of the indexed column in the main column family
or row key in the secondary index column family.context - data store context.public List<Column<C,D>> read(K indexKey, DataStoreContext context)
CustomSecondaryIndexread in interface CustomSecondaryIndex<K extends Serializable,C extends Serializable & Comparable<C>,D>indexKey - value of the indexed column in the main column family
or row key in the secondary index column family.context - data store context.public List<Column<C,D>> read(List<C> indexEntries, K indexKey, DataStoreContext context)
CustomSecondaryIndex
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.
read in interface CustomSecondaryIndex<K extends Serializable,C extends Serializable & Comparable<C>,D>indexEntries - index entries to read.indexKey - value of the indexed column in the main column family
or row key in the secondary index column family.context - data store context.indexEntries that doesn't exist in the
index given by indexKey is not included in the result.public Provider<ColumnDecoder<C,?>,ColumnName<C,?>> getDecoderProvider()
Copyright © 2014. All Rights Reserved.