Read a bloom filter window from a stream. */
| 121 | |
| 122 | /** Read a bloom filter window from a stream. */ |
| 123 | void read(std::istream& in, BitwiseOp readOp = BITWISE_OVERWRITE) |
| 124 | { |
| 125 | Bloom::FileHeader header = Bloom::readHeader(in); |
| 126 | assert(in); |
| 127 | |
| 128 | m_fullBloomSize = header.fullBloomSize; |
| 129 | m_startBitPos = header.startBitPos; |
| 130 | m_endBitPos = header.endBitPos; |
| 131 | |
| 132 | if (m_hashSeed != header.hashSeed) { |
| 133 | if (readOp == BITWISE_OVERWRITE) { |
| 134 | m_hashSeed = header.hashSeed; |
| 135 | } else { |
| 136 | std::cerr << "error: can't union/intersect bloom filters with " |
| 137 | << "different hash seed values\n"; |
| 138 | exit(EXIT_FAILURE); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | size_t bits = header.endBitPos - header.startBitPos + 1; |
| 143 | |
| 144 | if (m_size != bits) { |
| 145 | if (readOp == BITWISE_OVERWRITE) { |
| 146 | Konnector::BloomFilter::resize(bits); |
| 147 | } else { |
| 148 | std::cerr << "error: can't union/intersect bloom filters with " |
| 149 | << "different sizes\n"; |
| 150 | exit(EXIT_FAILURE); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | readBits(in, m_array, bits, 0, readOp); |
| 155 | |
| 156 | assert(in); |
| 157 | } |
| 158 | |
| 159 | /** Write a bloom filter window to a stream. */ |
| 160 | void write(std::ostream& out) const |
no test coverage detected