You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by zu...@apache.org on 2016/05/16 20:55:50 UTC

[13/46] incubator-quickstep git commit: Refactored how min and max BLOCKSIZEMBs are calculated. (#191)

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/a6677220
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/a6677220
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/a6677220

Branch: refs/heads/master
Commit: a6677220361f6452428f48f4cd341fa834e33565
Parents: 8d55ffe
Author: Marc S <cr...@users.noreply.github.com>
Authored: Tue Apr 26 12:35:27 2016 -0500
Committer: Jignesh Patel <pa...@users.noreply.github.com>
Committed: Tue Apr 26 12:35:27 2016 -0500

----------------------------------------------------------------------
 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/a6677220/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/a6677220/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/a6677220/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/a6677220/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