A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
UserSet Class Reference

#include <UserSet.h>

+ Inheritance diagram for UserSet:
+ Collaboration diagram for UserSet:

Public Member Functions

 UserSet (pdb::PDBLoggerPtr logger, SharedMemPtr shm, NodeID nodeId, DatabaseID dbId, UserTypeID typeId, SetID setId, string setName, PageCachePtr pageCache, LocalityType localityType=JobData, LocalitySetReplacementPolicy policy=MRU, OperationType operation=Read, DurabilityType durability=TryCache, PersistenceType persistence=Persistent, size_t pageSize=DEFAULT_PAGE_SIZE)
 
 UserSet (size_t pageSize, pdb::PDBLoggerPtr logger, SharedMemPtr shm, NodeID nodeId, DatabaseID dbId, UserTypeID typeId, SetID setId, string setName, PartitionedFilePtr file, PageCachePtr pageCache, LocalityType localityType=JobData, LocalitySetReplacementPolicy policy=MRU, OperationType operation=Read, DurabilityType durability=TryCache, PersistenceType persistence=Persistent)
 
 ~UserSet ()
 
bool addObject (PDBObjectPtr object, PDBPagePtr page)
 
bool addObject (PDBObjectPtr object)
 
void pinBufferPage ()
 
void unpinBufferPage ()
 
PDBPagePtr getPageFromFile (FilePartitionID partitionId, unsigned int pageSeqInPartition)
 
PDBPagePtr addPage ()
 
PDBPagePtr addPageByRawBytes (size_t sharedMemOffset)
 
void * getNewBytes (size_t size, bool evictWhenUnpin=false)
 
virtual vector< PageIteratorPtr > * getIterators ()
 
PDBPagePtr getPage (FilePartitionID partitionId, unsigned int pageSeqInPartition, PageID pageId)
 
int getNumPages ()
 
DatabaseID getDbID ()
 
UserTypeID getTypeID ()
 
SetID getSetID ()
 
string getSetName ()
 
PartitionedFilePtr getFile ()
 
void setFile (PartitionedFilePtr file)
 
PageID getLastFlushedPageId ()
 
void setLastFlushedPageId (PageID pageId)
 
void addPageToDirtyPageSet (PageID pageId)
 
void removePageFromDirtyPageSet (PageID pageId, FilePartitionID partitionId, unsigned int pageSeqInPartition)
 
unordered_map< PageID,
FileSearchKey > * 
getDirtyPageSet ()
 
void lockDirtyPageSet ()
 
void unlockDirtyPageSet ()
 
void dump (char *buffer)
 
void evictPages ()
 
bool getPinned ()
 
void setPinned (bool isPinned)
 
pdb::PDBLoggerPtr getLogger ()
 
void cleanDirtyPageSet ()
 
void flushDirtyPages ()
 
size_t getPageSize ()
 
void setPageSize (size_t pageSize)
 
bool getSorted ()
 
void setSorted (bool isSorted)
 
bool getPartitioned ()
 
void setPartitioned (bool isPartitioned)
 
- Public Member Functions inherited from LocalitySet
 LocalitySet (LocalityType localityType, LocalitySetReplacementPolicy replacementPolicy, OperationType operationType, DurabilityType durabilityType, PersistenceType persistenceType)
 
 ~LocalitySet ()
 
void addCachedPage (PDBPagePtr page)
 
void updateCachedPage (PDBPagePtr page)
 
void removeCachedPage (PDBPagePtr page)
 
PDBPagePtr selectPageForReplacement ()
 
vector< PDBPagePtr > * selectPagesForReplacement ()
 
void pin (LocalitySetReplacementPolicy policy, OperationType operationType)
 
void unpin ()
 
LocalityType getLocalityType ()
 
void setLocalityType (LocalityType type)
 
LocalitySetReplacementPolicy getReplacementPolicy ()
 
void setReplacementPolicy (LocalitySetReplacementPolicy policy)
 
OperationType getOperationType ()
 
void setOperationType (OperationType type)
 
DurabilityType getDurabilityType ()
 
