Package com.illumon.iris.db.v2
Class ModifiedColumnSet
java.lang.Object
com.illumon.iris.db.v2.ModifiedColumnSet
public class ModifiedColumnSet extends Object
Data structure to represent a subset of columns, used for propagating modifications via
ShiftAwareListener.Update
instances.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ModifiedColumnSet.Transformer
A helper utility that simplifies propagating modified columns to a child table. -
Field Summary
Fields Modifier and Type Field Description static ModifiedColumnSet
ALL
A static 'special' ModifiedColumnSet that pretends all columns are dirty.static ModifiedColumnSet
EMPTY
A static 'special' ModifiedColumnSet that pretends no columns are dirty. -
Constructor Summary
Constructors Constructor Description ModifiedColumnSet(ModifiedColumnSet other)
Create a new ModifiedColumnSet that shares all immutable state with the provided MCS.ModifiedColumnSet(Map<String,ColumnSource> columns)
Create an empty ModifiedColumnSet from the provided Column Source Map. -
Method Summary
Modifier and Type Method Description void
clear()
Reset the current dirty column state.void
clearAll(ModifiedColumnSet columnSet)
Marks all columns in the provided column set in this set as clean.void
clearAll(String... columnNames)
Turns off all bits for these columns.boolean
containsAll(ModifiedColumnSet columnSet)
Check whether or not all columns are currently marked as dirty.boolean
containsAny(ModifiedColumnSet columnSet)
Check whether or not any columns are currently marked as dirty.ModifiedColumnSet
copy()
Create an exact copy of this ModifiedColumnSet.boolean
empty()
boolean
equals(Object other)
BitSet
extractAsBitSet()
boolean
isCompatibleWith(ModifiedColumnSet columnSet)
ModifiedColumnSet.Transformer
newIdentityTransformer(Map<String,ColumnSource> newColumns)
Create a transformer that uses an identity mapping from one ColumnSourceMap to another.ModifiedColumnSet.Transformer
newTransformer(String[] columnNames, ModifiedColumnSet[] columnSets)
Create a transformer that is compatible with the class of ModifiedColumnSets that share a ColumnSourceMap.boolean
nonempty()
int
numColumns()
boolean
requiresTransformer(ModifiedColumnSet columnSet)
This method is used to determine whether or not a dependent requires a transformer to propagate dirty columns from its parent.void
setAll(ModifiedColumnSet columnSet)
Marks all columns in the provided column set in this set as dirty.void
setAll(String... columnNames)
Turns on all bits for these columns.void
setAllDirty()
Sets all columns dirty.void
setColumnWithIndex(int columnIndex)
Marks specifically the column with the given index as dirty.int
size()
String
toDebugString()
String
toString()
String
toString(int maxColumns)
-
Field Details
-
Constructor Details
-
ModifiedColumnSet
Create an empty ModifiedColumnSet from the provided Column Source Map. Note: prefer to use the copy constructor on future objects that share this CSM to minimize duplicating state.- Parameters:
columns
- The column source map this ModifiedColumnSet will use.
-
ModifiedColumnSet
Create a new ModifiedColumnSet that shares all immutable state with the provided MCS. The dirty set will initially be empty.- Parameters:
other
- The ModifiedColumnSet to borrow immutable state from.
-
-
Method Details
-
extractAsBitSet
-
newTransformer
public ModifiedColumnSet.Transformer newTransformer(String[] columnNames, ModifiedColumnSet[] columnSets)Create a transformer that is compatible with the class of ModifiedColumnSets that share a ColumnSourceMap.- Parameters:
columnNames
- input columns to check for dirtinesscolumnSets
- output columns to mark dirty when input column is dirty- Returns:
- a new Transformer instance
-
newIdentityTransformer
Create a transformer that uses an identity mapping from one ColumnSourceMap to another. The two CSM's must have equivalent column names and column ordering.- Parameters:
newColumns
- the column source map for result table- Returns:
- a simple Transformer that makes a cheap, but CSM compatible copy
-
isCompatibleWith
- Returns:
- whether or not this modified column set is compatible with the provided set
-
requiresTransformer
This method is used to determine whether or not a dependent requires a transformer to propagate dirty columns from its parent. If no transformer is required then it is acceptable to reuse any column set provided by the parent. Note this is intended to be determined during initialization and never during an update cycle. It is illegal to use the specialized ModifiedColumnSet.EMPTY / ModifiedColumnSet.ALL as their innards do not represent any table.- Parameters:
columnSet
- the column set for the dependent table- Returns:
- whether or not this modified column set must use a Transformer to propagate modified columns
-
copy
Create an exact copy of this ModifiedColumnSet.- Returns:
- a copy with identical state including dirty bits
-
clear
public void clear()Reset the current dirty column state. -
setAllDirty
public void setAllDirty()Sets all columns dirty. -
size
public int size()- Returns:
- the number of dirty columns
-
empty
public boolean empty()- Returns:
- whether or not this set is empty
-
nonempty
public boolean nonempty()- Returns:
- whether or not this set is non-empty
-
numColumns
public int numColumns()- Returns:
- the number of columns in this set
- Throws:
UnsupportedOperationException
- onALL
andEMPTY
-
setAll
Turns on all bits for these columns. Use this method to prepare pre-computed ModifiedColumnSets.- Parameters:
columnNames
- the columns which need to be marked dirty
-
setAll
Marks all columns in the provided column set in this set as dirty.- Parameters:
columnSet
- the set of columns to mark dirty
-
setColumnWithIndex
public void setColumnWithIndex(int columnIndex)Marks specifically the column with the given index as dirty.- Parameters:
columnIndex
- column index to mark dirty
-
clearAll
Turns off all bits for these columns. Use this method to prepare pre-computed ModifiedColumnSets.- Parameters:
columnNames
- the columns which need to be marked clean
-
clearAll
Marks all columns in the provided column set in this set as clean.- Parameters:
columnSet
- the set of columns to mark clean
-
containsAny
Check whether or not any columns are currently marked as dirty.- Parameters:
columnSet
- the columns to check- Returns:
- true iff any column is dirty
-
containsAll
Check whether or not all columns are currently marked as dirty.- Parameters:
columnSet
- the columns to check- Returns:
- true iff all columns match dirtiness
-
equals
-
toDebugString
-
toString
-
toString
-