Package org.apache.cassandra.db.view
Class View
java.lang.Object
org.apache.cassandra.db.view.View
A View copies data from a base table into a view table which can be queried independently from the
base. Every update which targets the base table must be fed through the
ViewManager to ensure
that if a view needs to be updated, the updates are properly created and fed into the view.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbuild()booleanWhen views contains a primary key column that is not part of the base table primary key, we use that column liveness info as the view PK, to ensure that whenever that column is not live in the base, the row is not live in the view.static Iterable<ViewMetadata>static TableMetadataReffindBaseTable(String keyspace, String viewName) getBaseColumn(ColumnMetadata viewColumn) The base column corresponding to the provided view column.getViewColumn(ColumnMetadata baseColumn) The view column corresponding to the provided base column.booleanbooleanmatchesViewFilter(DecoratedKey partitionKey, Row baseRow, long nowInSec) Whether a given base row matches the view filter (and thus if is should have a corresponding entry).booleanmayBeAffectedBy(DecoratedKey partitionKey, Row update) Whether the view might be affected by the provided update.voidupdateDefinition(ViewMetadata definition) This updates the columns stored which are dependent on the base TableMetadata.
-
Field Details
-
USAGE_WARNING
- See Also:
-
name
-
baseNonPKColumnsInViewPK
-
-
Constructor Details
-
View
-
-
Method Details
-
getDefinition
-
updateDefinition
This updates the columns stored which are dependent on the base TableMetadata. -
getViewColumn
The view column corresponding to the provided base column. This can returnnullif the column is denormalized in the view. -
getBaseColumn
The base column corresponding to the provided view column. This should never returnnullsince a view can't have its "own" columns. -
mayBeAffectedBy
Whether the view might be affected by the provided update.Note that having this method return
trueis not an absolute guarantee that the view will be updated, just that it most likely will, but afalsereturn guarantees it won't be affected).- Parameters:
partitionKey- the partition key that is updated.update- the update being applied.- Returns:
falseif we can guarantee that insertingupdatefor keypartitionKeywon't affect the view in any way,trueotherwise.
-
matchesViewFilter
Whether a given base row matches the view filter (and thus if is should have a corresponding entry).Note that this differs from
mayBeAffectedBy(org.apache.cassandra.db.DecoratedKey, org.apache.cassandra.db.rows.Row)in that the provide row must be the current state of the base row, not just some updates to it. This method also has no false positive: a base row either do or don't match the view filter.- Parameters:
partitionKey- the partition key that is updated.baseRow- the current state of a particular base row.nowInSec- the current time in seconds (to decide what is live and what isn't).- Returns:
trueifbaseRowmatches the view filters,falseotherwise.
-
build
public void build() -
findBaseTable
-
findAll
-
hasSamePrimaryKeyColumnsAsBaseTable
public boolean hasSamePrimaryKeyColumnsAsBaseTable() -
enforceStrictLiveness
public boolean enforceStrictLiveness()When views contains a primary key column that is not part of the base table primary key, we use that column liveness info as the view PK, to ensure that whenever that column is not live in the base, the row is not live in the view. This is done to prevent cells other than the view PK from making the view row alive when the view PK column is not live in the base. So in this case we tie the row liveness, to the primary key liveness. See CASSANDRA-11500 for context.
-