This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new ca1c107 [java-example] insert rows in AUTO_FLUSH_BACKGROUND mode
ca1c107 is described below
commit ca1c1077fe29c5c0d617cc86c164abdfb3bd7629
Author: zhangyifan27 <[email protected]>
AuthorDate: Mon Sep 28 11:18:16 2020 +0800
[java-example] insert rows in AUTO_FLUSH_BACKGROUND mode
The default flush mode is 'AUTO_FLUSH_SYNC', we should configure
the session with 'AUTO_FLUSH_BACKGROUND' then we could call
'countPendingErrors()' and 'getPendingErrors()' to print errors.
Change-Id: I69e2783ffb02e998684218b7b51a94d5a433d7a2
Reviewed-on: http://gerrit.cloudera.org:8080/16509
Tested-by: Kudu Jenkins
Reviewed-by: Alexey Serbin <[email protected]>
---
.../java-example/src/main/java/org/apache/kudu/examples/Example.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git
a/examples/java/java-example/src/main/java/org/apache/kudu/examples/Example.java
b/examples/java/java-example/src/main/java/org/apache/kudu/examples/Example.java
index 9d6e2a1..2cd1229 100644
---
a/examples/java/java-example/src/main/java/org/apache/kudu/examples/Example.java
+++
b/examples/java/java-example/src/main/java/org/apache/kudu/examples/Example.java
@@ -36,6 +36,7 @@ import org.apache.kudu.client.KuduTable;
import org.apache.kudu.client.PartialRow;
import org.apache.kudu.client.RowResult;
import org.apache.kudu.client.RowResultIterator;
+import org.apache.kudu.client.SessionConfiguration.FlushMode;
/*
* A simple example of using the synchronous Kudu Java client to
@@ -77,6 +78,7 @@ public class Example {
// Open the newly-created table and create a KuduSession.
KuduTable table = client.openTable(tableName);
KuduSession session = client.newSession();
+ session.setFlushMode(FlushMode.AUTO_FLUSH_BACKGROUND);
for (int i = 0; i < numRows; i++) {
Insert insert = table.newInsert();
PartialRow row = insert.getRow();
@@ -93,7 +95,7 @@ public class Example {
// Call session.close() to end the session and ensure the rows are
// flushed and errors are returned.
// You can also call session.flush() to do the same without ending the
session.
- // When flushing in AUTO_FLUSH_BACKGROUND mode (the default mode
recommended
+ // When flushing in AUTO_FLUSH_BACKGROUND mode (the mode recommended
// for most workloads, you must check the pending errors as shown below,
since
// write operations are flushed to Kudu in background threads.
session.close();