libfoedus-core
FOEDUS Core Library
foedus::storage::masstree::MasstreePartitionerData Struct Referencefinal

Dynamic information of one partitioner. More...

Detailed Description

Dynamic information of one partitioner.

Because partition keys are KeySlice, this is fixed-size like ArrayPartitionerData.

Definition at line 138 of file masstree_partitioner_impl.hpp.

#include <masstree_partitioner_impl.hpp>

Public Member Functions

 MasstreePartitionerData ()=delete
 
 ~MasstreePartitionerData ()=delete
 
uint16_t find_partition (const char *key, uint16_t key_length) const
 Returns the partition (node ID) that should contain the key. More...
 

Public Attributes

uint16_t partition_count_
 
KeySlice low_keys_ [kMaxIntermediatePointers]
 
uint16_t partitions_ [kMaxIntermediatePointers]
 

Constructor & Destructor Documentation

foedus::storage::masstree::MasstreePartitionerData::MasstreePartitionerData ( )
delete
foedus::storage::masstree::MasstreePartitionerData::~MasstreePartitionerData ( )
delete

Member Function Documentation

uint16_t foedus::storage::masstree::MasstreePartitionerData::find_partition ( const char *  key,
uint16_t  key_length 
) const

Returns the partition (node ID) that should contain the key.

MasstreePartitionerData methods, binary search.

Definition at line 527 of file masstree_partitioner_impl.cpp.

References ASSERT_ND, foedus::storage::masstree::is_key_aligned_and_zero_padded(), low_keys_, foedus::storage::masstree::normalize_be_bytes_full_aligned(), partition_count_, and partitions_.

Referenced by foedus::storage::masstree::MasstreePartitioner::partition_batch().

527  {
528  if (key_length == 0) {
529  return partitions_[0];
530  }
531 
532  // so far we do a simple sequential search here. we might want
533  // 1) binary search until candidate count becomes less than 8, 2) sequential search.
534  ASSERT_ND(is_key_aligned_and_zero_padded(key, key_length));
536  uint16_t i;
537  for (i = 1; i < partition_count_; ++i) {
538  if (low_keys_[i] > slice) {
539  break;
540  }
541  }
542  // now, i points to the first partition whose low_key is strictly larger than key.
543  // thus, the one before it should be the right partition.
544  return partitions_[i - 1];
545 }
uint64_t KeySlice
Each key slice is an 8-byte integer.
bool is_key_aligned_and_zero_padded(const char *key, KeyLength key_length)
Returns if the given key is 8-bytes aligned and also zero-padded to 8-bytes for easier slicing (which...
#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
KeySlice normalize_be_bytes_full_aligned(const void *be_bytes)
Convert an aligned big-endian byte array of at least 8-bytes-length to KeySlice.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

KeySlice foedus::storage::masstree::MasstreePartitionerData::low_keys_[kMaxIntermediatePointers]
uint16_t foedus::storage::masstree::MasstreePartitionerData::partitions_[kMaxIntermediatePointers]

The documentation for this struct was generated from the following files: