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
PageHandle.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 #ifndef PAGE_HANDLE_CC
20 #define PAGE_HANDLE_CC
21 
22 #include "PageHandle.h"
23 #include <iostream>
24 
25 
27  this->proxy = proxy;
28  this->page = page;
29 }
30 
32 
34  if (this->page->isPinned()) {
35  return;
36  }
37  // temp page
38  if ((this->page->getDbID() == 0) && (this->page->getTypeID() == 0)) {
39  proxy->pinTempPage(page->getSetID(), page->getPageID(), this->page);
40  }
41  // user page
42  else {
43  proxy->pinUserPage(page->getNodeID(),
44  page->getDbID(),
45  page->getTypeID(),
46  page->getSetID(),
47  page->getPageID(),
48  this->page);
49  }
50 }
51 
53  if (!this->page->isPinned()) {
54  cout << "PageHandle: can not unpin because page is already unpinned.\n";
55  return;
56  }
57  // temp page
58  if ((this->page->getDbID() == 0) && (this->page->getTypeID() == 0)) {
59  proxy->unpinTempPage(page->getSetID(), page);
60  }
61  // user page
62  else {
63  proxy->unpinUserPage(
64  page->getNodeID(), page->getDbID(), page->getTypeID(), page->getSetID(), page);
65  }
66  this->page->setPinned(false);
67 }
68 
69 
71  return this->page->getRawBytes();
72 }
73 
75  return this->page->getBytes();
76 }
77 
79  return this->page->getRawSize();
80 }
81 
83  return this->page->getSize();
84 }
85 
87  return this->page->getPageID();
88 }
89 
90 #endif
shared_ptr< PDBPage > PDBPagePtr
Definition: PDBPage.h:32
size_t getWritableSize()
Definition: PageHandle.cc:82
shared_ptr< DataProxy > DataProxyPtr
Definition: DataProxy.h:30
void * getRAM()
Definition: PageHandle.cc:70
void unpin()
Definition: PageHandle.cc:52
DataProxyPtr proxy
Definition: PageHandle.h:67
PageHandle(DataProxyPtr proxy, PDBPagePtr page)
Definition: PageHandle.cc:26
unsigned int PageID
Definition: DataTypes.h:26
PDBPagePtr page
Definition: PageHandle.h:68
PageID getPageID()
Definition: PageHandle.cc:86
size_t getSize()
Definition: PageHandle.cc:78
void * getWritableBytes()
Definition: PageHandle.cc:74
void pin()
Definition: PageHandle.cc:33