Fennel: CompoundId Class Reference (original) (raw)

CompoundId is a collection of static methods for manipulating PageIds, BlockIds, and SegByteIds. More...

#include <[CompoundId.h](CompoundId%5F8h-source.html)>

List of all members.

Static Public Member Functions
template
static BlockNum getBlockNum (PageOrBlockId pageId)
Extracts the BlockNum from a PageId or BlockId.
template
static void setBlockNum (PageOrBlockId &pageId, BlockNum blockNum)
Sets just the BlockNum of a PageId or BlockId.
template
static void incBlockNum (PageOrBlockId &pageId)
Increments the BlockNum of a PageId or BlockId.
template
static void decBlockNum (PageOrBlockId &pageId)
Decrements the BlockNum of a PageId or BlockId.
template
static DeviceId getDeviceId (PageOrBlockId pageId)
Extracts the DeviceId from a PageId or BlockId.
template
static void setDeviceId (PageOrBlockId &pageId, DeviceId deviceId)
Sets just the DeviceId of a PageId or BlockId.
static PageId getPageId (SegByteId segByteId)
Extracts the PageId component of a SegByteId.
static void setPageId (SegByteId &segByteId, PageId pageId)
Sets the PageId component of a SegByteId.
static uint getByteOffset (SegByteId segByteId)
Extracts the byte offset component of a SegByteId.
static void setByteOffset (SegByteId &segByteId, uint offset)
Sets the byte offset component of a SegByteId.
static int comparePageIds (PageId p1, PageId p2)
Compares two PageIds.
static int compareSegByteIds (SegByteId t1, SegByteId t2)
Compares two SegByteIds.
static uint getMaxDeviceCount ()
**Returns:**the maximum number of devices permitted by the page ID encoding
Static Public Attributes
static const uint MAX_DEVICES = 0x1000
Maximum number of devices, based on mask sizes.
static const uint MAX_BYTE_OFFSET = 0xFFFFF
Maximum byte offset on a page.
Static Private Attributes
static const uint64_t DEVICE_ID_MASK = 0xFFF0000000000000ULL
static const uint64_t BYTE_OFFSET_MASK = 0x000FFFFF00000000ULL
static const uint64_t BLOCK_NUM_MASK = 0x00000000FFFFFFFFULL
static const uint DEVICE_ID_SHIFT = 52
Number of bits to right-shift a masked PageId to extract the DeviceId.
static const uint BYTE_OFFSET_SHIFT = 32
Number of bits to right-shift a masked PageId to extract the BlockNum.

Detailed Description

CompoundId is a collection of static methods for manipulating PageIds, BlockIds, and SegByteIds.

These ID's are encoded into 64-bit integers representing logical or physical storage locations as follows:

MSB [ 12-bit DeviceId : 20-bit byte offset: 32-bit BlockNum ] LSB *

where DeviceId is the ID of some cached device, BlockNum is the block number of some block within that device (actual offset is determined by the device type and block size), and the byte offset is a 0-based byte location within that block.

The bit arrangement above allows for page sizes up to 1M. Combined with a 32-bit BlockNum, this allows a device size up to 4 petabytes. It also optimizes for translation between PageId and BlockId, rather than for byte offset access. The main justification is that PageId/BlockId translation has to occur for every page accessed, and in many cases the byte offset may not even be used. However, this means that SegByteId should only be used as a means of compact persistent representation; any time significant byte offset arithmetic has to be done, the byte offset should be manipulated as a separate uint.

TODO: autoconf support for parameterizing the CompoundId representation, since one size may not fit all. Also, could use architecture-dependent code for speeding up the accessors.

For a PageId or BlockId, the byte offset portion is always 0 (except for NULL_PAGE_ID and NULL_BLOCK_ID).

Definition at line 72 of file CompoundId.h.


Member Function Documentation

template

static BlockNum CompoundId::getBlockNum ( PageOrBlockId pageId ) [inline, static]

template

static void CompoundId::setBlockNum ( PageOrBlockId & pageId,
BlockNum blockNum
) [inline, static]

Sets just the BlockNum of a PageId or BlockId.

Parameters:

pageId the PageId or BlockId to modify
blockNum the new BlockNum to set

Definition at line 121 of file CompoundId.h.

References opaqueToInt().

