You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by jd...@apache.org on 2016/02/04 22:03:25 UTC

[5/5] incubator-kudu git commit: [python] - Allow to set a scanner to be fault tolerant

[python] - Allow to set a scanner to be fault tolerant

Making a scanner fault tolerant is useful in any case, but for cases
where hash partitioning is not being used, fault tolerance has the side
effect of also making the scanner return ordered results. This is a very
useful feature for timeseries use cases as it avoids an additional sort.

This just makes it so that it is possible make a python scanner fault
tolerant by calling the adequate method on the c++ client.

Change-Id: Iaf27778cde442f1da66e42abe8bd0f06e715dcd9
Reviewed-on: http://gerrit.cloudera.org:8080/1993
Tested-by: David Ribeiro Alves <da...@cloudera.com>
Reviewed-by: Todd Lipcon <to...@apache.org>
Reviewed-on: http://gerrit.cloudera.org:8080/2040
Tested-by: Kudu Jenkins
Reviewed-by: Jean-Daniel Cryans


Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/313fc160
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/313fc160
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/313fc160

Branch: refs/heads/branch-0.7.0
Commit: 313fc16037c51646bf0ddf7a9e6c3ba02b98d846
Parents: f165186
Author: David Alves <da...@cloudera.com>
Authored: Tue Feb 2 02:05:44 2016 -0800
Committer: Jean-Daniel Cryans <jd...@gerrit.cloudera.org>
Committed: Thu Feb 4 21:00:31 2016 +0000

----------------------------------------------------------------------
 python/kudu/client.pyx            | 14 +++++++++++++-
 python/kudu/libkudu_client.pxd    |  1 +
 python/kudu/tests/test_scanner.py |  2 ++
 3 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/313fc160/python/kudu/client.pyx
----------------------------------------------------------------------
diff --git a/python/kudu/client.pyx b/python/kudu/client.pyx
index f23bdeb..ffe8e46 100644
--- a/python/kudu/client.pyx
+++ b/python/kudu/client.pyx
@@ -1002,9 +1002,21 @@ cdef class Scanner:
         clone = pred.pred.Clone()
         check_status(self.scanner.AddConjunctPredicate(clone))
 
+    def set_fault_tolerant(self):
+        """
+        Makes the underlying KuduScanner fault tolerant.
+        Returns a reference to itself to facilitate chaining.
+
+        Returns
+        -------
+        self : Scanner
+        """
+        check_status(self.scanner.SetFaultTolerant())
+        return self
+
     def open(self):
         """
-        Returns a reference to itself to faciliate chaining
+        Returns a reference to itself to facilitate chaining
 
         Returns
         -------

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/313fc160/python/kudu/libkudu_client.pxd
----------------------------------------------------------------------
diff --git a/python/kudu/libkudu_client.pxd b/python/kudu/libkudu_client.pxd
index db71f1e..43557c1 100644
--- a/python/kudu/libkudu_client.pxd
+++ b/python/kudu/libkudu_client.pxd
@@ -593,6 +593,7 @@ cdef extern from "kudu/client/client.h" namespace "kudu::client" nogil:
         Status SetReadMode(ReadMode read_mode)
         Status SetSnapshot(uint64_t snapshot_timestamp_micros)
         Status SetTimeoutMillis(int millis)
+        Status SetFaultTolerant()
 
         string ToString()
 

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/313fc160/python/kudu/tests/test_scanner.py
----------------------------------------------------------------------
diff --git a/python/kudu/tests/test_scanner.py b/python/kudu/tests/test_scanner.py
index e6f1da4..573f9a9 100644
--- a/python/kudu/tests/test_scanner.py
+++ b/python/kudu/tests/test_scanner.py
@@ -86,6 +86,8 @@ class TestScanner(KuduTestBase, unittest.TestCase):
 
         scanner.add_predicates([sv >= 'hello_20',
                                 sv <= 'hello_22'])
+
+        scanner.set_fault_tolerant()
         scanner.open()
 
         tuples = scanner.read_all_tuples()