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
LocalitySet.h
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 LOCALITY_SET_H
20 #define LOCALITY_SET_H
21 
22 #include "PDBPage.h"
23 #include "DataTypes.h"
24 #include <list>
25 #include <vector>
26 #include <memory>
27 using namespace std;
28 
30 typedef shared_ptr<LocalitySet> LocalitySetPtr;
36 class LocalitySet {
37 public:
38  /*
39  * Constructor
40  */
41  LocalitySet(LocalityType localityType,
42  LocalitySetReplacementPolicy replacementPolicy,
43  OperationType operationType,
44  DurabilityType durabilityType,
45  PersistenceType persistenceType);
46 
47  /*
48  * Destructor
49  */
50  ~LocalitySet();
51 
52  /*
53  * To add a newly cached page to the locality set
54  */
55  void addCachedPage(PDBPagePtr page);
56 
57  /*
58  * To update a cached page with new access sequenceId
59  */
60  void updateCachedPage(PDBPagePtr page);
61 
62  /*
63  * To remove a cached page
64  */
65  void removeCachedPage(PDBPagePtr page);
66 
67  /*
68  * To select a page from the locality set for replacement based on the replacement policy, and
69  * also remove the page from the list.
70  */
71  PDBPagePtr selectPageForReplacement();
72 
73  vector<PDBPagePtr>* selectPagesForReplacement();
74 
75  void pin(LocalitySetReplacementPolicy policy, OperationType operationType);
76 
77  void unpin();
78 
79 
80  /*
81  * Getters/Setters
82  */
83 
84  LocalityType getLocalityType();
85 
86  void setLocalityType(LocalityType type);
87 
88  LocalitySetReplacementPolicy getReplacementPolicy();
89 
90  void setReplacementPolicy(LocalitySetReplacementPolicy policy);
91 
92  OperationType getOperationType();
93 
94  void setOperationType(OperationType type);
95 
96  DurabilityType getDurabilityType();
97 
98  void setDurabilityType(DurabilityType type);
99 
100  PersistenceType getPersistenceType();
101 
102  void setPersistenceType(PersistenceType type);
103 
104  bool isLifetimeEnded();
105 
106  void setLifetimeEnd(bool lifetimeEnded);
107 
108 protected:
113  list<PDBPagePtr>* cachedPages;
114 
115 
116  /*
117  * Types of the data in the set:
118  * 1. JobData: job input/output
119  * 2. ShuffleData: shuffle data
120  * 3. HashPartitionData: hash partition data
121  * 4. PartialAggregationData: spilled key-value pairs from a hash partition
122  *
123  * This property should be set at construction time.
124  */
126 
127  /*
128  * Replacement policy in the set:
129  * 1. LRU
130  * 2. MRU
131  * 3. Random
132  *
133  * This property should be set at construction time, and can be modified at pin time.
134  */
136 
137  /*
138  * On-going operation of the set:
139  * 1. Read
140  * 2. RepeatedRead
141  * 3. Write
142  *
143  * This property should be set at construction time, and can be modified at pin time.
144  */
146 
155 
164 
171 };
172 
173 
174 #endif
LocalitySetReplacementPolicy replacementPolicy
Definition: LocalitySet.h:135
shared_ptr< PDBPage > PDBPagePtr
Definition: PDBPage.h:32
OperationType
Definition: DataTypes.h:57
LocalityType localityType
Definition: LocalitySet.h:125
OperationType operationType
Definition: LocalitySet.h:145
LocalityType
Definition: DataTypes.h:50
bool lifetimeEnded
Definition: LocalitySet.h:170
DurabilityType
Definition: DataTypes.h:59
LocalitySetReplacementPolicy
Definition: DataTypes.h:52
PersistenceType
Definition: DataTypes.h:68
list< PDBPagePtr > * cachedPages
Definition: LocalitySet.h:113
shared_ptr< LocalitySet > LocalitySetPtr
Definition: LocalitySet.h:29
DurabilityType durabilityType
Definition: LocalitySet.h:154
PersistenceType persistenceType
Definition: LocalitySet.h:163