void setDurabilityType (DurabilityType type)
 
PersistenceType getPersistenceType ()
 
void setPersistenceType (PersistenceType type)
 
bool isLifetimeEnded ()
 
void setLifetimeEnd (bool lifetimeEnded)
 

Protected Attributes

PartitionedFilePtr file = nullptr
 
PageCachePtr pageCache = nullptr
 
SharedMemPtr shm
 
pdb::PDBLoggerPtr logger = nullptr
 
NodeID nodeId
 
DatabaseID dbId
 
UserTypeID typeId
 
SetID setId
 
string setName
 
PageID lastFlushedPageId
 
PageID latestPageId
 
PDBPagePtr inputBufferPage = nullptr
 
SequenceID seqId
 
unordered_map< PageID,
FileSearchKey > * 
dirtyPagesInPageCache = nullptr
 
pthread_mutex_t dirtyPageSetMutex
 
bool isPinned = false
 
int numPages
 
pthread_mutex_t addBytesMutex
 
size_t pageSize
 
bool isSorted = false
 
bool isPartitioned = false
 
- Protected Attributes inherited from LocalitySet
list< PDBPagePtr > * cachedPages
 
LocalityType localityType
 
LocalitySetReplacementPolicy replacementPolicy
 
OperationType operationType
 
DurabilityType durabilityType
 
PersistenceType persistenceType
 
bool lifetimeEnded
 

Detailed Description

This class implements UserSet. A UserType instance include one or more UserSet instances. Each UserSet instance represents a locality group of data, so that all data in a UserSet instance are of the same type and will be accessed together.

A UserSet class has following key members:

  • A point to the global buffer pool (or called PageCache)
  • A PDBFile instance to manage persisted data

Different with BufferSet, a UserSet does not have input buffer to buffer writes. For writing, user can directly pin a new page in buffer pool, so that multi-threaded writing can be more efficient than BufferSet that has single buffer.

Definition at line 55 of file UserSet.h.

Constructor & Destructor Documentation

UserSet::UserSet ( pdb::PDBLoggerPtr  logger,
SharedMemPtr  shm,
NodeID  nodeId,
DatabaseID  dbId,
UserTypeID  typeId,
SetID  setId,
string  setName,
PageCachePtr  pageCache,
LocalityType  localityType = JobData,
LocalitySetReplacementPolicy  policy = MRU,
OperationType  operation = Read,
DurabilityType  durability = TryCache,
PersistenceType  persistence = Persistent,
size_t  pageSize = DEFAULT_PAGE_SIZE 
)

Create a UserSet instance, need to set file, page cache, and open file later

Create a UserSet instance, need to set file, and open file later

Definition at line 31 of file UserSet.cc.

UserSet::UserSet ( size_t  pageSize,
pdb::PDBLoggerPtr  logger,
SharedMemPtr  shm,
NodeID  nodeId,
DatabaseID  dbId,
UserTypeID  typeId,
SetID  setId,
string  setName,
PartitionedFilePtr  file,
PageCachePtr  pageCache,
LocalityType  localityType = JobData,
LocalitySetReplacementPolicy  policy = MRU,
OperationType  operation = Read,
DurabilityType  durability = TryCache,
PersistenceType  persistence = Persistent 
)

Create a UserSet instance, file needs to be set here

Create a UserSet instance.

Definition at line 68 of file UserSet.cc.

+ Here is the call graph for this function:

UserSet::~UserSet ( )

Destructor.

Definition at line 114 of file UserSet.cc.

Member Function Documentation

bool UserSet::addObject ( PDBObjectPtr  object,
PDBPagePtr  page 
)

Add object to a page in the set.

bool UserSet::addObject ( PDBObjectPtr  object)

Add object to the inputBufferPage in the set.

PDBPagePtr UserSet::addPage ( )

Add new page to the page cache for the set.

Definition at line 139 of file UserSet.cc.

+ Here is the call graph for this function:

PDBPagePtr UserSet::addPageByRawBytes ( size_t  sharedMemOffset)

