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
JoinMap.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 JOIN_MAP_H
20 #define JOIN_MAP_H
21 
22 // PRELOAD %JoinMap <Nothing>%
23 
24 #include "Object.h"
25 #include "Handle.h"
26 #include "JoinPairArray.h"
27 
28 template <typename StoredType>
30 
31 namespace pdb {
32 
33 // This is the Map type used to power joins
34 
35 template <class ValueType>
36 class JoinMap : public Object {
37 
38 private:
39  // this is where the data are actually stored
41 
42  // size of ValueType
43  size_t objectSize;
44 
45  // my partition id
46  size_t partitionId;
47 
48  // number of partitions (per node)
50 
51 public:
53 
54  // this constructor creates a map with specified slots, partitionId and numPartitions
55  JoinMap(uint32_t initSize, size_t partitionId, int numPartitions);
56 
57  // this constructor pre-allocates initSize slots... initSize must be a power of two
58  JoinMap(uint32_t initSize);
59 
60  // this constructor creates a map with a single slot
61  JoinMap();
62 
63  // destructor
64  ~JoinMap();
65 
66  // allows us to access all of the records with a particular hash value
67  JoinRecordList<ValueType> lookup(const size_t& which);
68 
69  // adds a new value at position which
70  ValueType& push(const size_t& which);
71 
72  // clears the particular key from the map, destructing both the key and the value.
73  // This is typically used when an out-of-memory
74  // exception is thrown when we try to add to the hash table, and we want to immediately clear
75  // the last item added.
76  void setUnused(const size_t& clearMe);
77 
78  // returns the number of elements in the map
79  size_t size() const;
80 
81  // returns 0 if this entry is undefined; 1 if it is defined
82  int count(const size_t& which);
83 
84  // these are used for iteration
87 
88 
89  // JiaNote: add partition id to enable hash partitioned join
90  size_t getPartitionId();
91  void setPartitionId(size_t partitionId);
92  int getNumPartitions();
94 
95  // JiaNote: add this to enable combination of two JoinMaps
96  size_t getObjectSize();
97  void setObjectSize();
98 };
99 }
100 
101 #include "JoinMap.cc"
102 
103 #endif
Handle< JoinPairArray< ValueType > > myArray
Definition: JoinMap.h:40
#define ENABLE_DEEP_COPY
Definition: DeepCopy.h:52
size_t getObjectSize()
Definition: JoinMap.cc:130
void setUnused(const size_t &clearMe)
Definition: JoinMap.cc:68
size_t size() const
Definition: JoinMap.cc:92
int getNumPartitions()
Definition: JoinMap.cc:119
JoinMapIterator< ValueType > begin()
Definition: JoinMap.cc:97
int numPartitions
Definition: JoinMap.h:49
void setPartitionId(size_t partitionId)
Definition: JoinMap.cc:114
void setObjectSize()
Definition: JoinMap.cc:135
size_t partitionId
Definition: JoinMap.h:46
void setNumPartitions(int numPartitions)
Definition: JoinMap.cc:124
size_t objectSize
Definition: JoinMap.h:43
JoinRecordList< ValueType > lookup(const size_t &which)
Definition: JoinMap.cc:82
ValueType & push(const size_t &which)
Definition: JoinMap.cc:73
int count(const size_t &which)
Definition: JoinMap.cc:87
JoinMapIterator< ValueType > end()
Definition: JoinMap.cc:103
size_t getPartitionId()
Definition: JoinMap.cc:109