mongo::BucketBasics Class Reference

#include <btree.h>

Inheritance diagram for mongo::BucketBasics:
Inheritance graph
[legend]

List of all members.

Public Member Functions

void assertValid (const BSONObj &orderObj, bool force=false) const
void assertValid (const Ordering &order, bool force=false) const
void assertWritable ()
const DiskLoc getNextChild () const
const KeyNode keyNode (int i) const
int nKeys () const

Static Public Member Functions

static int bodySize ()
static int headerSize ()

Protected Types

enum  Flags { Packed = 1 }

Protected Member Functions

int _alloc (int bytes)
void _delKeyAtPos (int keypos, bool mayEmpty=false)
void _pack (const DiskLoc thisLoc, const Ordering &order, int &refPos) const
void _packReadyForMod (const Ordering &order, int &refPos)
bool _pushBack (const DiskLoc recordLoc, const BSONObj &key, const Ordering &order, const DiskLoc prevChild)
void _shape (int level, stringstream &) const
void _unalloc (int bytes)
bool basicInsert (const DiskLoc thisLoc, int &keypos, const DiskLoc recordLoc, const BSONObj &key, const Ordering &order) const
DiskLocchildForPos (int p)
const DiskLocchildForPos (int p) const
char * dataAt (short ofs)
void dropFront (int nDrop, const Ordering &order, int &refPos)
void init ()
_KeyNodek (int i)
const _KeyNodek (int i) const
void markUnused (int keypos)
bool mayDropKey (int index, int refPos) const
int packedDataSize (int refPos) const
void popBack (DiskLoc &recLoc, BSONObj &key)
void pushBack (const DiskLoc recordLoc, const BSONObj &key, const Ordering &order, const DiskLoc prevChild)
void reserveKeysFront (int nAdd)
void setKey (int i, const DiskLoc recordLoc, const BSONObj &key, const DiskLoc prevChildBucket)
void setNotPacked ()
void setPacked ()
int Size () const
int splitPos (int keypos) const
DiskLoctempNext ()
const DiskLoctempNext () const
int totalDataSize () const
void truncateTo (int N, const Ordering &order, int &refPos)

Friends

class BtreeBuilder
class KeyNode

Detailed Description

This class is all about the storage management

Const member functions of this class are those which may be called on an object for which writing has not been signaled. Non const member functions may only be called on objects for which writing has been signaled. Note that currently some const functions write to the underlying memory representation of this bucket using optimized methods to signal write operations.

DiskLoc parameters that may shadow references within the btree should be passed by value rather than by reference to non const member functions or const member functions which may perform writes. This way a callee need not worry that write operations will change or invalidate its arguments.

The current policy for dealing with bson arguments is the opposite of what is described above for DiskLoc arguments. We do not want to want to copy bson into memory as an intermediate step for btree changes, so if bson is to be moved it must be copied to the new location before the old location is invalidated.

Definition at line 120 of file btree.h.


Member Enumeration Documentation

enum mongo::BucketBasics::Flags [protected]
Enumerator:
Packed 

Definition at line 191 of file btree.h.


Member Function Documentation

int mongo::BucketBasics::_alloc ( int  bytes  )  [protected]
void mongo::BucketBasics::_delKeyAtPos ( int  keypos,
bool  mayEmpty = false 
) [protected]
void mongo::BucketBasics::_pack ( const DiskLoc  thisLoc,
const Ordering order,
int &  refPos 
) const [protected]

Pack the bucket to reclaim space from invalidated memory. is an index in the bucket which will may be updated if we delete keys from the bucket This function may cast away const and perform a write.

void mongo::BucketBasics::_packReadyForMod ( const Ordering order,
int &  refPos 
) [protected]

Pack when already writable

bool mongo::BucketBasics::_pushBack ( const DiskLoc  recordLoc,
const BSONObj key,
const Ordering order,
const DiskLoc  prevChild 
) [protected]
Returns:
true if works, false if not enough space
void mongo::BucketBasics::_shape ( int  level,
stringstream &   
) const [protected]
void mongo::BucketBasics::_unalloc ( int  bytes  )  [protected]
void mongo::BucketBasics::assertValid ( const BSONObj orderObj,
bool  force = false 
) const [inline]

Definition at line 128 of file btree.h.

void mongo::BucketBasics::assertValid ( const Ordering order,
bool  force = false 
) const
void mongo::BucketBasics::assertWritable (  ) 

assert write intent declared for this bucket already

