kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [2/2] kudu git commit: [python] - Add BlockSize method to ColumnSpec
Date Mon, 31 Oct 2016 23:00:18 GMT
[python] - Add BlockSize method to ColumnSpec

The ColumnSpec class currently doesn't expose the BlockSize method.
This patch adds that and includes a test.

Change-Id: I29c272efe1745c830054f081b311c34488f0d5c7
Reviewed-on: http://gerrit.cloudera.org:8080/4884
Tested-by: Kudu Jenkins
Reviewed-by: Todd Lipcon <todd@apache.org>


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

Branch: refs/heads/master
Commit: 4ed84b9560ef16839fad063a79b59b40361c6916
Parents: b2f3803
Author: Jordan Birdsell <jordantbirdsell@gmail.com>
Authored: Sat Oct 29 13:46:56 2016 -0400
Committer: Todd Lipcon <todd@apache.org>
Committed: Mon Oct 31 22:47:21 2016 +0000

----------------------------------------------------------------------
 python/kudu/schema.pyx           | 30 +++++++++++++++++++++++++++++-
 python/kudu/tests/test_schema.py |  1 +
 2 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/4ed84b95/python/kudu/schema.pyx
----------------------------------------------------------------------
diff --git a/python/kudu/schema.pyx b/python/kudu/schema.pyx
index cbef9d9..69de477 100644
--- a/python/kudu/schema.pyx
+++ b/python/kudu/schema.pyx
@@ -318,6 +318,29 @@ cdef class ColumnSpec:
         self.spec.RenameTo(new_name)
         return self
 
+    def block_size(self, block_size):
+        """
+        Set the target block size for the column.
+
+        This is the number of bytes of user data packed per block on disk, and
+        represents the unit of IO when reading the column. Larger values may
+        improve scan performance, particularly on spinning media. Smaller
+        values may improve random access performance, particularly for
+        workloads that have high cache hit rates or operate on fast storage
+        such as SSD.
+
+        Parameters
+        ----------
+        block_size : int
+          Block size (in bytes) to use.
+
+        Returns
+        -------
+        self : ColumnSpec
+        """
+        self.spec.BlockSize(block_size)
+        return self
+
 
 cdef class SchemaBuilder:
 
@@ -347,7 +370,7 @@ cdef class SchemaBuilder:
                                colschema.nullable)
 
     def add_column(self, name, type_=None, nullable=None, compression=None,
-                   encoding=None, primary_key=False):
+                   encoding=None, primary_key=False, block_size=None):
         """
         Add a new column to the schema. Returns a ColumnSpec object for further
         configuration and use in a fluid programming style.
@@ -368,6 +391,8 @@ cdef class SchemaBuilder:
           Or see kudu.ENCODING_* constants
         primary_key : boolean, default False
           Use this column as the table primary key
+        block_size : int, optional
+          Block size (in bytes) to use for the target column.
 
         Examples
         --------
@@ -400,6 +425,9 @@ cdef class SchemaBuilder:
         if primary_key:
             result.primary_key()
 
+        if block_size:
+            result.block_size(block_size)
+
         return result
 
     def set_primary_keys(self, key_names):

http://git-wip-us.apache.org/repos/asf/kudu/blob/4ed84b95/python/kudu/tests/test_schema.py
----------------------------------------------------------------------
diff --git a/python/kudu/tests/test_schema.py b/python/kudu/tests/test_schema.py
index b75c61d..8df1a1e 100644
--- a/python/kudu/tests/test_schema.py
+++ b/python/kudu/tests/test_schema.py
@@ -93,6 +93,7 @@ class TestSchema(unittest.TestCase):
         (builder.add_column('key')
          .type('int32')
          .primary_key()
+         .block_size(1048576)
          .nullable(False))
         schema = builder.build()
 


Mime
View raw message