Package io.delta.kernel.internal.actions
Class Protocol
Object
io.delta.kernel.internal.actions.Protocol
- All Implemented Interfaces:
Serializable
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanUpgradeTo(Protocol to) Determine whether this protocol can be safely upgraded to a new protocol `to`.Protocol denormalization is the process of converting a legacy protocol to the equivalent table features protocol.Helper method that applies both denormalization and normalization.booleanstatic ProtocolfromColumnVector(ColumnVector vector, int rowId) static ProtocolHelper method to get the Protocol from the row representation.Get the set of features that are explicitly supported by the protocol.Get the set of features that are both implicitly and explicitly supported by the protocol.Get the set of reader writer features that are both implicitly and explicitly supported by the protocol.Get the set of features that are implicitly supported by the protocol.intintinthashCode()Merge this protocol with multiple `protocols` to have the highest reader and writer versions plus all explicitly and implicitly supported features.Protocol normalization is the process of converting a table features protocol to the weakest possible form.booleansupportsFeature(TableFeature feature) Check if the protocol supports the given table featurebooleanbooleantoRow()Encode as aRowobject with the schemaFULL_SCHEMA.toString()withFeature(TableFeature feature) Get a new Protocol object that has `feature` supported.withFeatures(Iterable<TableFeature> newFeatures) Create a newProtocolobject with the givenTableFeaturesupported.
-
Field Details
-
FULL_SCHEMA
-
-
Constructor Details
-
Protocol
public Protocol(int minReaderVersion, int minWriterVersion) -
Protocol
-
-
Method Details
-
fromRow
Helper method to get the Protocol from the row representation.- Parameters:
row- Row representation of the Protocol.- Returns:
- the Protocol object
-
fromColumnVector
-
getMinReaderVersion
public int getMinReaderVersion()- Returns:
- The minimum reader version required for this protocol
-
getMinWriterVersion
public int getMinWriterVersion()- Returns:
- The minimum writer version required for this protocol
-
getReaderFeatures
- Returns:
- The set of explicitly specified reader features for this protocol. Will be empty if this protocol does not support reader features.
-
getWriterFeatures
- Returns:
- The set of explicitly specified writer features for this protocol. Will be empty if this protocol does not support writer features.
-
getReaderAndWriterFeatures
- Returns:
- The combined set of all reader and writer features for this protocol. Will be empty if this protocol does not support reader or writer features.
-
supportsReaderFeatures
public boolean supportsReaderFeatures()- Returns:
- Whether this protocol supports explicitly specifying reader features, which occurs when the minReaderVersion is greater than or equal to 3.
-
supportsWriterFeatures
public boolean supportsWriterFeatures()- Returns:
- Whether this protocol supports explicitly specifying writer features, which occurs when the minWriterVersion is greater than or equal to 7.
-
toString
-
equals
-
hashCode
public int hashCode() -
toRow
Encode as aRowobject with the schemaFULL_SCHEMA. Write any empty `readerFeatures` and `writerFeatures` as null.- Returns:
Rowobject with the schemaFULL_SCHEMA
-
getImplicitlySupportedFeatures
Get the set of features that are implicitly supported by the protocol. Features are implicitly supported if the reader and/or writer version is less than the versions that supports the explicit features specified in `readerFeatures` and `writerFeatures` sets. Examples:- (minRV = 1, minWV = 7, readerFeatures=[], writerFeatures=[domainMetadata]) results in []
- (minRV = 1, minWV = 3) results in [appendOnly, invariants, checkConstraints]
- (minRV = 3, minWV = 7, readerFeatures=[v2Checkpoint], writerFeatures=[v2Checkpoint]) results in []
- (minRV = 2, minWV = 6) results in [appendOnly, invariants, checkConstraints, changeDataFeed, generatedColumns, columnMapping, identityColumns]
-
getExplicitlySupportedFeatures
Get the set of features that are explicitly supported by the protocol. Features are explicitly supported if they are present in the `readerFeatures` and/or `writerFeatures` sets. Examples:- (minRV = 1, minWV = 7, writerFeatures=[appendOnly, invariants, checkConstraints]) results in [appendOnly, invariants, checkConstraints]
- (minRV = 3, minWV = 7, readerFeatures = [columnMapping], writerFeatures=[columnMapping, invariants]) results in [columnMapping, invariants]
- (minRV = 1, minWV = 2, readerFeatures = [], writerFeatures=[]) results in []
- Throws:
UnsupportedTableFeatureException- if any table features in the protocol's list of readerFeatures or writerFeatures are unsupported by Kernel
-
getImplicitlyAndExplicitlySupportedFeatures
Get the set of features that are both implicitly and explicitly supported by the protocol. Usually, the protocol has either implicit or explicit features, but not both. This API provides a way to get all enabled features.- Throws:
UnsupportedTableFeatureException- if any table features in the protocol's list of readerFeatures or writerFeatures are unsupported by Kernel
-
getImplicitlyAndExplicitlySupportedReaderWriterFeatures
Get the set of reader writer features that are both implicitly and explicitly supported by the protocol. Usually, the protocol has either implicit or explicit features, but not both. This API provides a way to get all enabled reader writer features. It doesn't return any writer only features. -
withFeatures
Create a newProtocolobject with the givenTableFeaturesupported. -
withFeature
Get a new Protocol object that has `feature` supported. Writer-only features will be added to `writerFeatures` field, and reader-writer features will be added to `readerFeatures` and `writerFeatures` fields.If `feature` is already implicitly supported in the current protocol's legacy reader or writer protocol version, the new protocol will not modify the original protocol version, i.e., the feature will not be explicitly added to the protocol's `readerFeatures` or `writerFeatures`. This is to avoid unnecessary protocol upgrade for feature that it already supports.
Examples:
- current protocol (2, 5) and new feature to add 'invariants` result in (2, 5) as this protocol already supports 'invariants' implicitly.
- current protocol is (1, 7, writerFeature='rowTracking,domainMetadata' and the new feature to add is 'appendOnly' results in (1, 7, writerFeature='rowTracking,domainMetadata,appendOnly')
- current protocol is (1, 7, writerFeature='rowTracking,domainMetadata' and the new feature to add is 'columnMapping' results in throwing UnsupportedOperationException as 'columnMapping' requires higher reader version (2) than the current protocol's reader version (1).
-
canUpgradeTo
Determine whether this protocol can be safely upgraded to a new protocol `to`. This means all features supported by this protocol are supported by `to`.Examples regarding feature status:
- `[appendOnly]` to `[appendOnly]` results in allowed.
- `[appendOnly, changeDataFeed]` to `[appendOnly]` results in not allowed.
-
normalized
Protocol normalization is the process of converting a table features protocol to the weakest possible form. This primarily refers to converting a table features protocol to a legacy protocol. A Table Features protocol can be represented with the legacy representation only when the features set of the former exactly matches a legacy protocol.Normalization can also decrease the reader version of a table features protocol when it is higher than necessary.
For example:
- (1, 7, AppendOnly, Invariants, CheckConstraints) results in (1, 3)
- (3, 7, RowTracking) results in (1, 7, RowTracking)
-
denormalized
Protocol denormalization is the process of converting a legacy protocol to the equivalent table features protocol. This is the inverse of protocol normalization. It can be used to allow operations on legacy protocols that yield results which cannot be represented anymore by a legacy protocol. For example- (1, 3) results in (1, 7, readerFeatures=[], writerFeatures=[appendOnly, invariants, checkConstraints])
- (2, 5) results in (2, 7, readerFeatures=[], writerFeatures=[appendOnly, invariants, checkConstraints, changeDataFeed, generatedColumns, columnMapping])
-
denormalizedNormalized
Helper method that applies both denormalization and normalization. This can be used to normalize invalid legacy protocols such as (2, 3), (1, 5). A legacy protocol is invalid when the version numbers are higher than required to support the implied feature set. -
merge
Merge this protocol with multiple `protocols` to have the highest reader and writer versions plus all explicitly and implicitly supported features. -
supportsFeature
Check if the protocol supports the given table feature
-