MCPcopy Create free account
hub / github.com/ElementsProject/elements / Add

Method Add

src/leveldb/table/table_builder.cc:94–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94void TableBuilder::Add(const Slice& key, const Slice& value) {
95 Rep* r = rep_;
96 assert(!r->closed);
97 if (!ok()) return;
98 if (r->num_entries > 0) {
99 assert(r->options.comparator->Compare(key, Slice(r->last_key)) > 0);
100 }
101
102 if (r->pending_index_entry) {
103 assert(r->data_block.empty());
104 r->options.comparator->FindShortestSeparator(&r->last_key, key);
105 std::string handle_encoding;
106 r->pending_handle.EncodeTo(&handle_encoding);
107 r->index_block.Add(r->last_key, Slice(handle_encoding));
108 r->pending_index_entry = false;
109 }
110
111 if (r->filter_block != nullptr) {
112 r->filter_block->AddKey(key);
113 }
114
115 r->last_key.assign(key.data(), key.size());
116 r->num_entries++;
117 r->data_block.Add(key, value);
118
119 const size_t estimated_block_size = r->data_block.CurrentSizeEstimate();
120 if (estimated_block_size >= r->options.block_size) {
121 Flush();
122 }
123}
124
125void TableBuilder::Flush() {
126 Rep* r = rep_;

Callers 1

FinishMethod · 0.45

Calls 11

okFunction · 0.85
CurrentSizeEstimateMethod · 0.80
SliceClass · 0.50
CompareMethod · 0.45
emptyMethod · 0.45
FindShortestSeparatorMethod · 0.45
EncodeToMethod · 0.45
AddKeyMethod · 0.45
assignMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected