libfoedus-core
FOEDUS Core Library
foedus::storage::masstree::OwnerSamples Struct Reference

Number of vol pages in each node sampled per pointer in the root page. More...

Detailed Description

Number of vol pages in each node sampled per pointer in the root page.

Will be probably used in other partitioners, too.

Definition at line 155 of file masstree_partitioner_impl.hpp.

#include <masstree_partitioner_impl.hpp>

Public Member Functions

 OwnerSamples (uint32_t nodes, uint32_t subtrees)
 
 ~OwnerSamples ()
 
void increment (uint32_t node, uint32_t subtree_id)
 
uint32_t at (uint32_t node, uint32_t subtree_id) const
 
uint32_t get_assignment (uint32_t subtree_id) const
 
void assign_owners ()
 Determine assignments based on the samples. More...
 

Public Attributes

const uint32_t nodes_
 number of nodes More...
 
const uint32_t subtrees_
 number of pointers to children in the root page More...
 
uint32_t * occurrences_
 number of occurences of a volatile page in the node. More...
 
uint32_t * assignments_
 node_id to be the owner of the subtree More...
 

Friends

std::ostream & operator<< (std::ostream &o, const OwnerSamples &v)
 

Constructor & Destructor Documentation

foedus::storage::masstree::OwnerSamples::OwnerSamples ( uint32_t  nodes,
uint32_t  subtrees 
)
inline

Definition at line 156 of file masstree_partitioner_impl.hpp.

References assignments_, and occurrences_.

156  : nodes_(nodes), subtrees_(subtrees) {
157  occurrences_ = new uint32_t[nodes * subtrees];
158  std::memset(occurrences_, 0, sizeof(uint32_t) * nodes * subtrees);
159  assignments_ = new uint32_t[subtrees];
160  std::memset(assignments_, 0, sizeof(uint32_t) * subtrees);
161  }
uint32_t * assignments_
node_id to be the owner of the subtree
uint32_t * occurrences_
number of occurences of a volatile page in the node.
const uint32_t subtrees_
number of pointers to children in the root page
foedus::storage::masstree::OwnerSamples::~OwnerSamples ( )
inline

Definition at line 162 of file masstree_partitioner_impl.hpp.

References assignments_, and occurrences_.

162  {
163  delete[] occurrences_;
164  occurrences_ = nullptr;
165  delete[] assignments_;
166  assignments_ = nullptr;
167  }
uint32_t * assignments_
node_id to be the owner of the subtree
uint32_t * occurrences_
number of occurences of a volatile page in the node.

Member Function Documentation

void foedus::storage::masstree::OwnerSamples::assign_owners ( )

Determine assignments based on the samples.

Definition at line 216 of file masstree_partitioner_impl.cpp.

References assignments_, at(), nodes_, and subtrees_.

216  {
217  // so far simply the node that has majority. but we might want to balance out
218  for (uint32_t subtree_id = 0; subtree_id < subtrees_; ++subtree_id) {
219  uint32_t max_node = 0;
220  uint32_t max_count = at(0, subtree_id);
221  for (uint32_t node = 1; node < nodes_; ++node) {
222  if (at(node, subtree_id) > max_count) {
223  max_node = node;
224  max_count = at(node, subtree_id);
225  }
226  }
227  assignments_[subtree_id] = max_node;
228  }
229 }
uint32_t at(uint32_t node, uint32_t subtree_id) const
uint32_t * assignments_
node_id to be the owner of the subtree
const uint32_t subtrees_
number of pointers to children in the root page

Here is the call graph for this function:

uint32_t foedus::storage::masstree::OwnerSamples::at ( uint32_t  node,
uint32_t  subtree_id 
) const
inline

Definition at line 183 of file masstree_partitioner_impl.hpp.

References ASSERT_ND.

Referenced by assign_owners(), and foedus::storage::masstree::operator<<().

183  {
184  ASSERT_ND(node < nodes_);
185  ASSERT_ND(subtree_id < subtrees_);
186  return occurrences_[subtree_id * nodes_ + node];
187  }
uint32_t * occurrences_
number of occurences of a volatile page in the node.
const uint32_t subtrees_
number of pointers to children in the root page
#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

Here is the caller graph for this function:

uint32_t foedus::storage::masstree::OwnerSamples::get_assignment ( uint32_t  subtree_id) const
inline

Definition at line 189 of file masstree_partitioner_impl.hpp.

Referenced by foedus::storage::masstree::operator<<().

189 { return assignments_[subtree_id]; }
uint32_t * assignments_
node_id to be the owner of the subtree

Here is the caller graph for this function:

void foedus::storage::masstree::OwnerSamples::increment ( uint32_t  node,
uint32_t  subtree_id 
)
inline

Definition at line 178 of file masstree_partitioner_impl.hpp.

References ASSERT_ND.

Referenced by foedus::storage::masstree::design_partition_first_parallel_recurse().

178  {
179  ASSERT_ND(node < nodes_);
180  ASSERT_ND(subtree_id < subtrees_);
181  ++occurrences_[subtree_id * nodes_ + node];
182  }
uint32_t * occurrences_
number of occurences of a volatile page in the node.
const uint32_t subtrees_
number of pointers to children in the root page
#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

Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const OwnerSamples v 
)
friend

Definition at line 231 of file masstree_partitioner_impl.cpp.

231  {
232  o << "<OwnerSamples nodes=\"" << v.nodes_
233  << "\" subtrees=\"" << v.subtrees_ << "\">" << std::endl;
234  o << "<!-- legend id=\"x\" assignment=\"x\">";
235  for (uint32_t node = 0; node < v.nodes_; ++node) {
236  o << "[Node-" << node << "] ";
237  }
238  o << " -->" << std::endl;
239  for (uint32_t subtree_id = 0; subtree_id < v.subtrees_; ++subtree_id) {
240  o << " <subtree id=\"" << subtree_id
241  << "\" assignment=\"" << v.get_assignment(subtree_id) << "\">";
242  for (uint32_t node = 0; node < v.nodes_; ++node) {
243  o << assorted::Hex(v.at(node, subtree_id), 6) << " ";
244  }
245  o << "</subtree>" << std::endl;
246  }
247  o << std::endl << "</OwnerSamples>";
248  return o;
249 }

Member Data Documentation

uint32_t* foedus::storage::masstree::OwnerSamples::assignments_

node_id to be the owner of the subtree

Definition at line 176 of file masstree_partitioner_impl.hpp.

Referenced by assign_owners(), OwnerSamples(), and ~OwnerSamples().

const uint32_t foedus::storage::masstree::OwnerSamples::nodes_

number of nodes

Definition at line 170 of file masstree_partitioner_impl.hpp.

Referenced by assign_owners(), and foedus::storage::masstree::operator<<().

uint32_t* foedus::storage::masstree::OwnerSamples::occurrences_

number of occurences of a volatile page in the node.

See also
at()

Definition at line 174 of file masstree_partitioner_impl.hpp.

Referenced by OwnerSamples(), and ~OwnerSamples().

const uint32_t foedus::storage::masstree::OwnerSamples::subtrees_

number of pointers to children in the root page

Definition at line 172 of file masstree_partitioner_impl.hpp.

Referenced by assign_owners(), and foedus::storage::masstree::operator<<().


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