-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API,Core: Multi-Table transactions API and support for REST
- Loading branch information
Showing
20 changed files
with
2,266 additions
and
9 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
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
84 changes: 84 additions & 0 deletions
84
core/src/main/java/org/apache/iceberg/catalog/CatalogTransaction.java
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,84 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.iceberg.catalog; | ||
|
||
public interface CatalogTransaction { | ||
|
||
enum IsolationLevel { | ||
|
||
/** | ||
* All reads that are being made will see the last committed values that existed when the table | ||
* was loaded first inside the catalog transaction. Subsequent changes to a table that happened | ||
* outside the catalog transaction after the table was read will not be seen to prevent <b>read | ||
* skew</b> (reading a table multiple times within the catalog transaction should always return | ||
* the same results). <br> | ||
* <br> | ||
* Will successfully commit only if the values updated by the transaction do not conflict with | ||
* other concurrent updates. <br> | ||
* <br> | ||
* | ||
* <p>Note that under SNAPSHOT isolation a <b>write skew anomaly</b> is acceptable and | ||
* permitted. In a <b>write skew anomaly</b>, two transactions (T1 and T2) concurrently read an | ||
* overlapping data set (e.g. values V1 and V2), concurrently make disjoint updates (e.g. T1 | ||
* updates V1, T2 updates V2), and finally concurrently commit, neither having seen the update | ||
* performed by the other. | ||
*/ | ||
SNAPSHOT, | ||
|
||
/** | ||
* All reads that are being made will see the last committed values that existed when the table | ||
* was loaded first inside the catalog transaction. Subsequent changes to a table that happened | ||
* outside the catalog transaction after the table was read will not be seen to prevent <b>read | ||
* skew</b>.<br> | ||
* <br> | ||
* All tables participating in the transaction must be in the same state when committing | ||
* compared to when the table was loaded first within the catalog transaction.<br> | ||
* <br> | ||
* | ||
* <p>Note that a <b>write skew anomaly</b> is not possible under SERIALIZABLE isolation, where | ||
* two transactions (T1 and T2) concurrently read an overlapping data set (e.g. values V1 and | ||
* V2), concurrently make disjoint updates (e.g. T1 updates V1, T2 updates V2). This is because | ||
* under SERIALIZABLE isolation either T1 or T2 would have to occur first and be visible to the | ||
* other transaction. | ||
*/ | ||
SERIALIZABLE; | ||
} | ||
|
||
/** | ||
* Performs an atomic commit of all the pending changes across multiple tables. Engine-specific | ||
* implementations must ensure that all pending changes are applied atomically. | ||
*/ | ||
void commitTransaction(); | ||
|
||
/** | ||
* Returns this catalog transaction as a {@link Catalog} API so that any actions that are called | ||
* through this API are participating in this catalog transaction. | ||
* | ||
* @return This catalog transaction as a {@link Catalog} API. Any actions that are called through | ||
* this API are participating in this catalog transaction. | ||
*/ | ||
Catalog asCatalog(); | ||
|
||
/** | ||
* Returns the current {@link IsolationLevel} for this transaction. | ||
* | ||
* @return The {@link IsolationLevel} for this transaction. | ||
*/ | ||
IsolationLevel isolationLevel(); | ||
} |
32 changes: 32 additions & 0 deletions
32
core/src/main/java/org/apache/iceberg/catalog/SupportsCatalogTransactions.java
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,32 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.iceberg.catalog; | ||
|
||
import org.apache.iceberg.catalog.CatalogTransaction.IsolationLevel; | ||
|
||
public interface SupportsCatalogTransactions { | ||
|
||
/** | ||
* Create a new {@link CatalogTransaction} with the given {@link IsolationLevel}. | ||
* | ||
* @param isolationLevel The isolation level to use. | ||
* @return A new {@link CatalogTransaction}. | ||
*/ | ||
CatalogTransaction createTransaction(IsolationLevel isolationLevel); | ||
} |
33 changes: 33 additions & 0 deletions
33
core/src/main/java/org/apache/iceberg/catalog/TableCommit.java
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,33 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.iceberg.catalog; | ||
|
||
import java.util.List; | ||
import org.apache.iceberg.MetadataUpdate; | ||
import org.apache.iceberg.TableMetadata; | ||
import org.immutables.value.Value; | ||
|
||
@Value.Immutable | ||
public interface TableCommit { | ||
TableIdentifier identifier(); | ||
|
||
TableMetadata base(); | ||
|
||
List<MetadataUpdate> changes(); | ||
} |
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
Oops, something went wrong.