bool mongo::BucketBasics::basicInsert ( const DiskLoc  thisLoc,
int &  keypos,
const DiskLoc  recordLoc,
const BSONObj key,
const Ordering order 
) const [protected]
Returns:
false if node is full and must be split is where to insert -- inserted before that key #. so keypos=0 is the leftmost one. keypos will be updated if keys are moved as a result of pack() This function will modify the btree bucket memory representation even though it is marked const.
static int mongo::BucketBasics::bodySize (  )  [inline, static]

Definition at line 145 of file btree.h.

DiskLoc& mongo::BucketBasics::childForPos ( int  p  )  [inline, protected]

Definition at line 194 of file btree.h.

const DiskLoc& mongo::BucketBasics::childForPos ( int  p  )  const [inline, protected]

Definition at line 193 of file btree.h.

char* mongo::BucketBasics::dataAt ( short  ofs  )  [inline, protected]

Definition at line 152 of file btree.h.

void mongo::BucketBasics::dropFront ( int  nDrop,
const Ordering order,
int &  refPos 
) [protected]

drop specified number of keys from beginning of key array, and pack

const DiskLoc mongo::BucketBasics::getNextChild (  )  const [inline]

Definition at line 149 of file btree.h.

static int mongo::BucketBasics::headerSize (  )  [inline, static]

Definition at line 141 of file btree.h.

void mongo::BucketBasics::init (  )  [protected]
_KeyNode& mongo::BucketBasics::k ( int  i  )  [inline, protected]

Definition at line 234 of file btree.h.

const _KeyNode& mongo::BucketBasics::k ( int  i  )  const [inline, protected]

Definition at line 233 of file btree.h.

const KeyNode mongo::BucketBasics::keyNode ( int  i  )  const [inline]
Returns:
KeyNode for key at index i. The KeyNode will become invalid if the key is moved or reassigned, or if the node is packed.

Definition at line 134 of file btree.h.

void mongo::BucketBasics::markUnused ( int  keypos  )  [protected]
bool mongo::BucketBasics::mayDropKey ( int  index,
int  refPos 
) const [protected]
Returns:
true if the key may be dropped by pack()
int mongo::BucketBasics::nKeys (  )  const [inline]

Definition at line 148 of file btree.h.

int mongo::BucketBasics::packedDataSize ( int  refPos  )  const [protected]
Returns:
the size of non header data in this bucket if we were to call pack().
void mongo::BucketBasics::popBack ( DiskLoc recLoc,
BSONObj key 
) [protected]

This is a special purpose function used by BtreeBuilder. The interface is quite dangerous if you're not careful. The bson key returned here points to bucket memory that has been invalidated but not yet reclaimed.

TODO Maybe this could be replaced with two functions, one which returns the last key without deleting it and another which simply deletes the last key. Then the caller would have enough control to ensure proper memory integrity.

void mongo::BucketBasics::pushBack ( const DiskLoc  recordLoc,
const BSONObj key,
const Ordering order,
const DiskLoc  prevChild 
) [inline, protected]

Definition at line 167 of file btree.h.

void mongo::BucketBasics::reserveKeysFront ( int  nAdd  )  [protected]

Adds new entries to beginning of key array, shifting existing entries to the right. After this is called, setKey() must be called on all the newly created entries in the key array.

void mongo::BucketBasics::setKey ( int  i,
const DiskLoc  recordLoc,
const BSONObj key,
const DiskLoc  prevChildBucket 
) [protected]

Sets an existing key using the given parameters. index of key to set

void mongo::BucketBasics::setNotPacked (  )  [inline, protected]

Definition at line 215 of file btree.h.

void mongo::BucketBasics::setPacked (  )  [inline, protected]

Definition at line 216 of file btree.h.

int mongo::BucketBasics::Size (  )  const [protected]
int mongo::BucketBasics::splitPos ( int  keypos  )  const [protected]
Returns:
the key position where a split should occur on insert
DiskLoc& mongo::BucketBasics::tempNext (  )  [inline, protected]

Definition at line 229 of file btree.h.

const DiskLoc& mongo::BucketBasics::tempNext (  )  const [inline, protected]

BtreeBuilder uses the parent var as a temp place to maintain a linked list chain. we use tempNext() when we do that to be less confusing. (one might have written a union in C)

Definition at line 228 of file btree.h.

int mongo::BucketBasics::totalDataSize (  )  const [protected]
void mongo::BucketBasics::truncateTo ( int  N,
const Ordering order,
int &  refPos 
) [protected]

Friends And Related Function Documentation

friend class BtreeBuilder [friend]

Definition at line 121 of file btree.h.

friend class KeyNode [friend]

Definition at line 122 of file btree.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


mongodb
Author(s): Nate Koenig
autogenerated on Fri Jan 11 12:15:54 2013