const Comparator* user_comparator, uint32_t cuckoo_block_size,
bool use_module_hash, bool identity_as_first_hash,
uint64_t (*get_slice_hash)(const Slice&, uint32_t, uint64_t),
- uint32_t column_family_id, const std::string& column_family_name)
+ uint32_t column_family_id, const std::string& column_family_name,
+ const std::string& db_id, const std::string& db_session_id)
: num_hash_func_(2),
file_(file),
max_hash_table_ratio_(max_hash_table_ratio),
properties_.filter_size = 0;
properties_.column_family_id = column_family_id;
properties_.column_family_name = column_family_name;
+ properties_.db_id = db_id;
+ properties_.db_session_id = db_session_id;
}
void CuckooTableBuilder::Add(const Slice& key, const Slice& value) {
return;
}
ParsedInternalKey ikey;
- if (!ParseInternalKey(key, &ikey)) {
- status_ = Status::Corruption("Unable to parse key into inernal key.");
+ Status pik_status =
+ ParseInternalKey(key, &ikey, false /* log_err_key */); // TODO
+ if (!pik_status.ok()) {
+ status_ = Status::Corruption("Unable to parse key into internal key. ",
+ pik_status.getState());
return;
}
if (ikey.type != kTypeDeletion && ikey.type != kTypeValue) {
hash_table_size_ =
static_cast<uint64_t>(num_entries_ / max_hash_table_ratio_);
}
- s = MakeHashTable(&buckets);
- if (!s.ok()) {
- return s;
+ status_ = MakeHashTable(&buckets);
+ if (!status_.ok()) {
+ return status_;
}
// Determine unused_user_key to fill empty buckets.
std::string unused_user_key = smallest_user_key_;
uint32_t num_added = 0;
for (auto& bucket : buckets) {
if (bucket.vector_idx == kMaxVectorIdx) {
- s = file_->Append(Slice(unused_bucket));
+ io_status_ = file_->Append(Slice(unused_bucket));
} else {
++num_added;
- s = file_->Append(GetKey(bucket.vector_idx));
- if (s.ok()) {
+ io_status_ = file_->Append(GetKey(bucket.vector_idx));
+ if (io_status_.ok()) {
if (value_size_ > 0) {
- s = file_->Append(GetValue(bucket.vector_idx));
+ io_status_ = file_->Append(GetValue(bucket.vector_idx));
}
}
}
- if (!s.ok()) {
- return s;
+ if (!io_status_.ok()) {
+ status_ = io_status_;
+ return status_;
}
}
assert(num_added == NumEntries());
BlockHandle property_block_handle;
property_block_handle.set_offset(offset);
property_block_handle.set_size(property_block.size());
- s = file_->Append(property_block);
+ io_status_ = file_->Append(property_block);
offset += property_block.size();
- if (!s.ok()) {
- return s;
+ if (!io_status_.ok()) {
+ status_ = io_status_;
+ return status_;
}
meta_index_builder.Add(kPropertiesBlock, property_block_handle);
BlockHandle meta_index_block_handle;
meta_index_block_handle.set_offset(offset);
meta_index_block_handle.set_size(meta_index_block.size());
- s = file_->Append(meta_index_block);
- if (!s.ok()) {
- return s;
+ io_status_ = file_->Append(meta_index_block);
+ if (!io_status_.ok()) {
+ status_ = io_status_;
+ return status_;
}
Footer footer(kCuckooTableMagicNumber, 1);
footer.set_index_handle(BlockHandle::NullBlockHandle());
std::string footer_encoding;
footer.EncodeTo(&footer_encoding);
- s = file_->Append(footer_encoding);
-
- if (file_ != nullptr) {
- file_checksum_ = file_->GetFileChecksum();
- }
- return s;
+ io_status_ = file_->Append(footer_encoding);
+ status_ = io_status_;
+ return status_;
}
void CuckooTableBuilder::Abandon() {
return null_found;
}
+std::string CuckooTableBuilder::GetFileChecksum() const {
+ if (file_ != nullptr) {
+ return file_->GetFileChecksum();
+ } else {
+ return kUnknownFileChecksum;
+ }
+}
+
const char* CuckooTableBuilder::GetFileChecksumFuncName() const {
if (file_ != nullptr) {
return file_->GetFileChecksumFuncName();
} else {
- return kUnknownFileChecksumFuncName.c_str();
+ return kUnknownFileChecksumFuncName;
}
}