19 #ifndef SRC_CPP_MAIN_DATABASE_HEADERS_USERSET_H_
20 #define SRC_CPP_MAIN_DATABASE_HEADERS_USERSET_H_
37 typedef shared_ptr<UserSet>
SetPtr;
113 void pinBufferPage();
120 if (this->inputBufferPage !=
nullptr) {
121 this->inputBufferPage->decRefCount();
144 PDBPagePtr addPageByRawBytes(
size_t sharedMemOffset);
151 inline void*
getNewBytes(
size_t size,
bool evictWhenUnpin =
false) {
155 pthread_mutex_lock(&this->addBytesMutex);
156 if (this->inputBufferPage ==
nullptr) {
158 this->inputBufferPage = this->addPage();
160 void* buffer = this->inputBufferPage->addVariableBytes(size);
161 if (buffer ==
nullptr) {
165 this->inputBufferPage->decRefCount();
174 if (evictWhenUnpin ==
true) {
175 this->pageCache->evictPage(this->inputBufferPage);
180 this->inputBufferPage = this->addPage();
181 buffer = this->inputBufferPage->addVariableBytes(size);
182 pthread_mutex_unlock(&this->addBytesMutex);
186 pthread_mutex_unlock(&this->addBytesMutex);
198 virtual vector<PageIteratorPtr>* getIterators();
241 return this->setName;
262 return this->lastFlushedPageId;
270 this->lastFlushedPageId = pageId;
278 auto search = dirtyPagesInPageCache->find(pageId);
279 if (search != dirtyPagesInPageCache->end()) {
280 cout <<
"UserSet: Error in addPageToDirtyPageSet, key exists.\n";
286 dirtyPagesInPageCache->insert({pageId, key});
288 unlockDirtyPageSet();
299 unsigned int pageSeqInPartition) {
300 if (isPinned ==
false) {
301 PDB_COUT <<
"the set is not pinned" << std::endl;
302 dirtyPagesInPageCache->erase(pageId);
305 PDB_COUT <<
"the set is pinned" << std::endl;
306 auto search = dirtyPagesInPageCache->find(pageId);
307 if (search != dirtyPagesInPageCache->end()) {
308 search->second.inCache =
false;
309 search->second.partitionId = partitionId;
310 search->second.pageSeqInPartition = pageSeqInPartition;
319 return dirtyPagesInPageCache;
323 pthread_mutex_lock(&this->dirtyPageSetMutex);
327 pthread_mutex_unlock(&this->dirtyPageSetMutex);
336 void dump(
char* buffer);
341 return this->isPinned;
350 this->isPinned = isPinned;
351 unlockDirtyPageSet();
358 void cleanDirtyPageSet();
361 void flushDirtyPages();
364 return this->pageSize;
368 this->pageSize = pageSize;
372 return this->isSorted;
376 this->isSorted = isSorted;
380 return this->isPartitioned;
384 this->isPartitioned = isPartitioned;
402 unordered_map<PageID, FileSearchKey>* dirtyPagesInPageCache =
nullptr;
404 bool isPinned =
false;
408 bool isSorted =
false;
409 bool isPartitioned =
false;
shared_ptr< PDBPage > PDBPagePtr
shared_ptr< PageCache > PageCachePtr
void setLastFlushedPageId(PageID pageId)
void setFile(PartitionedFilePtr file)
unsigned int pageSeqInPartition
PageID getLastFlushedPageId()
LocalitySetReplacementPolicy
shared_ptr< PartitionedFile > PartitionedFilePtr
shared_ptr< SharedMem > SharedMemPtr
FilePartitionID partitionId
void * getNewBytes(size_t size, bool evictWhenUnpin=false)
pthread_mutex_t addBytesMutex
void addPageToDirtyPageSet(PageID pageId)
void setPinned(bool isPinned)
void setSorted(bool isSorted)
pthread_mutex_t dirtyPageSetMutex
void setPageSize(size_t pageSize)
std::shared_ptr< PDBLogger > PDBLoggerPtr
void unlockDirtyPageSet()
shared_ptr< UserSet > SetPtr
#define DEFAULT_PAGE_SIZE
pdb::PDBLoggerPtr getLogger()
void removePageFromDirtyPageSet(PageID pageId, FilePartitionID partitionId, unsigned int pageSeqInPartition)
shared_ptr< PDBObject > PDBObjectPtr
PartitionedFilePtr getFile()
unordered_map< PageID, FileSearchKey > * getDirtyPageSet()
unsigned int FilePartitionID
void setPartitioned(bool isPartitioned)