libfoedus-core
FOEDUS Core Library
masstree_storage.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015, Hewlett-Packard Development Company, LP.
3  * This program is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the Free
5  * Software Foundation; either version 2 of the License, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11  * more details. You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  *
15  * HP designates this particular file as subject to the "Classpath" exception
16  * as provided by HP in the LICENSE.txt file that accompanied this code.
17  */
19 
20 #include <glog/logging.h>
21 
22 #include <iostream>
23 #include <string>
24 
31 #include "foedus/thread/thread.hpp"
32 
33 namespace foedus {
34 namespace storage {
35 namespace masstree {
36 
39  : Storage<MasstreeStorageControlBlock>(engine, control_block) {
41 }
43  : Storage<MasstreeStorageControlBlock>(engine, control_block) {
45 }
47  : Storage<MasstreeStorageControlBlock>(engine, id) {}
49  : Storage<MasstreeStorageControlBlock>(engine, name) {}
51  : Storage<MasstreeStorageControlBlock>(other.engine_, other.control_block_) {
52 }
54  engine_ = other.engine_;
56  return *this;
57 }
58 
60  return &control_block_->meta_;
61 }
62 
64  return MasstreeStoragePimpl(this).create(static_cast<const MasstreeMetadata&>(metadata));
65 }
67  return MasstreeStoragePimpl(this).load(snapshot_block);
68 }
70 
71 std::ostream& operator<<(std::ostream& o, const MasstreeStorage& v) {
72  o << "<MasstreeStorage>"
73  << "<id>" << v.get_id() << "</id>"
74  << "<name>" << v.get_name() << "</name>"
75  << "</MasstreeStorage>";
76  return o;
77 }
78 
80  thread::Thread* context,
81  const void* key,
82  KeyLength key_length,
83  void* payload,
84  PayloadLength* payload_capacity,
85  bool read_only) {
86  // Automatically switch to faster implementation for 8-byte keys
87  if (key_length == sizeof(KeySlice)) {
88  KeySlice slice = normalize_be_bytes_full(key);
89  return get_record_normalized(context, slice, payload, payload_capacity, read_only);
90  }
91 
92  MasstreeStoragePimpl pimpl(this);
93  RecordLocation location;
95  context,
96  key,
97  key_length,
98  !read_only,
99  &location));
100  return pimpl.retrieve_general(
101  context,
102  location,
103  payload,
104  payload_capacity);
105 }
106 
108  thread::Thread* context,
109  const void* key,
110  KeyLength key_length,
111  void* payload,
112  PayloadLength payload_offset,
113  PayloadLength payload_count,
114  bool read_only) {
115  // Automatically switch to faster implementation for 8-byte keys
116  if (key_length == sizeof(KeySlice)) {
117  KeySlice slice = normalize_be_bytes_full(key);
119  context, slice, payload, payload_offset, payload_count, read_only);
120  }
121 
122  MasstreeStoragePimpl pimpl(this);
123  RecordLocation location;
125  context,
126  key,
127  key_length,
128  !read_only,
129  &location));
130  return pimpl.retrieve_part_general(
131  context,
132  location,
133  payload,
134  payload_offset,
135  payload_count);
136 }
137 
138 template <typename PAYLOAD>
140  thread::Thread* context,
141  const void* key,
142  KeyLength key_length,
143  PAYLOAD* payload,
144  PayloadLength payload_offset,
145  bool read_only) {
146  // Automatically switch to faster implementation for 8-byte keys
147  if (key_length == sizeof(KeySlice)) {
148  KeySlice slice = normalize_be_bytes_full(key);
149  return get_record_primitive_normalized<PAYLOAD>(
150  context, slice, payload, payload_offset, read_only);
151  }
152 
153  MasstreeStoragePimpl pimpl(this);
154  RecordLocation location;
156  context,
157  key,
158  key_length,
159  !read_only,
160  &location));
161  return pimpl.retrieve_part_general(
162  context,
163  location,
164  payload,
165  payload_offset,
166  sizeof(PAYLOAD));
167 }
168 
170  thread::Thread* context,
171  KeySlice key,
172  void* payload,
173  PayloadLength* payload_capacity,
174  bool read_only) {
175  MasstreeStoragePimpl pimpl(this);
176  RecordLocation location;
178  context,
179  key,
180  !read_only,
181  &location));
182  return pimpl.retrieve_general(
183  context,
184  location,
185  payload,
186  payload_capacity);
187 }
188 
190  thread::Thread* context,
191  KeySlice key,
192  void* payload,
193  PayloadLength payload_offset,
194  PayloadLength payload_count,
195  bool read_only) {
196  MasstreeStoragePimpl pimpl(this);
197  RecordLocation location;
199  context,
200  key,
201  !read_only,
202  &location));
203  return pimpl.retrieve_part_general(
204  context,
205  location,
206  payload,
207  payload_offset,
208  payload_count);
209 }
210 
211 template <typename PAYLOAD>
213  thread::Thread* context,
214  KeySlice key,
215  PAYLOAD* payload,
216  PayloadLength payload_offset,
217  bool read_only) {
218  MasstreeStoragePimpl pimpl(this);
219  RecordLocation location;
221  context,
222  key,
223  !read_only,
224  &location));
225  return pimpl.retrieve_part_general(
226  context,
227  location,
228  payload,
229  payload_offset,
230  sizeof(PAYLOAD));
231 }
232 
234  PayloadLength payload_count,
235  PayloadLength physical_payload_hint) {
236  ASSERT_ND(physical_payload_hint >= payload_count); // if not, most likely misuse.
237  if (physical_payload_hint < payload_count) {
238  physical_payload_hint = payload_count;
239  }
240  if (physical_payload_hint > kMaxPayloadLength) {
241  physical_payload_hint = kMaxPayloadLength;
242  }
243  physical_payload_hint = assorted::align8(physical_payload_hint);
244  return physical_payload_hint;
245 }
246 
248  thread::Thread* context,
249  const void* key,
250  KeyLength key_length,
251  const void* payload,
252  PayloadLength payload_count,
253  PayloadLength physical_payload_hint) {
254  // Automatically switch to faster implementation for 8-byte keys
255  if (key_length == sizeof(KeySlice)) {
256  KeySlice slice = normalize_be_bytes_full(key);
257  return insert_record_normalized(context, slice, payload, payload_count, physical_payload_hint);
258  }
259 
260  if (UNLIKELY(payload_count > kMaxPayloadLength)) {
262  }
263  physical_payload_hint = adjust_payload_hint(payload_count, physical_payload_hint);
264  MasstreeStoragePimpl pimpl(this);
265  RecordLocation location;
267  context,
268  key,
269  key_length,
270  payload_count,
271  physical_payload_hint,
272  &location));
273  ASSERT_ND(location.is_found()); // contract of reserve_record
274  return pimpl.insert_general(
275  context,
276  location,
277  key,
278  key_length,
279  payload,
280  payload_count);
281 }
282 
284  thread::Thread* context,
285  KeySlice key,
286  const void* payload,
287  PayloadLength payload_count,
288  PayloadLength physical_payload_hint) {
289  if (UNLIKELY(payload_count > kMaxPayloadLength)) {
291  }
292  physical_payload_hint = adjust_payload_hint(payload_count, physical_payload_hint);
293  MasstreeStoragePimpl pimpl(this);
294  RecordLocation location;
296  context,
297  key,
298  payload_count,
299  physical_payload_hint,
300  &location));
301  ASSERT_ND(location.is_found()); // contract of reserve_record
302  uint64_t be_key = assorted::htobe<uint64_t>(key);
303  return pimpl.insert_general(
304  context,
305  location,
306  &be_key,
307  sizeof(be_key),
308  payload,
309  payload_count);
310 }
311 
313  thread::Thread* context,
314  const void* key,
315  KeyLength key_length) {
316  // Automatically switch to faster implementation for 8-byte keys
317  if (key_length == sizeof(KeySlice)) {
318  KeySlice slice = normalize_be_bytes_full(key);
319  return delete_record_normalized(context, slice);
320  }
321 
322  MasstreeStoragePimpl pimpl(this);
323  RecordLocation location;
325  context,
326  key,
327  key_length,
328  true,
329  &location));
330  return pimpl.delete_general(context, location, key, key_length);
331 }
332 
334  thread::Thread* context,
335  KeySlice key) {
336  MasstreeStoragePimpl pimpl(this);
337  RecordLocation location;
339  context,
340  key,
341  true,
342  &location));
343  uint64_t be_key = assorted::htobe<uint64_t>(key);
344  return pimpl.delete_general(context, location, &be_key, sizeof(be_key));
345 }
346 
348  thread::Thread* context,
349  const void* key,
350  KeyLength key_length,
351  const void* payload,
352  PayloadLength payload_count,
353  PayloadLength physical_payload_hint) {
354  // Automatically switch to faster implementation for 8-byte keys
355  if (key_length == sizeof(KeySlice)) {
356  KeySlice slice = normalize_be_bytes_full(key);
357  return upsert_record_normalized(context, slice, payload, payload_count, physical_payload_hint);
358  }
359 
360  if (UNLIKELY(payload_count > kMaxPayloadLength)) {
362  }
363  physical_payload_hint = adjust_payload_hint(payload_count, physical_payload_hint);
364  MasstreeStoragePimpl pimpl(this);
365  RecordLocation location;
367  context,
368  key,
369  key_length,
370  payload_count,
371  physical_payload_hint,
372  &location));
373  ASSERT_ND(location.is_found()); // contract of reserve_record
374  return pimpl.upsert_general(
375  context,
376  location,
377  key,
378  key_length,
379  payload,
380  payload_count);
381 }
382 
384  thread::Thread* context,
385  KeySlice key,
386  const void* payload,
387  PayloadLength payload_count,
388  PayloadLength physical_payload_hint) {
389  if (UNLIKELY(payload_count > kMaxPayloadLength)) {
391  }
392  physical_payload_hint = adjust_payload_hint(payload_count, physical_payload_hint);
393  MasstreeStoragePimpl pimpl(this);
394  RecordLocation location;
396  context,
397  key,
398  payload_count,
399  physical_payload_hint,
400  &location));
401  ASSERT_ND(location.is_found()); // contract of reserve_record
402  uint64_t be_key = assorted::htobe<uint64_t>(key);
403  return pimpl.upsert_general(
404  context,
405  location,
406  &be_key,
407  sizeof(be_key),
408  payload,
409  payload_count);
410 }
411 
413  thread::Thread* context,
414  const void* key,
415  KeyLength key_length,
416  const void* payload,
417  PayloadLength payload_offset,
418  PayloadLength payload_count) {
419  // Automatically switch to faster implementation for 8-byte keys
420  if (key_length == sizeof(KeySlice)) {
421  KeySlice slice = normalize_be_bytes_full(key);
422  return overwrite_record_normalized(context, slice, payload, payload_offset, payload_count);
423  }
424 
425  MasstreeStoragePimpl pimpl(this);
426  RecordLocation location;
428  context,
429  key,
430  key_length,
431  true,
432  &location));
433  return pimpl.overwrite_general(
434  context,
435  location,
436  key,
437  key_length,
438  payload,
439  payload_offset,
440  payload_count);
441 }
442 
443 template <typename PAYLOAD>
445  thread::Thread* context,
446  const void* key,
447  KeyLength key_length,
448  PAYLOAD payload,
449  PayloadLength payload_offset) {
450  // Automatically switch to faster implementation for 8-byte keys
451  if (key_length == sizeof(KeySlice)) {
452  KeySlice slice = normalize_be_bytes_full(key);
453  return overwrite_record_primitive_normalized<PAYLOAD>(context, slice, payload, payload_offset);
454  }
455 
456  MasstreeStoragePimpl pimpl(this);
457  RecordLocation location;
459  context,
460  key,
461  key_length,
462  true,
463  &location));
464  return pimpl.overwrite_general(
465  context,
466  location,
467  key,
468  key_length,
469  &payload,
470  payload_offset,
471  sizeof(payload));
472 }
473 
475  thread::Thread* context,
476  KeySlice key,
477  const void* payload,
478  PayloadLength payload_offset,
479  PayloadLength payload_count) {
480  MasstreeStoragePimpl pimpl(this);
481  RecordLocation location;
483  context,
484  key,
485  true,
486  &location));
487  uint64_t be_key = assorted::htobe<uint64_t>(key);
488  return pimpl.overwrite_general(
489  context,
490  location,
491  &be_key,
492  sizeof(be_key),
493  payload,
494  payload_offset,
495  payload_count);
496 }
497 
498 template <typename PAYLOAD>
500  thread::Thread* context,
501  KeySlice key,
502  PAYLOAD payload,
503  PayloadLength payload_offset) {
504  MasstreeStoragePimpl pimpl(this);
505  RecordLocation location;
507  context,
508  key,
509  true,
510  &location));
511  uint64_t be_key = assorted::htobe<uint64_t>(key);
512  return pimpl.overwrite_general(
513  context,
514  location,
515  &be_key,
516  sizeof(be_key),
517  &payload,
518  payload_offset,
519  sizeof(payload));
520 }
521 
522 template <typename PAYLOAD>
524  thread::Thread* context,
525  const void* key,
526  KeyLength key_length,
527  PAYLOAD* value,
528  PayloadLength payload_offset) {
529  // Automatically switch to faster implementation for 8-byte keys
530  if (key_length == sizeof(KeySlice)) {
531  KeySlice slice = normalize_be_bytes_full(key);
532  return increment_record_normalized<PAYLOAD>(context, slice, value, payload_offset);
533  }
534 
535  MasstreeStoragePimpl pimpl(this);
536  RecordLocation location;
538  context,
539  key,
540  key_length,
541  true,
542  &location));
543  return pimpl.increment_general<PAYLOAD>(
544  context,
545  location,
546  key,
547  key_length,
548  value,
549  payload_offset);
550 }
551 
552 template <typename PAYLOAD>
554  thread::Thread* context,
555  KeySlice key,
556  PAYLOAD* value,
557  PayloadLength payload_offset) {
558  MasstreeStoragePimpl pimpl(this);
559  RecordLocation location;
561  context,
562  key,
563  true,
564  &location));
565  uint64_t be_key = assorted::htobe<uint64_t>(key);
566  return pimpl.increment_general<PAYLOAD>(
567  context,
568  location,
569  &be_key,
570  sizeof(be_key),
571  value,
572  payload_offset);
573 }
574 
576  return MasstreeStoragePimpl(this).verify_single_thread(context);
577 }
578 
580  Engine* engine,
581  bool volatile_only,
582  uint32_t max_pages) {
583  return MasstreeStoragePimpl(this).debugout_single_thread(engine, volatile_only, max_pages);
584 }
585 
588 }
589 
591  thread::Thread* context,
592  bool install_volatile,
593  bool cache_snapshot,
594  KeySlice from,
595  KeySlice to) {
597  context,
598  install_volatile,
599  cache_snapshot,
600  from,
601  to);
602 }
603 
605  thread::Thread* context,
606  uint32_t desired_count,
607  bool disable_no_record_split) {
608  MasstreeStoragePimpl impl(this);
609  return impl.fatify_first_root(context, desired_count, disable_no_record_split);
610 }
611 
613  Layer layer,
614  KeyLength key_length,
615  PayloadLength payload_length) {
616  PayloadLength aligned_payload = assorted::align8(payload_length);
617  KeyLength aligned_suffix = 0;
618  if (key_length > (layer + 1U) * sizeof(KeySlice)) {
619  aligned_suffix = assorted::align8(key_length - (layer + 1U) * sizeof(KeySlice));
620  }
622  / (aligned_suffix + aligned_payload + kBorderPageSlotSize);
624  return ret;
625 }
626 
627 // Explicit instantiations for each payload type
628 // @cond DOXYGEN_IGNORE
629 #define EXPIN_1(x) template ErrorCode MasstreeStorage::get_record_primitive< x > \
630  (thread::Thread* context, const void* key, KeyLength key_length, x* payload, \
631  PayloadLength payload_offset, bool read_only)
633 
634 #define EXPIN_2(x) template ErrorCode \
635  MasstreeStorage::get_record_primitive_normalized< x > \
636  (thread::Thread* context, KeySlice key, x* payload, PayloadLength payload_offset, bool read_only)
638 
639 #define EXPIN_3(x) template ErrorCode MasstreeStorage::overwrite_record_primitive< x > \
640  (thread::Thread* context, const void* key, KeyLength key_length, x payload, \
641  PayloadLength payload_offset)
643 
644 #define EXPIN_4(x) template ErrorCode \
645  MasstreeStorage::overwrite_record_primitive_normalized< x > \
646  (thread::Thread* context, KeySlice key, x payload, PayloadLength payload_offset)
648 
649 #define EXPIN_5(x) template ErrorCode MasstreeStorage::increment_record< x > \
650  (thread::Thread* context, const void* key, KeyLength key_length, x* value, \
651  PayloadLength payload_offset)
653 
654 #define EXPIN_6(x) template ErrorCode MasstreeStorage::increment_record_normalized< x > \
655  (thread::Thread* context, KeySlice key, x* value, PayloadLength payload_offset)
657 // @endcond
658 
659 } // namespace masstree
660 } // namespace storage
661 } // namespace foedus
ErrorCode get_record_normalized(thread::Thread *context, KeySlice key, void *payload, PayloadLength *payload_capacity, bool read_only)
Retrieves an entire record of the given primitive key in this Masstree.
T align8(T value)
8-alignment.
uint16_t PayloadLength
Represents a byte-length of a payload in this package.
Definition: masstree_id.hpp:92
ErrorStack fatify_first_root(thread::Thread *context, uint32_t desired_count, bool disable_no_record_split)
Defined in masstree_storage_fatify.cpp.
uint16_t SlotIndex
Index of a record in a (border) page.
std::ostream & operator<<(std::ostream &o, const MasstreeComposeContext::PathLevel &v)
ErrorCode reserve_record_normalized(thread::Thread *context, KeySlice key, PayloadLength payload_count, PayloadLength physical_payload_hint, RecordLocation *result)
ErrorCode locate_record_normalized(thread::Thread *context, KeySlice key, bool for_writes, RecordLocation *result)
Identifies page and record for the normalized key.
StorageType get_type() const
Returns the type of this storage.
Definition: storage.hpp:150
ErrorCode increment_record_normalized(thread::Thread *context, KeySlice key, PAYLOAD *value, PayloadLength payload_offset)
For primitive key.
uint32_t StorageId
Unique ID for storage.
Definition: storage_id.hpp:55
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
ErrorStack create(const Metadata &metadata)
Represents one thread running on one NUMA core.
Definition: thread.hpp:48
ErrorCode retrieve_part_general(thread::Thread *context, const RecordLocation &location, void *payload, PayloadLength payload_offset, PayloadLength payload_count)
const uint32_t kBorderPageSlotSize
Byte size of one slot in MasstreeBorderPage excluding slice information.
ErrorCode upsert_record(thread::Thread *context, const void *key, KeyLength key_length, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
Inserts a new record of the given key or replaces the existing one, or so-called upsert.
Declares all log types used in this storage type.
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
ErrorCode prefetch_pages_normalized(thread::Thread *context, bool install_volatile, bool cache_snapshot, KeySlice from, KeySlice to)
defined in masstree_storage_prefetch.cpp
Engine * engine_
Most attachable object stores an engine pointer (local engine), so we define it here.
Definition: attachable.hpp:107
ErrorCode overwrite_general(thread::Thread *context, const RecordLocation &location, const void *be_key, KeyLength key_length, const void *payload, PayloadLength payload_offset, PayloadLength payload_count)
implementation of overwrite_record family.
uint64_t KeySlice
Each key slice is an 8-byte integer.
ErrorCode retrieve_general(thread::Thread *context, const RecordLocation &location, void *payload, PayloadLength *payload_capacity)
implementation of get_record family.
0x0808 : "STORAGE: Payload of the record is too long" .
Definition: error_code.hpp:174
uint16_t KeyLength
Represents a byte-length of a key in this package.
Definition: masstree_id.hpp:69
ErrorCode upsert_record_normalized(thread::Thread *context, KeySlice key, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
Upserts a new record of the given primitive key in this Masstree.
KeySlice normalize_be_bytes_full(const void *be_bytes)
Convert a big-endian byte array of at least 8-bytes-length to KeySlice.
MasstreeStorage & operator=(const MasstreeStorage &other)
ErrorStack load(const StorageControlBlock &snapshot_block)
ErrorCode get_record_part_normalized(thread::Thread *context, KeySlice key, void *payload, PayloadLength payload_offset, PayloadLength payload_count, bool read_only)
Retrieves a part of the given primitive key in this Masstree.
Metadata of one storage.
Definition: metadata.hpp:58
uint64_t htobe< uint64_t >(uint64_t host_value)
Definition: endianness.hpp:87
Represents one key-value store.
Definition: storage.hpp:116
uint8_t Layer
Represents the depth of a B-trie layer.
Definition: masstree_id.hpp:42
ErrorCode get_record_primitive(thread::Thread *context, const void *key, KeyLength key_length, PAYLOAD *payload, PayloadLength payload_offset, bool read_only)
Retrieves a part of the given key in this Masstree as a primitive value.
ErrorCode insert_general(thread::Thread *context, const RecordLocation &location, const void *be_key, KeyLength key_length, const void *payload, PayloadLength payload_count)
implementation of insert_record family.
ErrorCode prefetch_pages_normalized(thread::Thread *context, bool install_volatile, bool cache_snapshot, KeySlice from=kInfimumSlice, KeySlice to=kSupremumSlice)
Prefetch data pages in this storage.
PayloadLength adjust_payload_hint(PayloadLength payload_count, PayloadLength physical_payload_hint)
MasstreeStorageControlBlock * control_block_
The shared data on shared memory that has been initialized in some SOC or master engine.
Definition: attachable.hpp:111
const StorageName & get_name() const
Returns the unique name of this storage.
Definition: storage.hpp:155
ErrorCode reserve_record(thread::Thread *context, const void *key, KeyLength key_length, PayloadLength payload_count, PayloadLength physical_payload_hint, RecordLocation *result)
Like locate_record(), this is also a logical operation.
bool exists() const
Returns whether this storage is already created.
Definition: storage.hpp:169
ErrorStack fatify_first_root(thread::Thread *context, uint32_t desired_count, bool disable_no_record_split=true)
Deliberately causes splits under the volatile root of first layer, or "fatify" it.
ErrorCode get_record(thread::Thread *context, const void *key, KeyLength key_length, void *payload, PayloadLength *payload_capacity, bool read_only)
Retrieves an entire record of the given key in this Masstree.
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
const SlotIndex kBorderPageMaxSlots
Maximum number of slots in one MasstreeBorderPage.
const uint32_t kBorderPageDataPartSize
Byte size of the record data part (data_) in MasstreeBorderPage.
static SlotIndex estimate_records_per_page(Layer layer, KeyLength key_length, PayloadLength payload_length)
StorageId get_id() const
Returns the unique ID of this storage.
Definition: storage.hpp:145
ErrorCode overwrite_record_normalized(thread::Thread *context, KeySlice key, const void *payload, PayloadLength payload_offset, PayloadLength payload_count)
Overwrites a part of one record of the given primitive key in this Masstree.
ErrorStack load(const StorageControlBlock &snapshot_block)
ErrorCode delete_record_normalized(thread::Thread *context, KeySlice key)
Deletes a record of the given primitive key from this Masstree.
const PayloadLength kMaxPayloadLength
Max length of a payload.
Definition: masstree_id.hpp:98
ErrorCode increment_general(thread::Thread *context, const RecordLocation &location, const void *be_key, KeyLength key_length, PAYLOAD *value, PayloadLength payload_offset)
implementation of increment_record family.
ErrorStack debugout_single_thread(Engine *engine, bool volatile_only=false, uint32_t max_pages=1024U)
A super-expensive and single-thread only debugging feature to write out gigantic human-readable texts...
ErrorStack verify_single_thread(thread::Thread *context)
ErrorCode delete_general(thread::Thread *context, const RecordLocation &location, const void *be_key, KeyLength key_length)
implementation of delete_record family.
ErrorCode delete_record(thread::Thread *context, const void *key, KeyLength key_length)
Deletes a record of the given key from this Masstree.
ErrorStack hcc_reset_all_temperature_stat()
Resets all volatile pages' temperature stat to be zero in this storage.
ErrorCode insert_record_normalized(thread::Thread *context, KeySlice key, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
Inserts a new record of the given primitive key in this Masstree.
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155
ErrorCode get_record_part(thread::Thread *context, const void *key, KeyLength key_length, void *payload, PayloadLength payload_offset, PayloadLength payload_count, bool read_only)
Retrieves a part of the given key in this Masstree.
ErrorCode increment_record(thread::Thread *context, const void *key, KeyLength key_length, PAYLOAD *value, PayloadLength payload_offset)
This one further optimizes overwrite methods for the frequent use case of incrementing some data in p...
ErrorStack hcc_reset_all_temperature_stat()
For stupid reasons (I'm lazy!) these are defined in _debug.cpp.
ErrorStack verify_single_thread(thread::Thread *context)
These are defined in masstree_storage_verify.cpp.
ErrorStack drop()
Storage-wide operations, such as drop, create, etc.
ErrorCode get_record_primitive_normalized(thread::Thread *context, KeySlice key, PAYLOAD *payload, PayloadLength payload_offset, bool read_only)
Retrieves a part of the given primitive key in this Masstree as a primitive value.
ErrorCode overwrite_record_primitive_normalized(thread::Thread *context, KeySlice key, PAYLOAD payload, PayloadLength payload_offset)
Overwrites a part of one record of the given primitive key in this Masstree as a primitive value...
ErrorStack create(const MasstreeMetadata &metadata)
#define INSTANTIATE_ALL_NUMERIC_TYPES(M)
INSTANTIATE_ALL_TYPES minus std::string.
ErrorCode overwrite_record(thread::Thread *context, const void *key, KeyLength key_length, const void *payload, PayloadLength payload_offset, PayloadLength payload_count)
Overwrites a part of one record of the given key in this Masstree.
#define UNLIKELY(x)
Hints that x is highly likely false.
Definition: compiler.hpp:104
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72
ErrorCode upsert_general(thread::Thread *context, const RecordLocation &location, const void *be_key, KeyLength key_length, const void *payload, PayloadLength payload_count)
implementation of upsert_record family.
ErrorCode overwrite_record_primitive(thread::Thread *context, const void *key, KeyLength key_length, PAYLOAD payload, PayloadLength payload_offset)
Overwrites a part of one record of the given key in this Masstree as a primitive value.
A base layout of shared data for all storage types.
Definition: storage.hpp:53
return value of MasstreeStoragePimpl::locate_record()/reserve_record().
ErrorCode insert_record(thread::Thread *context, const void *key, KeyLength key_length, const void *payload, PayloadLength payload_count) __attribute__((always_inline))
Inserts a new record of the given key in this Masstree.
ErrorCode
Enum of error codes defined in error_code.xmacro.
Definition: error_code.hpp:85
const MasstreeMetadata * get_masstree_metadata() const
ErrorCode locate_record(thread::Thread *context, const void *key, KeyLength key_length, bool for_writes, RecordLocation *result)
Identifies page and record for the key.
ErrorStack debugout_single_thread(Engine *engine, bool volatile_only, uint32_t max_pages)
These are defined in masstree_storage_debug.cpp.