public class View
extends java.lang.Object
ViewManager
to ensure
that if a view needs to be updated, the updates are properly created and fed into the view.Modifier and Type | Field and Description |
---|---|
java.util.List<ColumnMetadata> |
baseNonPKColumnsInViewPK |
java.lang.String |
name |
static java.lang.String |
USAGE_WARNING |
Constructor and Description |
---|
View(ViewMetadata definition,
ColumnFamilyStore baseCfs) |
Modifier and Type | Method and Description |
---|---|
void |
build() |
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.
|
static java.lang.Iterable<ViewMetadata> |
findAll(java.lang.String keyspace,
java.lang.String baseTable) |
static TableMetadataRef |
findBaseTable(java.lang.String keyspace,
java.lang.String viewName) |
ColumnMetadata |
getBaseColumn(ColumnMetadata viewColumn)
The base column corresponding to the provided view column.
|
ViewMetadata |
getDefinition() |
ColumnMetadata |
getViewColumn(ColumnMetadata baseColumn)
The view column corresponding to the provided base column.
|
boolean |
hasSamePrimaryKeyColumnsAsBaseTable() |
boolean |
matchesViewFilter(DecoratedKey partitionKey,
Row baseRow,
int nowInSec)
Whether a given base row matches the view filter (and thus if is should have a corresponding entry).
|
boolean |
mayBeAffectedBy(DecoratedKey partitionKey,
Row update)
Whether the view might be affected by the provided update.
|
void |
updateDefinition(ViewMetadata definition)
This updates the columns stored which are dependent on the base TableMetadata.
|
public static final java.lang.String USAGE_WARNING
public final java.lang.String name
public volatile java.util.List<ColumnMetadata> baseNonPKColumnsInViewPK
public View(ViewMetadata definition, ColumnFamilyStore baseCfs)
public ViewMetadata getDefinition()
public void updateDefinition(ViewMetadata definition)
public ColumnMetadata getViewColumn(ColumnMetadata baseColumn)
null
if the column is denormalized in the view.public ColumnMetadata getBaseColumn(ColumnMetadata viewColumn)
null
since a view can't have its "own" columns.public boolean mayBeAffectedBy(DecoratedKey partitionKey, Row update)
Note that having this method return true
is not an absolute guarantee that the view will be
updated, just that it most likely will, but a false
return guarantees it won't be affected).
partitionKey
- the partition key that is updated.update
- the update being applied.false
if we can guarantee that inserting update
for key partitionKey
won't affect the view in any way, true
otherwise.public boolean matchesViewFilter(DecoratedKey partitionKey, Row baseRow, int nowInSec)
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.
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).true
if baseRow
matches the view filters, false
otherwise.public void build()
@Nullable public static TableMetadataRef findBaseTable(java.lang.String keyspace, java.lang.String viewName)
public static java.lang.Iterable<ViewMetadata> findAll(java.lang.String keyspace, java.lang.String baseTable)
public boolean hasSamePrimaryKeyColumnsAsBaseTable()
public boolean enforceStrictLiveness()
Copyright © 2009-2021 The Apache Software Foundation