You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by bl...@apache.org on 2019/06/18 22:16:10 UTC

[incubator-iceberg] branch master updated: Support FastAppend in BaseTransaction (#223)

This is an automated email from the ASF dual-hosted git repository.

blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iceberg.git


The following commit(s) were added to refs/heads/master by this push:
     new 68f937c  Support FastAppend in BaseTransaction (#223)
68f937c is described below

commit 68f937c5a3ebf5c0ed89d4a41f87a5bd558e62df
Author: Anton Okolnychyi <ao...@apple.com>
AuthorDate: Tue Jun 18 23:16:06 2019 +0100

    Support FastAppend in BaseTransaction (#223)
---
 .../java/org/apache/iceberg/BaseTransaction.java   | 13 ++++++++++++
 .../java/org/apache/iceberg/TestTransaction.java   | 23 ++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/core/src/main/java/org/apache/iceberg/BaseTransaction.java b/core/src/main/java/org/apache/iceberg/BaseTransaction.java
index c4dac2b..be91e0a 100644
--- a/core/src/main/java/org/apache/iceberg/BaseTransaction.java
+++ b/core/src/main/java/org/apache/iceberg/BaseTransaction.java
@@ -135,6 +135,14 @@ class BaseTransaction implements Transaction {
   }
 
   @Override
+  public AppendFiles newFastAppend() {
+    checkLastOperationCommitted("AppendFiles");
+    AppendFiles append = new FastAppend(transactionOps);
+    updates.add(append);
+    return append;
+  }
+
+  @Override
   public RewriteFiles newRewrite() {
     checkLastOperationCommitted("RewriteFiles");
     RewriteFiles rewrite = new ReplaceFiles(transactionOps);
@@ -380,6 +388,11 @@ class BaseTransaction implements Transaction {
     }
 
     @Override
+    public AppendFiles newFastAppend() {
+      return BaseTransaction.this.newFastAppend();
+    }
+
+    @Override
     public RewriteFiles newRewrite() {
       return BaseTransaction.this.newRewrite();
     }
diff --git a/core/src/test/java/org/apache/iceberg/TestTransaction.java b/core/src/test/java/org/apache/iceberg/TestTransaction.java
index 141e95e..8fa8b77 100644
--- a/core/src/test/java/org/apache/iceberg/TestTransaction.java
+++ b/core/src/test/java/org/apache/iceberg/TestTransaction.java
@@ -21,6 +21,7 @@ package org.apache.iceberg;
 
 import com.google.common.collect.Sets;
 import java.io.File;
+import java.util.List;
 import java.util.Set;
 import org.apache.iceberg.ManifestEntry.Status;
 import org.apache.iceberg.exceptions.CommitFailedException;
@@ -458,4 +459,26 @@ public class TestTransaction extends TableTestBase {
 
     Assert.assertFalse("Append manifest should be deleted", new File(appendManifest.path()).exists());
   }
+
+  @Test
+  public void testTransactionFastAppends() {
+    table.updateProperties()
+        .set(TableProperties.MANIFEST_MIN_MERGE_COUNT, "0")
+        .commit();
+
+    Transaction txn = table.newTransaction();
+
+    txn.newFastAppend()
+        .appendFile(FILE_A)
+        .commit();
+
+    txn.newFastAppend()
+        .appendFile(FILE_B)
+        .commit();
+
+    txn.commitTransaction();
+
+    List<ManifestFile> manifests = table.currentSnapshot().manifests();
+    Assert.assertEquals("Expected 2 manifests", 2, manifests.size());
+  }
 }