Fixed the test cases.
diff --git a/query_optimizer/resolver/Resolver.cpp b/query_optimizer/resolver/Resolver.cpp
index 1cf5c28..e0f1ba3 100644
--- a/query_optimizer/resolver/Resolver.cpp
+++ b/query_optimizer/resolver/Resolver.cpp
@@ -602,16 +602,21 @@
// Resolve the Block size (size -> # of slots).
std::int64_t slots = kDefaultBlockSizeInSlots;
if (block_properties->hasBlockSizeMb()) {
- std::int64_t blocksizemb = block_properties->getBlockSizeMbValue();
- if (blocksizemb == -1) {
+ const std::int64_t block_size_in_mega_bytes = block_properties->getBlockSizeMbValue();
+ if (block_size_in_mega_bytes == -1) {
// Indicates an error condition if the property is present but getter returns -1.
THROW_SQL_ERROR_AT(block_properties->getBlockSizeMb())
<< "The BLOCKSIZEMB property must be an integer.";
+ } else if ((block_size_in_mega_bytes * kAMegaByte) % kSlotSizeBytes != 0) {
+ THROW_SQL_ERROR_AT(block_properties->getBlockSizeMb())
+ << "The BLOCKSIZEMB property must be multiple times of "
+ << std::to_string(kSlotSizeBytes / kAMegaByte) << "MB.";
}
- slots = (blocksizemb * kAMegaByte) / kSlotSizeBytes;
+
+ slots = (block_size_in_mega_bytes * kAMegaByte) / kSlotSizeBytes;
DLOG(INFO) << "Resolver using BLOCKSIZEMB of " << slots << " slots"
<< " which is " << (slots * kSlotSizeBytes) << " bytes versus"
- << " user requested " << (blocksizemb * kAMegaByte) << " bytes.";
+ << " user requested " << (block_size_in_mega_bytes * 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 ||
diff --git a/query_optimizer/tests/logical_generator/Create.test b/query_optimizer/tests/logical_generator/Create.test
index eb99759..66e8c5b 100644
--- a/query_optimizer/tests/logical_generator/Create.test
+++ b/query_optimizer/tests/logical_generator/Create.test
@@ -13,7 +13,7 @@
# limitations under the License.
[default optimized_logical_plan]
-CREATE TABLE foo (attr int) WITH BLOCKPROPERTIES (TYPE rowstore, BLOCKSIZEMB 10)
+CREATE TABLE foo (attr int) WITH BLOCKPROPERTIES (TYPE rowstore, BLOCKSIZEMB 160)
--
TopLevelPlan
+-plan=CreateTable[relation=foo]
@@ -27,7 +27,7 @@
==
CREATE TABLE foo (attr int, attr2 int) WITH BLOCKPROPERTIES
-(TYPE compressed_columnstore, SORT attr, COMPRESS ALL, BLOCKSIZEMB 10)
+(TYPE compressed_columnstore, SORT attr, COMPRESS ALL, BLOCKSIZEMB 160)
--
TopLevelPlan
+-plan=CreateTable[relation=foo]
diff --git a/query_optimizer/tests/physical_generator/Create.test b/query_optimizer/tests/physical_generator/Create.test
index 58e15fa..cc46de2 100644
--- a/query_optimizer/tests/physical_generator/Create.test
+++ b/query_optimizer/tests/physical_generator/Create.test
@@ -86,8 +86,8 @@
+-AttributeReference[id=10,name=col11,relation=foo,type=Char(5) NULL]
+-AttributeReference[id=11,name=col12,relation=foo,type=VarChar(5) NULL]
==
-CREATE TABLE foo (col1 INT) WITH BLOCKPROPERTIES
- (TYPE compressed_columnstore, SORT col1, COMPRESS ALL, BLOCKSIZEMB 5);
+CREATE TABLE foo (col1 INT) WITH BLOCKPROPERTIES
+ (TYPE compressed_columnstore, SORT col1, COMPRESS ALL, BLOCKSIZEMB 64);
--
[Optimized Logical Plan]
TopLevelPlan
diff --git a/query_optimizer/tests/resolver/Create.test b/query_optimizer/tests/resolver/Create.test
index 18beacd..d7bf384 100644
--- a/query_optimizer/tests/resolver/Create.test
+++ b/query_optimizer/tests/resolver/Create.test
@@ -123,7 +123,7 @@
==
# Rowstores cannot have a sorted attribute.
-CREATE TABLE foo (attr INT) WITH BLOCKPROPERTIES
+CREATE TABLE foo (attr INT) WITH BLOCKPROPERTIES
(TYPE rowstore, SORT attr);
--
ERROR: The SORT property does not apply to this block type. (2 : 22)
@@ -167,7 +167,7 @@
==
# Compress property is required for compressed blocks.
-CREATE TABLE foo (attr INT) WITH
+CREATE TABLE foo (attr INT) WITH
BLOCKPROPERTIES (TYPE compressed_rowstore);
--
ERROR: The COMPRESS property must be specified as ALL or a list of attributes. (2 : 1)
@@ -206,7 +206,7 @@
CREATE TABLE foo (attr INT) WITH BLOCKPROPERTIES
(TYPE rowstore, BLOCKSIZEMB 0);
--
-ERROR: The BLOCKSIZEMB property must be between 2MB and 1024MB. (2 : 17)
+ERROR: The BLOCKSIZEMB property must be between 32MB and 1024MB. (2 : 17)
(TYPE rowstore, BLOCKSIZEMB 0);
^
==
@@ -215,6 +215,6 @@
CREATE TABLE foo (attr INT) WITH BLOCKPROPERTIES
(TYPE rowstore, BLOCKSIZEMB 2000);
--
-ERROR: The BLOCKSIZEMB property must be between 2MB and 1024MB. (2 : 17)
+ERROR: The BLOCKSIZEMB property must be multiple times of 32MB. (2 : 17)
(TYPE rowstore, BLOCKSIZEMB 2000);
^
diff --git a/storage/tests/HashTable_unittest_common.hpp b/storage/tests/HashTable_unittest_common.hpp
index c1df6d1..1ecb0d0 100644
--- a/storage/tests/HashTable_unittest_common.hpp
+++ b/storage/tests/HashTable_unittest_common.hpp
@@ -66,24 +66,24 @@
class TestHashPayload {
public:
- explicit TestHashPayload(const int payload)
- : internal_int_(payload) {
+ explicit TestHashPayload(const std::int64_t payload)
+ : internal_long_(payload) {
}
TestHashPayload(const TestHashPayload &orig)
- : internal_int_(orig.internal_int_.load()) {
+ : internal_long_(orig.internal_long_.load()) {
}
- std::atomic<int>* accessInternalInt() {
- return &internal_int_;
+ void increaseByOne() {
+ internal_long_.fetch_add(1, std::memory_order_relaxed);
}
- int loadInternalInt() const {
- return internal_int_.load(std::memory_order_relaxed);
+ std::int64_t loadInternalLong() const {
+ return internal_long_.load(std::memory_order_relaxed);
}
private:
- std::atomic<int> internal_int_;
+ std::atomic<std::int64_t> internal_long_;
};
class NonTriviallyDestructibleTestHashPayload {
@@ -129,13 +129,13 @@
void operator()(TestHashPayload *value) {
++call_count_;
- value->accessInternalInt()->fetch_add(1, std::memory_order_relaxed);
+ value->increaseByOne();
}
template <typename ValueAccessorT>
void operator()(const ValueAccessorT &accessor, TestHashPayload *value) {
++call_count_;
- value->accessInternalInt()->fetch_add(1, std::memory_order_relaxed);
+ value->increaseByOne();
}
std::size_t call_count() const {
@@ -160,11 +160,11 @@
}
void operator()(const TypedValue &key, const TestHashPayload &payload) {
- internal_map_.emplace(extractScalarSeed(key), payload.loadInternalInt());
+ internal_map_.emplace(extractScalarSeed(key), payload.loadInternalLong());
}
void operator()(const std::vector<TypedValue> &key, const TestHashPayload &payload) {
- internal_map_.emplace(extractCompositeSeed(key), payload.loadInternalInt());
+ internal_map_.emplace(extractCompositeSeed(key), payload.loadInternalLong());
}
template <typename ValueAccessorT>
@@ -175,7 +175,7 @@
composite_key.emplace_back(accessor.getTypedValue(2));
internal_map_.emplace(extractCompositeSeed(composite_key),
- payload.loadInternalInt());
+ payload.loadInternalLong());
}
const std::unordered_multimap<std::int64_t, int>& internal_map() const {
@@ -486,23 +486,23 @@
if (!HashTableImpl::template_allow_duplicate_keys) {
const TestHashPayload *value = hash_table_->getSingle(key);
ASSERT_NE(nullptr, value);
- EXPECT_EQ(i, value->loadInternalInt());
+ EXPECT_EQ(i, value->loadInternalLong());
value = hash_table_->getSingleCompositeKey(key_vec);
ASSERT_NE(nullptr, value);
- EXPECT_EQ(i, value->loadInternalInt());
+ EXPECT_EQ(i, value->loadInternalLong());
}
// Test getAll() in all cases.
std::vector<const TestHashPayload*> matches;
hash_table_->getAll(key, &matches);
ASSERT_EQ(1u, matches.size());
- EXPECT_EQ(i, matches.front()->loadInternalInt());
+ EXPECT_EQ(i, matches.front()->loadInternalLong());
matches.clear();
hash_table_->getAllCompositeKey(key_vec, &matches);
ASSERT_EQ(1u, matches.size());
- EXPECT_EQ(i, matches.front()->loadInternalInt());
+ EXPECT_EQ(i, matches.front()->loadInternalLong());
}
// Check a nonexistent key.
@@ -564,9 +564,9 @@
EXPECT_EQ(static_cast<std::size_t>((i % 3) + 1), matches.size());
std::bitset<3> value_found;
for (const TestHashPayload *match : matches) {
- ASSERT_LE(match->loadInternalInt() - i * kNumSampleKeys, 3);
- EXPECT_FALSE(value_found[match->loadInternalInt() - i * kNumSampleKeys]);
- value_found.set(match->loadInternalInt() - i * kNumSampleKeys, true);
+ ASSERT_LE(match->loadInternalLong() - i * kNumSampleKeys, 3);
+ EXPECT_FALSE(value_found[match->loadInternalLong() - i * kNumSampleKeys]);
+ value_found.set(match->loadInternalLong() - i * kNumSampleKeys, true);
}
EXPECT_TRUE(value_found[0]);
if (i % 3 > 0) {
@@ -582,7 +582,7 @@
} else {
ASSERT_EQ(1u, matches.size());
EXPECT_EQ(i * kNumSampleKeys,
- matches.front()->loadInternalInt());
+ matches.front()->loadInternalLong());
}
}
@@ -667,7 +667,7 @@
hash_table_->getAll(key, &matches);
ASSERT_EQ(1u, matches.size());
EXPECT_EQ(i + (i >= kNumSampleKeys / 2),
- matches.front()->loadInternalInt());
+ matches.front()->loadInternalLong());
}
// Also read the values out using the vectorized interface.
@@ -743,7 +743,7 @@
std::vector<const TestHashPayload*> matches;
hash_table_->getAll(key, &matches);
ASSERT_EQ(1u, matches.size());
- EXPECT_EQ(i, matches.front()->loadInternalInt());
+ EXPECT_EQ(i, matches.front()->loadInternalLong());
}
}
@@ -776,7 +776,7 @@
std::vector<const TestHashPayload*> matches;
hash_table_->getAll(key, &matches);
ASSERT_EQ(1u, matches.size());
- EXPECT_EQ(j, matches.front()->loadInternalInt());
+ EXPECT_EQ(j, matches.front()->loadInternalLong());
}
// Check that the entry we failed to insert is not present.
@@ -814,7 +814,7 @@
const TestHashPayload *value = hash_table_->getSingle(key);
ASSERT_NE(nullptr, value);
- EXPECT_EQ(44 - (i % 2), value->loadInternalInt());
+ EXPECT_EQ(44 - (i % 2), value->loadInternalLong());
}
}
@@ -855,7 +855,7 @@
std::vector<const TestHashPayload*> matches;
hash_table_->getAll(key, &matches);
ASSERT_EQ(1u, matches.size());
- EXPECT_EQ(43, matches.front()->loadInternalInt());
+ EXPECT_EQ(43, matches.front()->loadInternalLong());
}
}
@@ -919,7 +919,7 @@
std::vector<const TestHashPayload*> matches;
hash_table_->getAll(key, &matches);
ASSERT_EQ(1u, matches.size());
- EXPECT_EQ(i, matches.front()->loadInternalInt());
+ EXPECT_EQ(i, matches.front()->loadInternalLong());
}
// Check a nonexistent key.
@@ -1005,7 +1005,7 @@
EXPECT_EQ(kNumConcurrentThreads, matches.size());
std::vector<bool> found_value(kNumConcurrentThreads, false);
for (const TestHashPayload *payload : matches) {
- const int payload_value = payload->loadInternalInt();
+ const int payload_value = payload->loadInternalLong();
ASSERT_GE(payload_value, i * kNumSampleKeys);
ASSERT_LT(payload_value,
i * kNumSampleKeys + static_cast<std::int64_t>(kNumConcurrentThreads));
@@ -1020,7 +1020,7 @@
for (const std::unique_ptr<InserterThread> &thread : threads) {
if (thread->insert_succeeded()[i]) {
EXPECT_EQ(i * kNumSampleKeys + thread->getID(),
- matches.front()->loadInternalInt());
+ matches.front()->loadInternalLong());
}
}
}
@@ -1101,7 +1101,7 @@
EXPECT_EQ(kNumConcurrentThreads, matches.size());
std::vector<bool> found_value(kNumConcurrentThreads, false);
for (const TestHashPayload *payload : matches) {
- const int payload_value = payload->loadInternalInt();
+ const int payload_value = payload->loadInternalLong();
ASSERT_GE(payload_value, i * kNumSampleKeys);
ASSERT_LT(payload_value,
i * kNumSampleKeys + static_cast<std::int64_t>(kNumConcurrentThreads));
@@ -1116,7 +1116,7 @@
for (const std::unique_ptr<CompositeKeyInserterThread> &thread : threads) {
if (thread->insert_succeeded()[i]) {
EXPECT_EQ(i * kNumSampleKeys + thread->getID(),
- matches.front()->loadInternalInt());
+ matches.front()->loadInternalLong());
}
}
}
@@ -1354,14 +1354,14 @@
if (!TypeParam::template_allow_duplicate_keys) {
const TestHashPayload *value = this->hash_table_->getSingleCompositeKey(key);
ASSERT_NE(nullptr, value);
- EXPECT_EQ(i, value->loadInternalInt());
+ EXPECT_EQ(i, value->loadInternalLong());
}
// Test getAllCompositeKey() in all cases.
std::vector<const TestHashPayload*> matches;
this->hash_table_->getAllCompositeKey(key, &matches);
ASSERT_EQ(1u, matches.size());
- EXPECT_EQ(i, matches.front()->loadInternalInt());
+ EXPECT_EQ(i, matches.front()->loadInternalLong());
}
// Check a nonexistent key.
@@ -1436,22 +1436,22 @@
std::vector<const TestHashPayload*> values;
this->hash_table_->getAll(empty_hash_key, &values);
ASSERT_EQ(1u, values.size());
- EXPECT_EQ(42, values.front()->loadInternalInt());
+ EXPECT_EQ(42, values.front()->loadInternalLong());
values.clear();
this->hash_table_->getAll(pending_hash_key, &values);
ASSERT_EQ(1u, values.size());
- EXPECT_EQ(85, values.front()->loadInternalInt());
+ EXPECT_EQ(85, values.front()->loadInternalLong());
values.clear();
this->hash_table_->getAll(adjusted_empty_hash_key, &values);
ASSERT_EQ(1u, values.size());
- EXPECT_EQ(123, values.front()->loadInternalInt());
+ EXPECT_EQ(123, values.front()->loadInternalLong());
values.clear();
this->hash_table_->getAll(adjusted_pending_hash_key, &values);
ASSERT_EQ(1u, values.size());
- EXPECT_EQ(456, values.front()->loadInternalInt());
+ EXPECT_EQ(456, values.front()->loadInternalLong());
values.clear();
}
@@ -1504,9 +1504,9 @@
EXPECT_EQ(static_cast<std::size_t>((i % 3) + 1), matches.size());
std::bitset<3> value_found;
for (const TestHashPayload *match : matches) {
- ASSERT_LE(match->loadInternalInt() - i * kNumSampleKeys, 3);
- EXPECT_FALSE(value_found[match->loadInternalInt() - i * kNumSampleKeys]);
- value_found.set(match->loadInternalInt() - i * kNumSampleKeys, true);
+ ASSERT_LE(match->loadInternalLong() - i * kNumSampleKeys, 3);
+ EXPECT_FALSE(value_found[match->loadInternalLong() - i * kNumSampleKeys]);
+ value_found.set(match->loadInternalLong() - i * kNumSampleKeys, true);
}
EXPECT_TRUE(value_found[0]);
if (i % 3 > 0) {
@@ -1522,7 +1522,7 @@
} else {
ASSERT_EQ(1u, matches.size());
EXPECT_EQ(i * kNumSampleKeys,
- matches.front()->loadInternalInt());
+ matches.front()->loadInternalLong());
}
}
@@ -1625,7 +1625,7 @@
this->hash_table_->getAllCompositeKey(key, &matches);
ASSERT_EQ(1u, matches.size());
EXPECT_EQ(i + (i >= kNumSampleKeys / 2),
- matches.front()->loadInternalInt());
+ matches.front()->loadInternalLong());
}
// Also read the values out using the vectorized interface.
@@ -1738,7 +1738,7 @@
std::vector<const TestHashPayload*> matches;
this->hash_table_->getAllCompositeKey(key, &matches);
ASSERT_EQ(1u, matches.size());
- EXPECT_EQ(i, matches.front()->loadInternalInt());
+ EXPECT_EQ(i, matches.front()->loadInternalLong());
}
}
@@ -1799,7 +1799,7 @@
std::vector<const TestHashPayload*> matches;
this->hash_table_->getAllCompositeKey(key, &matches);
ASSERT_EQ(1u, matches.size());
- EXPECT_EQ(j, matches.front()->loadInternalInt());
+ EXPECT_EQ(j, matches.front()->loadInternalLong());
}
// Check that the entry we failed to insert is not present.
@@ -1849,7 +1849,7 @@
const TestHashPayload *value = this->hash_table_->getSingleCompositeKey(key);
ASSERT_NE(nullptr, value);
- EXPECT_EQ(44 - (i % 2), value->loadInternalInt());
+ EXPECT_EQ(44 - (i % 2), value->loadInternalLong());
}
}
@@ -1892,7 +1892,7 @@
std::vector<const TestHashPayload*> matches;
this->hash_table_->getAllCompositeKey(key, &matches);
ASSERT_EQ(1u, matches.size());
- EXPECT_EQ(43, matches.front()->loadInternalInt());
+ EXPECT_EQ(43, matches.front()->loadInternalLong());
}
}
@@ -1988,7 +1988,7 @@
std::vector<const TestHashPayload*> matches;
this->hash_table_->getAllCompositeKey(key, &matches);
ASSERT_EQ(1u, matches.size());
- EXPECT_EQ(i, matches.front()->loadInternalInt());
+ EXPECT_EQ(i, matches.front()->loadInternalLong());
}
// Check a nonexistent key.