Add new page by existing page raw bytes in shared memory page cache

Definition at line 156 of file UserSet.cc.

void UserSet::addPageToDirtyPageSet ( PageID  pageId)
inline

Add dirty page to the Set's hash map for dirty pages

Definition at line 276 of file UserSet.h.

+ Here is the caller graph for this function:

void UserSet::cleanDirtyPageSet ( )

Definition at line 257 of file UserSet.cc.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void UserSet::dump ( char *  buffer)

To dump set data to a buffer. NOTE: User MUST guarantee that the size of buffer is large enough for dumping all data in the set.

Definition at line 211 of file UserSet.cc.

+ Here is the call graph for this function:

void UserSet::evictPages ( )

Definition at line 232 of file UserSet.cc.

+ Here is the call graph for this function:

void UserSet::flushDirtyPages ( )

Definition at line 271 of file UserSet.cc.

+ Here is the call graph for this function:

DatabaseID UserSet::getDbID ( )
inline

Return DatabaseID of the set instance.

Definition at line 217 of file UserSet.h.

+ Here is the caller graph for this function:

unordered_map<PageID, FileSearchKey>* UserSet::getDirtyPageSet ( )
inline

Get the dirty page map

Definition at line 318 of file UserSet.h.

+ Here is the caller graph for this function:

PartitionedFilePtr UserSet::getFile ( )
inline

Returns file instance;

Definition at line 247 of file UserSet.h.

+ Here is the caller graph for this function:

vector< PageIteratorPtr > * UserSet::getIterators ( )
virtual

Get a set of iterators for scanning the data in the set. The set of iterators will include: – 1 iterator to scan data in input buffer; – K iterators to scan data in file partitions, assuming there are K partitions. IMPORTANT: user needs to delete the returned vector!!!

Get a set of iterators for scanning the data in the set. The set of iterators will include: – 1 iterator to scan data in page cache; – K iterators to scan data in file partitions, assuming there are K partitions.

Definition at line 173 of file UserSet.cc.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PageID UserSet::getLastFlushedPageId ( )
inline

Returns last flushed pageId;

Definition at line 261 of file UserSet.h.

pdb::PDBLoggerPtr UserSet::getLogger ( )
inline

Definition at line 354 of file UserSet.h.

void* UserSet::getNewBytes ( size_t  size,
bool  evictWhenUnpin = false 
)
inline

To get next a few bytes with size specified by the parameter. Returns the pointer pointing to the starting position of the bytes.

Definition at line 151 of file UserSet.h.

int UserSet::getNumPages ( )

Get number of pages.

Definition at line 163 of file UserSet.cc.

PDBPagePtr UserSet::getPage ( FilePartitionID  partitionId,
unsigned int  pageSeqInPartition,
PageID  pageId 
)

Get page from set. Step 1. check whether the page is already in cache using cache key, if so return it. Step 2. check whether the page is flushed to disk file, if so, load it to cache, and return it.

check whether the page is already in cache using cache key, if so return it. otherwise, check whether the page is flushed to disk file, if so, load it to cache, and return it.

Definition at line 126 of file UserSet.cc.

PDBPagePtr UserSet::getPageFromFile ( FilePartitionID  partitionId,
unsigned int  pageSeqInPartition 
)

Load a page from the set's associate file to cache. If the set's associated file is of SequenceFile type, the parameter partitionId will be ignored. If the page exists in the partition, load it to cache, pin it, and return the page. If the page doesn't exist in the partition, we return nullptr.

size_t UserSet::getPageSize ( )
inline

Definition at line 363 of file UserSet.h.

bool UserSet::getPartitioned ( )
inline

Definition at line 379 of file UserSet.h.

bool UserSet::getPinned ( )
inline

Definition at line 340 of file UserSet.h.

SetID UserSet::getSetID ( )
inline

Return SetID of the set instance.

Definition at line 233 of file UserSet.h.

+ Here is the caller graph for this function:

string UserSet::getSetName ( )
inline

Return the name of the set instance.

Definition at line 240 of file UserSet.h.

