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<ColumnDefinition> |
baseNonPKColumnsInViewPK |
java.lang.String |
name |
Constructor and Description |
---|
View(ViewDefinition definition,
ColumnFamilyStore baseCfs) |
Modifier and Type | Method and Description |
---|---|
void |
build() |
static java.lang.String |
buildSelectStatement(java.lang.String cfName,
java.util.Collection<ColumnDefinition> includedColumns,
java.lang.String whereClause)
Builds the string text for a materialized view's SELECT statement.
|
static java.lang.Iterable<ViewDefinition> |
findAll(java.lang.String keyspace,
java.lang.String baseTable) |
static CFMetaData |
findBaseTable(java.lang.String keyspace,
java.lang.String viewName) |
ColumnDefinition |
getBaseColumn(ColumnDefinition viewColumn)
The base column corresponding to the provided view column.
|
ViewDefinition |
getDefinition() |
ReadQuery |
getReadQuery()
Returns the ReadQuery used to filter this view.
|
SelectStatement |
getSelectStatement()
Returns the SelectStatement used to populate and filter this view.
|
ColumnDefinition |
getViewColumn(ColumnDefinition baseColumn)
The view column corresponding to the provided base column.
|
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.
|
static java.lang.String |
relationsToWhereClause(java.util.List<Relation> whereClause) |
void |
updateDefinition(ViewDefinition definition)
This updates the columns stored which are dependent on the base CFMetaData.
|
public final java.lang.String name
public volatile java.util.List<ColumnDefinition> baseNonPKColumnsInViewPK
public View(ViewDefinition definition, ColumnFamilyStore baseCfs)
public ViewDefinition getDefinition()
public void updateDefinition(ViewDefinition definition)
public ColumnDefinition getViewColumn(ColumnDefinition baseColumn)
null
if the column is denormalized in the view.public ColumnDefinition getBaseColumn(ColumnDefinition 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 SelectStatement getSelectStatement()
public ReadQuery getReadQuery()
public void build()
@Nullable public static CFMetaData findBaseTable(java.lang.String keyspace, java.lang.String viewName)
public static java.lang.Iterable<ViewDefinition> findAll(java.lang.String keyspace, java.lang.String baseTable)
public static java.lang.String buildSelectStatement(java.lang.String cfName, java.util.Collection<ColumnDefinition> includedColumns, java.lang.String whereClause)
public static java.lang.String relationsToWhereClause(java.util.List<Relation> whereClause)
Copyright © 2016 The Apache Software Foundation