25 #ifndef SRC_CPP_MAIN_DATABASE_HEADERS_PARTITIONEDFILEMETADATA_H_
26 #define SRC_CPP_MAIN_DATABASE_HEADERS_PARTITIONEDFILEMETADATA_H_
31 #include <unordered_map>
71 this->partitions =
nullptr;
73 this->numFlushedPages = 0;
74 this->pageIndexes =
new unordered_map<PageID, PageIndex>();
75 this->pageIds =
new unordered_map<PageIndex, PageID, PageIndexHash, PageIndexEqual>();
76 pthread_mutex_init(&(this->metaMutex),
nullptr);
77 pthread_mutex_init(&(this->indexMutex),
nullptr);
82 if (partitions !=
nullptr) {
86 if (pageIndexes !=
nullptr) {
90 if (pageIds !=
nullptr) {
98 return this->numFlushedPages;
103 this->numFlushedPages = numFlushedPages;
107 pthread_mutex_lock(&indexMutex);
111 this->pageIndexes->insert(pair<PageID, PageIndex>(pageId, pageIndex));
112 this->pageIds->insert(pair<PageIndex, PageID>(pageIndex, pageId));
113 pthread_mutex_unlock(&indexMutex);
119 if (this->pageIndexes->find(pageId) == this->pageIndexes->end()) {
123 pageIndex = this->pageIndexes->at(pageId);
133 if (this->pageIds->find(pageIndex) == this->pageIds->end()) {
134 pageId = (
unsigned int)(-1);
136 pageId = this->pageIds->at(pageIndex);
144 pthread_mutex_lock(&metaMutex);
145 this->numFlushedPages++;
146 pthread_mutex_unlock(&metaMutex);
161 this->pageSize = pageSize;
171 return partitions->at(partitionId);
176 this->partitions = partitions;
181 if (this->partitions ==
nullptr) {
182 this->partitions =
new vector<PartitionMetaDataPtr>();
184 partitions->push_back(partition);
194 this->version = version;
200 this->latestPageId = pageId;
211 vector<PartitionMetaDataPtr>* partitions =
nullptr;
219 unordered_map<PageID, PageIndex>* pageIndexes =
nullptr;
220 unordered_map<PageIndex, PageID, PageIndexHash, PageIndexEqual>* pageIds =
nullptr;
237 this->partitionId = partitionId;
253 this->numPages = numPages;
274 this->partitionId = partitionId;
unsigned int pageSeqInPartition
bool operator()(const PageIndex &lIndex, const PageIndex &rIndex) const
FilePartitionID partitionId
std::size_t operator()(const PageIndex &index) const
unsigned int FilePartitionID