14 This class is used to construct a RLEVector.
17 class RLEEncoder : public VectorEncoder
20 RLEEncoder(usint block_bytes, usint superblock_size = VectorEncoder::SUPERBLOCK_SIZE);
23 // void setBit(usint value);
24 void setRun(usint start, usint len);
26 inline void RLEncode(usint diff, usint len)
28 this->size += diff + len - 1;
30 this->buffer->writeDeltaCode(diff);
31 this->buffer->writeDeltaCode(len);
37 This is a run-length encoded bit vector using delta coding.
40 class RLEVector : public BitVector
43 RLEVector(std::ifstream& file);
44 RLEVector(RLEEncoder& encoder, usint universe_size);
47 //--------------------------------------------------------------------------
49 usint rank(usint value, bool at_least = false);
51 usint select(usint index);
54 pair_type valueAfter(usint value);
55 pair_type nextValue();
57 pair_type selectRun(usint index, usint max_length);
58 pair_type selectNextRun(usint max_length);
60 bool isSet(usint value);
62 //--------------------------------------------------------------------------
69 inline void valueLoop(usint value)
71 this->getSample(this->sampleForValue(value));
74 if(this->val >= value) { return; }
75 while(this->cur < this->block_items)
77 this->val += this->buffer->readDeltaCode();
79 this->run = this->buffer->readDeltaCode() - 1;
80 if(this->val >= value) { break; }
82 this->cur += this->run;
83 this->val += this->run;
84 if(this->val >= value)
86 this->run = this->val - value;
88 this->cur -= this->run;
100 #endif // RLEVECTOR_H