quickstep-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zu...@apache.org
Subject [13/30] incubator-quickstep git commit: Refactored how min and max BLOCKSIZEMBs are calculated. (#191)
Date Thu, 05 May 2016 06:16:49 GMT
Refactored how min and max BLOCKSIZEMBs are calculated. (#191)

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

Branch: refs/heads/master
Commit: 4ec8d4d788d890314b5a29419565e75098c5d5cc
Parents: 4423550
Author: Marc S <cramja@users.noreply.github.com>
Authored: Tue Apr 26 12:35:27 2016 -0500
Committer: Zuyu Zhang <zzhang@pivotal.io>
Committed: Wed May 4 23:15:34 2016 -0700

----------------------------------------------------------------------
 query_optimizer/resolver/Resolver.cpp             | 18 ++++++++++--------
 .../tests/logical_generator/Create.test           |  4 ++--
 query_optimizer/tests/resolver/Create.test        | 13 +++++++++++--
 storage/StorageConstants.hpp                      | 12 ++++++++++++
 4 files changed, 35 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4ec8d4d7/query_optimizer/resolver/Resolver.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/Resolver.cpp b/query_optimizer/resolver/Resolver.cpp
index 8ddcf3f..1cf5c28 100644
--- a/query_optimizer/resolver/Resolver.cpp
+++ b/query_optimizer/resolver/Resolver.cpp
@@ -600,7 +600,7 @@ StorageBlockLayoutDescription* Resolver::resolveBlockProperties(
     }
   }
   // Resolve the Block size (size -> # of slots).
-  std::int64_t slots = 1;  // The default.
+  std::int64_t slots = kDefaultBlockSizeInSlots;
   if (block_properties->hasBlockSizeMb()) {
     std::int64_t blocksizemb = block_properties->getBlockSizeMbValue();
     if (blocksizemb == -1) {
@@ -608,16 +608,18 @@ StorageBlockLayoutDescription* Resolver::resolveBlockProperties(
       THROW_SQL_ERROR_AT(block_properties->getBlockSizeMb())
           << "The BLOCKSIZEMB property must be an integer.";
     }
-    slots = (blocksizemb * 1000000) / kSlotSizeBytes;
+    slots = (blocksizemb * kAMegaByte) / kSlotSizeBytes;
     DLOG(INFO) << "Resolver using BLOCKSIZEMB of " << slots << " slots"
         << " which is " << (slots * kSlotSizeBytes) << " bytes versus"
-        << " user requested " << (blocksizemb * 1000000) << " bytes.";
-    // 1Gb is the max size.
-    const std::int64_t max_size_slots = 1000000000 / kSlotSizeBytes;
-    // TODO(marc) The upper bound is arbitrary.
-    if (slots < 1 || slots > max_size_slots) {
+        << " user requested " << (blocksizemb * kAMegaByte) << " bytes.";
+    const std::uint64_t max_size_slots = kBlockSizeUpperBoundBytes / kSlotSizeBytes;
+    const std::uint64_t min_size_slots = kBlockSizeLowerBoundBytes / kSlotSizeBytes;
+    if (static_cast<std::uint64_t>(slots) < min_size_slots ||
+        static_cast<std::uint64_t>(slots) > max_size_slots) {
       THROW_SQL_ERROR_AT(block_properties->getBlockSizeMb())
-        << "The BLOCKSIZEMB property must be between 2Mb and 1000Mb.";
+          << "The BLOCKSIZEMB property must be between "
+          << std::to_string(kBlockSizeLowerBoundBytes / kAMegaByte) << "MB and
"
+          << std::to_string(kBlockSizeUpperBoundBytes / kAMegaByte) << "MB.";
     }
   }
   storage_block_description->set_num_slots(slots);

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4ec8d4d7/query_optimizer/tests/logical_generator/Create.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/logical_generator/Create.test b/query_optimizer/tests/logical_generator/Create.test
index 6ceaa8f..eb99759 100644
--- a/query_optimizer/tests/logical_generator/Create.test
+++ b/query_optimizer/tests/logical_generator/Create.test
@@ -19,7 +19,7 @@ TopLevelPlan
 +-plan=CreateTable[relation=foo]
 | +-block_properties=ProtoDescription
 | | +-Property=ProtoProperty[Property=blocktype,Value=rowstore]
-| | +-Property=ProtoProperty[Property=slots,Value=4]
+| | +-Property=ProtoProperty[Property=slots,Value=5]
 | +-attributes=
 |   +-AttributeReference[id=0,name=attr,relation=foo,type=Int]
 +-output_attributes=
@@ -36,7 +36,7 @@ TopLevelPlan
 | | +-Property=ProtoProperty[Property=sort,Value=0]
 | | +-Property=ProtoProperty[Property=compress,Value=0]
 | | +-Property=ProtoProperty[Property=compress,Value=1]
-| | +-Property=ProtoProperty[Property=slots,Value=4]
+| | +-Property=ProtoProperty[Property=slots,Value=5]
 | +-attributes=
 |   +-AttributeReference[id=0,name=attr,relation=foo,type=Int]
 |   +-AttributeReference[id=1,name=attr2,relation=foo,type=Int]

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4ec8d4d7/query_optimizer/tests/resolver/Create.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/resolver/Create.test b/query_optimizer/tests/resolver/Create.test
index d4a1098..18beacd 100644
--- a/query_optimizer/tests/resolver/Create.test
+++ b/query_optimizer/tests/resolver/Create.test
@@ -202,10 +202,19 @@ ERROR: The BLOCKSIZEMB property must be an integer. (2 : 17)
                 ^
 ==
 
-# BLOCKSIZEMB must not be 0.
+# BLOCKSIZEMB must be greater than the minimum (defined in StorageConstants.hpp).
 CREATE TABLE foo (attr INT) WITH BLOCKPROPERTIES
 (TYPE rowstore, BLOCKSIZEMB 0);
 --
-ERROR: The BLOCKSIZEMB property must be between 2Mb and 1000Mb. (2 : 17)
+ERROR: The BLOCKSIZEMB property must be between 2MB and 1024MB. (2 : 17)
 (TYPE rowstore, BLOCKSIZEMB 0);
                 ^
+==
+
+# BLOCKSIZEMB must be less than the maximum (defined in StorageConstants.hpp).
+CREATE TABLE foo (attr INT) WITH BLOCKPROPERTIES
+(TYPE rowstore, BLOCKSIZEMB 2000);
+--
+ERROR: The BLOCKSIZEMB property must be between 2MB and 1024MB. (2 : 17)
+(TYPE rowstore, BLOCKSIZEMB 2000);
+                ^

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4ec8d4d7/storage/StorageConstants.hpp
----------------------------------------------------------------------
diff --git a/storage/StorageConstants.hpp b/storage/StorageConstants.hpp
index 43996c6..de54345 100644
--- a/storage/StorageConstants.hpp
+++ b/storage/StorageConstants.hpp
@@ -37,6 +37,18 @@ const std::size_t kSlotSizeBytes = 0x200000;
 
 // A GigaByte.
 const std::uint64_t kAGigaByte = (1 << 30);
+// A MegaByte.
+const std::uint64_t kAMegaByte = (1 << 20);
+
+// Constants for the minimum and maximum user-specifiable BLOCKSIZEMB in
+// the SQL clause BLOCKPROPERTIES.
+const std::uint64_t kBlockSizeUpperBoundBytes = kAGigaByte;
+
+// 2 Megabytes.
+const std::uint64_t kBlockSizeLowerBoundBytes = kAMegaByte << 1;
+
+// The default size of a new relation in terms of the number of slots.
+const std::uint64_t kDefaultBlockSizeInSlots = 1;
 
 // To determine the size of a buffer pool, we use a threshold (see below)
 // to check if the system has "large" amounts of installed memory. This


Mime
View raw message