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.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 JOIN_MAP_CC
20 #define JOIN_MAP_CC
21 
22 #include "InterfaceFunctions.h"
23 #include "JoinMap.h"
24 
25 namespace pdb {
26 
27 template <class ValueType>
28 JoinMap<ValueType>::JoinMap(uint32_t initSize, size_t partitionId, int numPartitions) {
29 
30  if (initSize < 2) {
31  initSize = 2;
32  }
33 
34  // this way, we'll allocate extra bytes on the end of the array
36  size_t size = temp.getObjSize();
37  myArray = makeObjectWithExtraStorage<JoinPairArray<ValueType>>(size * initSize, initSize);
38  this->partitionId = partitionId;
39  this->numPartitions = numPartitions;
40 }
41 
42 
43 template <class ValueType>
44 JoinMap<ValueType>::JoinMap(uint32_t initSize) {
45 
46  if (initSize < 2) {
47  initSize = 2;
48  }
49 
50  // this way, we'll allocate extra bytes on the end of the array
52  size_t size = temp.getObjSize();
53  myArray = makeObjectWithExtraStorage<JoinPairArray<ValueType>>(size * initSize, initSize);
54 }
55 
56 template <class ValueType>
58 
60  size_t size = temp.getObjSize();
61  myArray = makeObjectWithExtraStorage<JoinPairArray<ValueType>>(size * 2, 2);
62 }
63 
64 template <class ValueType>
66 
67 template <class ValueType>
68 void JoinMap<ValueType>::setUnused(const size_t& clearMe) {
69  myArray->setUnused(clearMe);
70 }
71 
72 template <class ValueType>
73 ValueType& JoinMap<ValueType>::push(const size_t& me) {
74  if (myArray->isOverFull()) {
75  Handle<JoinPairArray<ValueType>> temp = myArray->doubleArray();
76  myArray = temp;
77  }
78  return myArray->push(me);
79 }
80 
81 template <class ValueType>
83  return myArray->lookup(me);
84 }
85 
86 template <class ValueType>
87 int JoinMap<ValueType>::count(const size_t& which) {
88  return myArray->count(which);
89 }
90 
91 template <class ValueType>
92 size_t JoinMap<ValueType>::size() const {
93  return myArray->numUsedSlots();
94 }
95 
96 template <class ValueType>
98  JoinMapIterator<ValueType> returnVal(myArray, true);
99  return returnVal;
100 }
101 
102 template <class ValueType>
104  JoinMapIterator<ValueType> returnVal(myArray);
105  return returnVal;
106 }
107 
108 template <class ValueType>
110  return this->partitionId;
111 }
112 
113 template <class ValueType>
114 void JoinMap<ValueType>::setPartitionId(size_t partitionId) {
115  this->partitionId = partitionId;
116 }
117 
118 template <class ValueType>
120  return this->numPartitions;
121 }
122 
123 template <class ValueType>
124 void JoinMap<ValueType>::setNumPartitions(int numPartitions) {
125  this->numPartitions = numPartitions;
126 }
127 
128 
129 template <class ValueType>
131  return this->objectSize;
132 }
133 
134 template <class ValueType>
137  size_t objSize = temp.getObjSize();
138  this->objectSize = objSize;
139 }
140 }
141 
142 #endif
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
void setPartitionId(size_t partitionId)
Definition: JoinMap.cc:114
void setObjectSize()
Definition: JoinMap.cc:135
void setNumPartitions(int numPartitions)
Definition: JoinMap.cc:124
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