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
PartitionPageIterator.cc
Go to the documentation of this file.
1 /*****************************************************************************
2  * *
3  * Copyright 2018 Rice University *
4  * *
5  * Licensed under the Apache License, Version 2.0 (the "License"); *
6  * you may not use this file except in compliance with the License. *
7  * You may obtain a copy of the License at *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14  * See the License for the specific language governing permissions and *
15  * limitations under the License. *
16  * *
17  *****************************************************************************/
18 
19 #include "PDBDebug.h"
20 #include "PartitionPageIterator.h"
21 
26  PDBFilePtr file,
27  FilePartitionID partitionId,
28  UserSet* set) {
29  this->cache = cache;
30  this->file = file;
31  this->partitionId = partitionId;
32  this->set = set;
33  if ((this->type = file->getFileType()) == FileType::SequenceFileType) {
34  this->sequenceFile = dynamic_pointer_cast<SequenceFile>(file);
35  this->partitionedFile = nullptr;
36  this->numPages = file->getNumFlushedPages();
37  } else {
38  this->sequenceFile = nullptr;
39  this->partitionedFile = dynamic_pointer_cast<PartitionedFile>(file);
40  this->numPages = partitionedFile->getMetaData()->getPartition(partitionId)->getNumPages();
41  }
42  this->numIteratedPages = 0;
43 }
44 
49  PDBPagePtr pageToReturn;
50  if (this->numIteratedPages >= this->numPages) {
51  return nullptr;
52  } else {
53  if (this->type == FileType::SequenceFileType) {
54  pageToReturn = cache->getPage(this->sequenceFile, this->numIteratedPages);
55  this->numIteratedPages++;
56  } else {
57  PageID curPageId =
58  this->partitionedFile->loadPageId(this->partitionId, this->numIteratedPages);
59  PDB_COUT << "PartitionedPageIterator: curTypeId=" << this->partitionedFile->getTypeId()
60  << ",curSetId=" << this->partitionedFile->getSetId()
61  << ",curPageId=" << curPageId << "\n";
62 // page is pinned (ref count ++)
63 #ifdef USE_LOCALITY_SET
64  pageToReturn = cache->getPage(this->partitionedFile,
65  this->partitionId,
66  this->numIteratedPages,
67  curPageId,
68  false,
69  set);
70 #else
71  pageToReturn = cache->getPage(this->partitionedFile,
72  this->partitionId,
73  this->numIteratedPages,
74  curPageId,
75  false,
76  nullptr);
77 #endif
78  PDB_COUT << "PartitionedPageIterator: got page" << std::endl;
79  this->numIteratedPages++;
80  }
81  }
82  return pageToReturn;
83 }
84 
89  if (this->numIteratedPages < this->numPages) {
90  return true;
91  } else {
92  return false;
93  }
94 }
shared_ptr< PDBPage > PDBPagePtr
Definition: PDBPage.h:32
shared_ptr< PageCache > PageCachePtr
Definition: PageCache.h:39
unsigned int PageID
Definition: DataTypes.h:26
shared_ptr< PDBFileInterface > PDBFilePtr
Definition: PDBFile.h:29
#define PDB_COUT
Definition: PDBDebug.h:31
unsigned int FilePartitionID
Definition: DataTypes.h:32
PartitionPageIterator(PageCachePtr cache, PDBFilePtr file, FilePartitionID partitionId, UserSet *set=nullptr)
PartitionedFilePtr partitionedFile