-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86b2601
commit c9e96e0
Showing
9 changed files
with
119 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
title: Auto Compaction | ||
nav: | ||
- index.md | ||
- ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# AutoCompact | ||
|
||
`AutoCompact` is a [AutoCompactBase](AutoCompactBase.md). | ||
|
||
??? note "case object" | ||
`AutoCompact` is a `case object` in Scala which means it is a class that has exactly one instance (itself). | ||
A `case object` is created lazily when it is referenced, like a `lazy val`. | ||
|
||
Learn more in [Tour of Scala](https://docs.scala-lang.org/tour/singleton-objects.html). | ||
|
||
`AutoCompact` is [registered](../OptimisticTransactionImpl.md#registerPostCommitHook) when `TransactionalWrite` is requested to [write data out](../TransactionalWrite.md#writeFiles) and there are indeed new files added and it is not [Optimize](../commands/optimize/index.md) command. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# AutoCompactBase | ||
|
||
`AutoCompactBase` is an [extension](#contract) of the [PostCommitHook](../post-commit-hooks/PostCommitHook.md) abstraction for [post-commit hooks](#implementations) that [perform auto compaction](#run). | ||
|
||
## Implementations | ||
|
||
* [AutoCompact](AutoCompact.md) | ||
|
||
## Name { #name } | ||
|
||
??? note "PostCommitHook" | ||
|
||
```scala | ||
name: String | ||
``` | ||
|
||
`name` is part of the [PostCommitHook](../post-commit-hooks/PostCommitHook.md#name) abstraction. | ||
|
||
`name` is **Auto Compact**. | ||
|
||
## Executing Post-Commit Hook { #run } | ||
|
||
??? note "PostCommitHook" | ||
|
||
```scala | ||
run( | ||
spark: SparkSession, | ||
txn: OptimisticTransactionImpl, | ||
committedVersion: Long, | ||
postCommitSnapshot: Snapshot, | ||
actions: Seq[Action]): Unit | ||
``` | ||
|
||
`run` is part of the [PostCommitHook](../post-commit-hooks/PostCommitHook.md#run) abstraction. | ||
|
||
`run` [determines the type of AutoCompact](#getAutoCompactType). | ||
|
||
`run` returns (and hence skips auto compacting) when [shouldSkipAutoCompact](#shouldSkipAutoCompact) is enabled. | ||
|
||
In the end, `run` [compactIfNecessary](#compactIfNecessary) with the following: | ||
|
||
* `delta.commit.hooks.autoOptimize` operation name | ||
* `maxDeletedRowsRatio` unspecified (`None`) | ||
|
||
### compactIfNecessary { #compactIfNecessary } | ||
|
||
```scala | ||
compactIfNecessary( | ||
spark: SparkSession, | ||
txn: OptimisticTransactionImpl, | ||
postCommitSnapshot: Snapshot, | ||
opType: String, | ||
maxDeletedRowsRatio: Option[Double]): Seq[OptimizeMetrics] | ||
``` | ||
|
||
`compactIfNecessary` [prepareAutoCompactRequest](AutoCompactUtils.md#prepareAutoCompactRequest). | ||
|
||
When [shouldCompact](AutoCompactRequest.md#shouldCompact) is disabled, `compactIfNecessary` returns no [OptimizeMetrics](../commands/optimize/OptimizeMetrics.md). | ||
|
||
Otherwise, with [shouldCompact](AutoCompactRequest.md#shouldCompact) turned on, `compactIfNecessary` [performs auto compaction](AutoCompact.md#compact). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# AutoCompactRequest | ||
|
||
`AutoCompactRequest` is...FIXME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# AutoCompactUtils | ||
|
||
## prepareAutoCompactRequest { #prepareAutoCompactRequest } | ||
|
||
```scala | ||
prepareAutoCompactRequest( | ||
spark: SparkSession, | ||
txn: OptimisticTransactionImpl, | ||
postCommitSnapshot: Snapshot, | ||
partitionsAddedToOpt: Option[PartitionKeySet], | ||
opType: String, | ||
maxDeletedRowsRatio: Option[Double]): AutoCompactRequest | ||
``` | ||
|
||
`prepareAutoCompactRequest`...FIXME | ||
|
||
--- | ||
|
||
`prepareAutoCompactRequest` is used when: | ||
|
||
* `AutoCompactBase` is requested to [compactIfNecessary](AutoCompactBase.md#compactIfNecessary) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Auto Compaction | ||
|
||
**Auto Compaction** feature in Delta Lake uses [AutoCompact](AutoCompact.md) post-commit hook to [run](AutoCompactBase.md#run) at a [successful transaction commit](../OptimisticTransactionImpl.md#registerPostCommitHook). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters