27 : file_(
file), use_compression_(true) {}
32 use_compression_ = use_compression;
35std::string RecordWriter::Compress(std::string
const& s)
const {
36 const unsigned long source_size = s.size();
37 const char* source = s.c_str();
39 unsigned long dsize = source_size + (source_size * 0.1f) + 16;
40 std::unique_ptr<char[]> destination(
new char[dsize]);
43 compress(
reinterpret_cast<unsigned char*
>(destination.get()), &dsize,
44 reinterpret_cast<const unsigned char*
>(source), source_size);
47 LOG(FATAL) <<
"Compress error occurred! Error code: " << result;
49 return std::string(destination.get(), dsize);
56void RecordReader::Uncompress(
const char*
const source, uint64_t source_size,
57 char*
const output_buffer,
58 uint64_t output_size)
const {
59 unsigned long result_size = output_size;
62 uncompress(
reinterpret_cast<unsigned char*
>(output_buffer), &result_size,
63 reinterpret_cast<const unsigned char*
>(source), source_size);
65 LOG(FATAL) <<
"Uncompress error occurred! Error code: " << result;
67 CHECK_LE(result_size,
static_cast<unsigned long>(output_size));