summaryrefslogtreecommitdiff
path: root/table/table_builder.cc
diff options
context:
space:
mode:
Diffstat (limited to 'table/table_builder.cc')
-rw-r--r--table/table_builder.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/table/table_builder.cc b/table/table_builder.cc
index 29a619d..ba3df9e 100644
--- a/table/table_builder.cc
+++ b/table/table_builder.cc
@@ -168,6 +168,20 @@ void TableBuilder::WriteBlock(BlockBuilder* block, BlockHandle* handle) {
}
break;
}
+
+ case kZstdCompression: {
+ std::string* compressed = &r->compressed_output;
+ if (port::Zstd_Compress(raw.data(), raw.size(), compressed) &&
+ compressed->size() < raw.size() - (raw.size() / 8u)) {
+ block_contents = *compressed;
+ } else {
+ // Zstd not supported, or compressed less than 12.5%, so just
+ // store uncompressed form
+ block_contents = raw;
+ type = kNoCompression;
+ }
+ break;
+ }
}
WriteRawBlock(block_contents, type, handle);
r->compressed_output.clear();