Commit 0e609980 authored by Jens Dieskau's avatar Jens Dieskau
Browse files

Correct size in byte calculation and code cleanup

parent 1f1a98f3
......@@ -496,7 +496,14 @@ T& DeltaCompressedColumn<T>::operator[](const int id)
template<class T>
unsigned int DeltaCompressedColumn<T>::getSizeinBytes() const throw()
{
return lookup.size() * sizeof(uint8_t) + sizeof(lookup);
if (typeid(T) == typeid(std::string)) {
int size = 0;
for (auto iter = dictionary.begin(), end = dictionary.end(); iter != end; iter++) {
size += sizeof(*iter);
}
return size + lookup.size() * sizeof(uint8_t) + sizeof(lookup);
}
return lookup.size() * sizeof(uint8_t) + sizeof(lookup) + dictionary.size() * sizeof(T);
}
/***************** End of Implementation Section ******************/
......
......@@ -511,7 +511,14 @@ T& DictionaryCompressedColumn<T>::operator[](const int id)
template<class T>
unsigned int DictionaryCompressedColumn<T>::getSizeinBytes() const throw()
{
return lookup.size() * sizeof(uint8_t) + sizeof(lookup);
if (typeid(T) == typeid(std::string)) {
int size = 0;
for (auto iter = dictionary.begin(), end = dictionary.end(); iter != end; iter++) {
size += sizeof(*iter);
}
return size + lookup.size() * sizeof(uint8_t) + sizeof(lookup);
}
return lookup.size() * sizeof(uint8_t) + sizeof(lookup) + dictionary.size() * sizeof(T);
}
/***************** End of Implementation Section ******************/
......
......@@ -337,7 +337,6 @@ unsigned int RunLengthCompressedColumn<T>::getSizeinBytes() const throw()
if (typeid(T) == typeid(std::string)) {
int size = 0;
for (auto iter = data.begin(), end = data.end(); iter != end; iter++) {
//std::string tmp( reinterpret_cast<std::string>(std::get<0>(*iter)));
size += sizeof(std::get<0>(*iter));
}
return size + (data.size() * sizeof(uint8_t));
......
......@@ -50,60 +50,60 @@ int main()
std::cout << "[Dictionary] Unitests Passed!" << std::endl;
// /**************
// * RUN LENGTH *
// *************/
// std::cout << std::endl << "Start testing run length compression: " << std::endl;
//
// /*create an object of your implemented column, and pass the smart pointer to the unittests*/
// boost::shared_ptr<RunLengthCompressedColumn<int> > col_run(new RunLengthCompressedColumn<int>("int column", INT));
// if (!unittest(col_run)) {
// std::cout << "At least one Unittest Failed!" << std::endl;
// return -1;
// }
// std::cout << "Unitests Passed!\n" << std::endl;
//
// boost::shared_ptr<RunLengthCompressedColumn<float> > col_run_float(new RunLengthCompressedColumn<float>("float column", FLOAT));
// if (!unittest(col_run_float)) {
// std::cout << "At least one Unittest Failed!" << std::endl;
// return -1;
// }
// std::cout << "Unitests Passed!\n" << std::endl;
//
// boost::shared_ptr<RunLengthCompressedColumn<std::string> > col_run_string(new RunLengthCompressedColumn<std::string>("string column", VARCHAR));
// if (!unittest(col_run_string)) {
// std::cout << "At least one Unittest Failed!" << std::endl;
// return -1;
// }
// std::cout << "[RunLength] Unitests Passed!" << std::endl;
/**************
* RUN LENGTH *
*************/
std::cout << std::endl << "Start testing run length compression: " << std::endl;
/*create an object of your implemented column, and pass the smart pointer to the unittests*/
boost::shared_ptr<RunLengthCompressedColumn<int> > col_run(new RunLengthCompressedColumn<int>("int column", INT));
if (!unittest(col_run)) {
std::cout << "At least one Unittest Failed!" << std::endl;
return -1;
}
std::cout << "Unitests Passed!\n" << std::endl;
boost::shared_ptr<RunLengthCompressedColumn<float> > col_run_float(new RunLengthCompressedColumn<float>("float column", FLOAT));
if (!unittest(col_run_float)) {
std::cout << "At least one Unittest Failed!" << std::endl;
return -1;
}
std::cout << "Unitests Passed!\n" << std::endl;
boost::shared_ptr<RunLengthCompressedColumn<std::string> > col_run_string(new RunLengthCompressedColumn<std::string>("string column", VARCHAR));
if (!unittest(col_run_string)) {
std::cout << "At least one Unittest Failed!" << std::endl;
return -1;
}
std::cout << "[RunLength] Unitests Passed!" << std::endl;
/********************
* DELTA DICTIONARY *
********************/
// std::cout << std::endl << "Start testing delta dictionary compression: " << std::endl;
//
// /*create an object of your implemented column, and pass the smart pointer to the unittests*/
// boost::shared_ptr<DeltaCompressedColumn<int> > col_delta(new DeltaCompressedColumn<int>("int column", INT));
// if (!unittest(col_delta)) {
// std::cout << "At least one Unittest Failed!" << std::endl;
// return -1;
// }
// std::cout << "Unitests Passed!\n" << std::endl;
//
// boost::shared_ptr<DeltaCompressedColumn<float> > col_delta_float(new DeltaCompressedColumn<float>("float column", FLOAT));
// if (!unittest(col_delta_float)) {
// std::cout << "At least one Unittest Failed!" << std::endl;
// return -1;
// }
// std::cout << "Unitests Passed!\n" << std::endl;
//
// boost::shared_ptr<DeltaCompressedColumn<std::string> > col_delta_string(new DeltaCompressedColumn<std::string>("string column", VARCHAR));
// if (!unittest(col_delta_string)) {
// std::cout << "At least one Unittest Failed!" << std::endl;
// return -1;
// }
// std::cout << "[DeltaDict] Unitests Passed!" << std::endl;
std::cout << std::endl << "Start testing delta dictionary compression: " << std::endl;
/*create an object of your implemented column, and pass the smart pointer to the unittests*/
boost::shared_ptr<DeltaCompressedColumn<int> > col_delta(new DeltaCompressedColumn<int>("int column", INT));
if (!unittest(col_delta)) {
std::cout << "At least one Unittest Failed!" << std::endl;
return -1;
}
std::cout << "Unitests Passed!\n" << std::endl;
boost::shared_ptr<DeltaCompressedColumn<float> > col_delta_float(new DeltaCompressedColumn<float>("float column", FLOAT));
if (!unittest(col_delta_float)) {
std::cout << "At least one Unittest Failed!" << std::endl;
return -1;
}
std::cout << "Unitests Passed!\n" << std::endl;
boost::shared_ptr<DeltaCompressedColumn<std::string> > col_delta_string(new DeltaCompressedColumn<std::string>("string column", VARCHAR));
if (!unittest(col_delta_string)) {
std::cout << "At least one Unittest Failed!" << std::endl;
return -1;
}
std::cout << "[DeltaDict] Unitests Passed!" << std::endl;
// /****** BULK UPDATE TEST ******/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment