Commit 7b5534eb authored by Jens Dieskau's avatar Jens Dieskau
Browse files

Begin of framing support

parent d6811073
......@@ -65,6 +65,9 @@ public:
const std::string name;
private:
std::vector<uint8_t>::iterator getLastFrameIter();
std::vector<T> dictionary;
size_t number_of_entries;
......@@ -93,6 +96,22 @@ DictionaryCompressedColumn<T>::~DictionaryCompressedColumn()
}
template<class T>
std::vector<uint8_t>::iterator DictionaryCompressedColumn<T>::getLastFrameIter()
{
auto iter = lookup.begin();
while (true) {
uint16_t frame_blocks = (*iter) << 8 | *iter;
if (iter + frame_blocks + 2 == lookup.end()) {
return iter;
}
iter += frame_blocks + 2; // skip to next header
}
}
template<class T>
bool DictionaryCompressedColumn<T>::insert(const boost::any& value)
{
......@@ -116,8 +135,10 @@ bool DictionaryCompressedColumn<T>::insert(const T& value)
}
number_of_entries++; // increase value counter
auto last_frame = getLastFrameIter();
int bit_length = index == 0 ? 1 : (int) ceil(log2(index+1));
int bit_length = index == 0 ? 1 : (int) ceil(log2(index + 1));
int number_of_blocks = (int) ceil((bit_length + 3) / 8.0) - 1; // excl. master block
// save master block header
......@@ -190,7 +211,7 @@ bool DictionaryCompressedColumn<T>::update(TID id, const boost::any& value)
dictionary.push_back(rvalue);
}
int bit_length = index == 0 ? 1 : (int) ceil(log2(index+1));
int bit_length = index == 0 ? 1 : (int) ceil(log2(index + 1));
uint8_t number_of_blocks_of_new = (int) ceil((bit_length + 3) / 8.0) - 1; // excl. master block
int i = 0;
......@@ -217,7 +238,7 @@ bool DictionaryCompressedColumn<T>::update(TID id, const boost::any& value)
// if new value has even more block than the old one...
for (int i = 0; i < number_of_blocks_of_new - number_of_blocks; ++i) {
iter = lookup.insert(iter, index >> ((number_of_blocks_of_new - 1 - (i+number_of_blocks)) * 8) & 0xFF);
iter = lookup.insert(iter, index >> ((number_of_blocks_of_new - 1 - (i + number_of_blocks)) * 8) & 0xFF);
iter++;
}
}
......@@ -258,7 +279,7 @@ bool DictionaryCompressedColumn<T>::remove(TID id)
uint8_t number_of_blocks = *iter >> 5;
if (i == id) { // found correct position
number_of_entries--;
lookup.erase(iter, iter + number_of_blocks+1);
lookup.erase(iter, iter + number_of_blocks + 1);
return true;;
} else {
//skip blocks
......
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