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
HashSet.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 /*
20  * HashSet is an in-memory set for implementing Pangaea hash map.
21  */
22 
23 
24 #ifndef HASHSET_H
25 #define HASHSET_H
26 
27 #include "PageCache.h"
28 #include "PDBLogger.h"
29 #include "DataTypes.h"
30 #include "LocalitySet.h"
31 #include <memory>
32 #include <string>
33 using namespace std;
34 
35 class HashSet;
36 typedef shared_ptr<HashSet> HashSetPtr;
37 
38 class HashSet : public LocalitySet {
39 public:
41  PDBLoggerPtr logger,
42  size_t pageSize,
43  NodeID nodeId,
44  DatabaseID dbId,
45  UserTypeID typeId,
46  SetID setId,
47  string setName)
49  this->cache = cache;
50  this->logger = logger;
51  this->pageSize = pageSize;
52  this->nodeId = nodeId;
53  this->dbId = dbId;
54  this->typeId = typeId;
55  this->setId = setId;
56  this->pageId = 0;
57  this->setName = setName;
58  }
59 
60  ~HashSet() {}
61 
62  void clear() {}
63 
65  return this->dbId;
66  }
67 
69  return this->typeId;
70  }
71 
73  return this->setId;
74  }
75 
76  string getSetName() {
77  return this->setName;
78  }
79 
81  CacheKey key;
82  key.dbId = this->dbId;
83  key.typeId = this->typeId;
84  key.setId = this->setId;
85  key.pageId = this->pageId;
86  this->pageId++;
87  // PDBPagePtr page = this->cache->getNewPageNonBlocking(this->nodeId, key, this);
88  PDBPagePtr page = this->cache->getNewPage(this->nodeId, key, this);
89  return page;
90  }
91 
92  void unpinPage(PageID pageId) {
93  CacheKey key;
94  key.dbId = this->dbId;
95  key.typeId = this->typeId;
96  key.setId = this->setId;
97  key.pageId = pageId;
98  this->cache->decPageRefCount(key);
99  }
100 
101 private:
104  size_t pageSize;
110  string setName;
111 };
112 
113 #endif
SetID getSetID()
Definition: HashSet.h:72
PDBLoggerPtr logger
Definition: HashSet.h:102
SetID setId
Definition: DataTypes.h:87
unsigned int SetID
Definition: DataTypes.h:31
shared_ptr< PDBPage > PDBPagePtr
Definition: PDBPage.h:32
string getSetName()
Definition: HashSet.h:76
SetID setId
Definition: HashSet.h:108
~HashSet()
Definition: HashSet.h:60
string setName
Definition: HashSet.h:110
shared_ptr< PageCache > PageCachePtr
Definition: PageCache.h:39
shared_ptr< HashSet > HashSetPtr
Definition: HashSet.h:35
DatabaseID dbId
Definition: DataTypes.h:85
void unpinPage(PageID pageId)
Definition: HashSet.h:92
size_t pageSize
Definition: HashSet.h:104
unsigned int NodeID
Definition: DataTypes.h:27
UserTypeID getUserTypeID()
Definition: HashSet.h:68
unsigned int DatabaseID
Definition: DataTypes.h:29
unsigned int PageID
Definition: DataTypes.h:26
UserTypeID typeId
Definition: HashSet.h:107
PageID pageId
Definition: DataTypes.h:88
PDBPagePtr addPage()
Definition: HashSet.h:80
HashSet(PageCachePtr cache, PDBLoggerPtr logger, size_t pageSize, NodeID nodeId, DatabaseID dbId, UserTypeID typeId, SetID setId, string setName)
Definition: HashSet.h:40
void clear()
Definition: HashSet.h:62
NodeID nodeId
Definition: HashSet.h:105
DatabaseID getDatabaseID()
Definition: HashSet.h:64
PageID pageId
Definition: HashSet.h:109
std::shared_ptr< PDBLogger > PDBLoggerPtr
Definition: PDBLogger.h:40
PageCachePtr cache
Definition: HashSet.h:103
UserTypeID typeId
Definition: DataTypes.h:86
DatabaseID dbId
Definition: HashSet.h:106
unsigned int UserTypeID
Definition: DataTypes.h:25
Definition: DataTypes.h:52