forked from hyrise/hyrise-v1
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hyrise#258 from bastih/feature/concurrent_delta
Concurrent delta
- Loading branch information
Showing
26 changed files
with
599 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,172 +1,48 @@ | ||
// Copyright (c) 2012 Hasso-Plattner-Institut fuer Softwaresystemtechnik GmbH. All rights reserved. | ||
#include "testing/test.h" | ||
#include <storage.h> | ||
|
||
#include <storage/BitCompressedVector.h> | ||
#include <storage/FixedLengthVector.h> | ||
#include <storage/AttributeVectorFactory.h> | ||
|
||
template <typename T> | ||
class AttributeVectorTests : public ::hyrise::Test { | ||
public: | ||
|
||
}; | ||
|
||
template<bool Compressed> | ||
struct TestType { | ||
static const bool compressed = Compressed; | ||
}; | ||
|
||
|
||
TEST( FixedLengthVectorTest, increment_test ) { | ||
size_t cols = 1; | ||
size_t rows = 3; | ||
|
||
auto tuples = std::dynamic_pointer_cast<FixedLengthVector<value_id_t>>( | ||
AttributeVectorFactory::getAttributeVector2<value_id_t>(cols,rows, false)); | ||
|
||
tuples->resize(rows); | ||
|
||
EXPECT_EQ(0u, tuples->get(0,0)); | ||
EXPECT_EQ(0u, tuples->inc(0,0)); | ||
EXPECT_EQ(1u, tuples->get(0,0)); | ||
EXPECT_EQ(1u, tuples->atomic_inc(0,0)); | ||
EXPECT_EQ(2u, tuples->get(0,0)); | ||
} | ||
|
||
static const std::vector<uint64_t> bits = std::vector<uint64_t> {2, 3}; | ||
|
||
using testing::Types; | ||
|
||
typedef Types < | ||
TestType<false >, | ||
TestType<true > | ||
// BitCompressedVector<uint>, | ||
// BitCompressedVector<uint, StrategizedAllocator<uint, MemalignStrategy<16> > >, | ||
// BitCompressedVector<uint, StrategizedAllocator<uint, NumaNodeStrategy<NumaConfig> > >, | ||
// FixedLengthVector<uint>, | ||
// FixedLengthVector<uint, StrategizedAllocator<uint, MemalignStrategy<16> > >, | ||
// FixedLengthVector<uint, StrategizedAllocator<uint, NumaNodeStrategy<NumaConfig> > > | ||
> Vectors; | ||
|
||
TYPED_TEST_CASE(AttributeVectorTests, Vectors); | ||
|
||
TYPED_TEST(AttributeVectorTests, boundaries_test) { | ||
size_t cols = 2; | ||
size_t rows = 3; | ||
auto tuples = AttributeVectorFactory::getAttributeVector2<value_id_t>(cols, rows, TypeParam::compressed, bits); | ||
tuples->resize(rows); | ||
#ifdef EXPENSIVE_ASSERTIONS | ||
EXPECT_THROW(tuples->get(cols, 0), std::out_of_range); | ||
EXPECT_THROW(tuples->get(0, rows), std::out_of_range); | ||
EXPECT_THROW(tuples->get(cols, rows), std::out_of_range); | ||
#endif | ||
} | ||
|
||
TYPED_TEST(AttributeVectorTests, base_test) { | ||
|
||
auto tuples = AttributeVectorFactory::getAttributeVector2<value_id_t>(1, 3, TypeParam::compressed, bits); | ||
tuples->resize(3); | ||
|
||
tuples->set(0, 0, 2); | ||
tuples->set(0, 1, 3); | ||
tuples->set(0, 2, 1); | ||
|
||
ASSERT_EQ(3u, tuples->size()); | ||
|
||
ASSERT_EQ(2u, tuples->get(0, 0)); | ||
ASSERT_EQ(3u, tuples->get(0, 1)); | ||
ASSERT_EQ(1u, tuples->get(0, 2)); | ||
|
||
tuples->clear(); | ||
|
||
ASSERT_EQ(0u, tuples->size()); | ||
} | ||
|
||
TYPED_TEST(AttributeVectorTests, two_columns) { | ||
auto tuples = AttributeVectorFactory::getAttributeVector2<value_id_t>(2, 3, TypeParam::compressed, bits); | ||
tuples->resize(3); | ||
|
||
tuples->set(0, 0, 2); | ||
tuples->set(0, 1, 3); | ||
tuples->set(0, 2, 1); | ||
|
||
tuples->set(1, 0, 5); | ||
tuples->set(1, 1, 7); | ||
|
||
ASSERT_EQ(3u, tuples->size()); | ||
|
||
ASSERT_EQ(2u, tuples->get(0, 0)); | ||
ASSERT_EQ(3u, tuples->get(0, 1)); | ||
ASSERT_EQ(1u, tuples->get(0, 2)); | ||
|
||
ASSERT_EQ(5u, tuples->get(1, 0)); | ||
ASSERT_EQ(7u, tuples->get(1, 1)); | ||
|
||
tuples->clear(); | ||
|
||
ASSERT_EQ(0u, tuples->size()); | ||
} | ||
|
||
TYPED_TEST(AttributeVectorTests, copy_test) { | ||
|
||
auto tuples = AttributeVectorFactory::getAttributeVector2<value_id_t>(2, 3, TypeParam::compressed, bits); | ||
tuples->resize(3); | ||
|
||
tuples->set(0, 0, 2); | ||
tuples->set(0, 1, 3); | ||
tuples->set(0, 2, 1); | ||
|
||
tuples->set(1, 0, 5); | ||
tuples->set(1, 1, 7); | ||
|
||
std::shared_ptr<BaseAttributeVector<uint32_t>> copy = tuples->copy(); | ||
tuples->clear(); | ||
|
||
ASSERT_EQ(3u, copy->size()); | ||
|
||
ASSERT_EQ(2u, copy->get(0, 0)); | ||
ASSERT_EQ(3u, copy->get(0, 1)); | ||
ASSERT_EQ(1u, copy->get(0, 2)); | ||
|
||
ASSERT_EQ(5u, copy->get(1, 0)); | ||
ASSERT_EQ(7u, copy->get(1, 1)); | ||
|
||
copy->clear(); | ||
|
||
ASSERT_EQ(0u, copy->size()); | ||
#include <limits> | ||
|
||
#include "storage/storage_types.h" | ||
#include "storage/BitCompressedVector.h" | ||
#include "storage/FixedLengthVector.h" | ||
|
||
TEST(BitCompressedTests, set_retrieve_bits) { | ||
std::vector<uint64_t> bits {1, 2, 4, 8, 13}; | ||
BitCompressedVector<value_id_t> tuples(5, 2, bits); | ||
tuples.resize(2); | ||
auto col = 0; | ||
for (auto bit: bits) { | ||
auto maxval = (1 << bit) - 1; // Maximum value that can be stored is 2^bit-1 | ||
tuples.set(col, 0, 0); | ||
tuples.set(col, 1, maxval); | ||
EXPECT_EQ(0u, tuples.get(col, 0)); | ||
EXPECT_EQ(maxval, tuples.get(col, 1)); | ||
col++; | ||
} | ||
} | ||
|
||
TYPED_TEST(AttributeVectorTests, empty_does_not_fail_when_reserve_test) { | ||
auto tuples = AttributeVectorFactory::getAttributeVector2<value_id_t>(1, 0, TypeParam::compressed, bits); | ||
tuples->resize(3); | ||
|
||
// when adding three elements | ||
tuples->set(0, 0, 2); | ||
tuples->set(0, 1, 3); | ||
tuples->set(0, 2, 1); | ||
|
||
ASSERT_EQ(3u, tuples->size()); | ||
|
||
ASSERT_EQ(2u, tuples->get(0, 0)); | ||
ASSERT_EQ(3u, tuples->get(0, 1)); | ||
ASSERT_EQ(1u, tuples->get(0, 2)); | ||
TEST(BitCompressedTests, empty_size_does_not_change_with_reserve) { | ||
BitCompressedVector<value_id_t> tuples(1, 1, {1}); | ||
ASSERT_EQ(0u, tuples.size()); | ||
ASSERT_EQ(64u, tuples.capacity()); | ||
tuples.reserve(3); | ||
ASSERT_EQ(0u, tuples.size()); | ||
ASSERT_EQ(64u, tuples.capacity()); | ||
tuples.reserve(65); | ||
ASSERT_EQ(0u, tuples.size()); | ||
ASSERT_EQ(128u, tuples.capacity()); | ||
} | ||
|
||
TYPED_TEST(AttributeVectorTests, empty_size_does_not_change_with_reserve) { | ||
|
||
auto tuples = AttributeVectorFactory::getAttributeVector2<value_id_t>(1, 1, TypeParam::compressed, std::vector<uint64_t> {1}); | ||
ASSERT_EQ(0u, tuples->size()); | ||
if (TypeParam::compressed) | ||
ASSERT_EQ(64u, tuples->capacity()); | ||
else | ||
ASSERT_EQ(1u, tuples->capacity()); | ||
tuples->reserve(3); | ||
ASSERT_EQ(0u, tuples->size()); | ||
if (TypeParam::compressed) | ||
ASSERT_EQ(64u, tuples->capacity()); | ||
else | ||
ASSERT_EQ(3u, tuples->capacity()); | ||
TEST(FixedLengthVectorTest, increment_test) { | ||
size_t cols = 1; | ||
size_t rows = 3; | ||
|
||
FixedLengthVector<value_id_t> tuples(cols, rows); | ||
tuples.resize(rows); | ||
EXPECT_EQ(0u, tuples.get(0,0)); | ||
EXPECT_EQ(0u, tuples.inc(0,0)); | ||
EXPECT_EQ(1u, tuples.get(0,0)); | ||
EXPECT_EQ(1u, tuples.atomic_inc(0,0)); | ||
EXPECT_EQ(2u, tuples.get(0,0)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.