Referenced by Database::allocateHeader(), Database::createDataSegment(), SegStorageTestBase::createLinearDeviceSegment(), Database::createShadowLog(), Database::createTempSegment(), Database::createTxnLogSegment(), Database::loadHeader(), CacheImpl< PageT, VictimPolicyT >::lockScratchPage(), CacheTest::makeBlockId(), SegmentFactory::newTempDeviceSegment(), SparseBitmapTest::openStorage(), ScratchSegment::translatePageId(), and LinearDeviceSegment::translatePageId().

template

static void CompoundId::incBlockNum ( PageOrBlockId & pageId ) [inline, static]

template

static void CompoundId::decBlockNum ( PageOrBlockId & pageId ) [inline, static]

template

static DeviceId CompoundId::getDeviceId ( PageOrBlockId pageId ) [inline, static]

Extracts the DeviceId from a PageId or BlockId.

Parameters:

pageId the PageId or BlockId to access

Returns:

the extracted DeviceId

Definition at line 158 of file CompoundId.h.

References opaqueToInt().

Referenced by LinearDeviceSegment::getDeviceId(), CachePage::isScratchLocked(), ScratchSegment::lockPage(), CacheImpl< PageT, VictimPolicyT >::lockPage(), CacheImpl< PageT, VictimPolicyT >::mapPage(), DeviceIdPagePredicate::operator()(), CacheImpl< PageT, VictimPolicyT >::prefetchBatch(), CacheImpl< PageT, VictimPolicyT >::transferPageAsync(), and CacheImpl< PageT, VictimPolicyT >::unlockPage().

template

static void CompoundId::setDeviceId ( PageOrBlockId & pageId,
DeviceId deviceId
) [inline, static]

Sets just the DeviceId of a PageId or BlockId.

Parameters:

pageId the PageId or BlockId to modify
deviceId the new DeviceId to set

Definition at line 172 of file CompoundId.h.

References opaqueToInt().

Referenced by Database::allocateHeader(), Database::createDataSegment(), SegStorageTestBase::createLinearDeviceSegment(), Database::createShadowLog(), Database::createTempSegment(), Database::createTxnLogSegment(), Database::loadHeader(), CacheImpl< PageT, VictimPolicyT >::lockScratchPage(), CacheTest::makeBlockId(), SegmentFactory::newTempDeviceSegment(), SparseBitmapTest::openStorage(), and ScratchSegment::translatePageId().

static PageId CompoundId::getPageId ( SegByteId segByteId ) [inline, static]
static void CompoundId::setPageId ( SegByteId & segByteId,
PageId pageId
) [inline, static]
static uint CompoundId::getByteOffset ( SegByteId segByteId ) [inline, static]
static void CompoundId::setByteOffset ( SegByteId & segByteId,
uint offset
) [inline, static]
static int CompoundId::comparePageIds ( PageId p1,
PageId p2
) [inline, static]

Compares two PageIds.

Parameters:

p1 first PageId to compare
p2 second PageId to compare

Returns:

memcmp convention (negative if p1 is less than p2; zero if equal; positive if greater)

Definition at line 243 of file CompoundId.h.

00244 { 00245 return (p1 > p2) ? 1 00246 : ((p1 < p2) ? -1 : 0); 00247 }

static int CompoundId::compareSegByteIds ( SegByteId t1,
SegByteId t2
) [inline, static]

Compares two SegByteIds.

Parameters:

t1 first SegByteId to compare
t2 second SegByteId to compare

Returns:

memcmp convention (negative if t1 is less than t2; zero if equal; positive if greater)

Definition at line 259 of file CompoundId.h.

00260 { 00261 return (t1 > t2) ? 1 00262 : ((t1 < t2) ? -1 : 0); 00263 }

| static uint CompoundId::getMaxDeviceCount | ( | | ) | [inline, static] | | ------------------------------------------------------------------------------------------------------ | - | | - | ------------------ |

Returns:

the maximum number of devices permitted by the page ID encoding

Definition at line 269 of file CompoundId.h.


Member Data Documentation

Number of bits to right-shift a masked PageId to extract the DeviceId.

Definition at line 82 of file CompoundId.h.

Number of bits to right-shift a masked PageId to extract the BlockNum.

Definition at line 87 of file CompoundId.h.

Maximum number of devices, based on mask sizes.

Definition at line 93 of file CompoundId.h.


The documentation for this class was generated from the following file:


Generated on Mon Jun 22 04:00:29 2009 for Fennel by doxygen 1.5.1