void ConstructionTest(stxxl::vector<unsigned> lengths, std::vector<unsigned> offsets) { BOOST_ASSERT(lengths.size() == offsets.size() - 1); TestRangeTable table(lengths); for (unsigned i = 0; i < lengths.size(); i++) { auto range = table.GetRange(i); BOOST_CHECK_EQUAL(range.front(), offsets[i]); BOOST_CHECK_EQUAL(range.back() + 1, offsets[i + 1]); } }
bool serializeVector(std::ofstream &out_stream, const stxxl::vector<simple_type> &data) { const std::uint64_t size = data.size(); out_stream.write(reinterpret_cast<const char *>(&size), sizeof(size)); simple_type write_buffer[WRITE_BLOCK_BUFFER_SIZE]; std::size_t buffer_len = 0; for (const auto entry : data) { write_buffer[buffer_len++] = entry; if (buffer_len >= WRITE_BLOCK_BUFFER_SIZE) { out_stream.write(reinterpret_cast<const char *>(write_buffer), WRITE_BLOCK_BUFFER_SIZE * sizeof(simple_type)); buffer_len = 0; } } // write remaining entries if (buffer_len > 0) out_stream.write(reinterpret_cast<const char *>(write_buffer), buffer_len * sizeof(simple_type)); return static_cast<bool>(out_stream); }
unsigned_type get_num_errors() { return errors.size(); }