bool UserSet::getSorted ( )
inline

Definition at line 371 of file UserSet.h.

UserTypeID UserSet::getTypeID ( )
inline

Return UserTypeID of the set instance

Definition at line 225 of file UserSet.h.

+ Here is the caller graph for this function:

void UserSet::lockDirtyPageSet ( )
inline

Definition at line 322 of file UserSet.h.

+ Here is the caller graph for this function:

void UserSet::pinBufferPage ( )
void UserSet::removePageFromDirtyPageSet ( PageID  pageId,
FilePartitionID  partitionId,
unsigned int  pageSeqInPartition 
)
inline

Not really remove dirty page from the Set's hash map for dirty pages; Just label it as flushed, and set other fields of FileSearchKey. It is not thread-safe. It is only used in PDBFlushConsumerWork class, where it is guarded by lock.

Definition at line 297 of file UserSet.h.

void UserSet::setFile ( PartitionedFilePtr  file)
inline

Set file instance;

Definition at line 254 of file UserSet.h.

+ Here is the caller graph for this function:

void UserSet::setLastFlushedPageId ( PageID  pageId)
inline

Set last flushed pageId;

Definition at line 269 of file UserSet.h.

void UserSet::setPageSize ( size_t  pageSize)
inline

Definition at line 367 of file UserSet.h.

void UserSet::setPartitioned ( bool  isPartitioned)
inline

Definition at line 383 of file UserSet.h.

void UserSet::setPinned ( bool  isPinned)
inline

Definition at line 348 of file UserSet.h.

+ Here is the caller graph for this function:

void UserSet::setSorted ( bool  isSorted)
inline

Definition at line 375 of file UserSet.h.

void UserSet::unlockDirtyPageSet ( )
inline

Definition at line 326 of file UserSet.h.

+ Here is the caller graph for this function:

void UserSet::unpinBufferPage ( )
inline

Unpin buffer page.

Definition at line 119 of file UserSet.h.

Member Data Documentation

pthread_mutex_t UserSet::addBytesMutex
protected

Definition at line 406 of file UserSet.h.

DatabaseID UserSet::dbId
protected

Definition at line 394 of file UserSet.h.

pthread_mutex_t UserSet::dirtyPageSetMutex
protected

Definition at line 403 of file UserSet.h.

unordered_map<PageID, FileSearchKey>* UserSet::dirtyPagesInPageCache = nullptr
protected

Definition at line 402 of file UserSet.h.

PartitionedFilePtr UserSet::file = nullptr
protected

Definition at line 389 of file UserSet.h.

PDBPagePtr UserSet::inputBufferPage = nullptr
protected

Definition at line 400 of file UserSet.h.

bool UserSet::isPartitioned = false
protected

Definition at line 409 of file UserSet.h.

bool UserSet::isPinned = false
protected

Definition at line 404 of file UserSet.h.

bool UserSet::isSorted = false
protected

Definition at line 408 of file UserSet.h.

PageID UserSet::lastFlushedPageId
protected

Definition at line 398 of file UserSet.h.

PageID UserSet::latestPageId
protected

Definition at line 399 of file UserSet.h.

pdb::PDBLoggerPtr UserSet::logger = nullptr
protected

Definition at line 392 of file UserSet.h.

NodeID UserSet::nodeId
protected

Definition at line 393 of file UserSet.h.

int UserSet::numPages
protected

Definition at line 405 of file UserSet.h.

PageCachePtr UserSet::pageCache = nullptr
protected

Definition at line 390 of file UserSet.h.

size_t UserSet::pageSize
protected

Definition at line 407 of file UserSet.h.

SequenceID UserSet::seqId
protected

Definition at line 401 of file UserSet.h.

SetID UserSet::setId
protected

Definition at line 396 of file UserSet.h.

string UserSet::setName
protected

Definition at line 397 of file UserSet.h.

SharedMemPtr UserSet::shm
protected

Definition at line 391 of file UserSet.h.

UserTypeID UserSet::typeId
protected

Definition at line 395 of file UserSet.h.


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