2 #ifndef JOIN_PAIR_ARRAY_CC
3 #define JOIN_PAIR_ARRAY_CC
10 #include <type_traits>
20 #define JM_UNUSED 493295393
23 #define JM_FILL_FACTOR .667
26 #define JM_GET_HASH(data, i) (*((size_t*)(((char*)data) + (i * objSize))))
27 #define JM_GET_HASH_PTR(data, i) ((size_t*)(((char*)data) + (i * objSize)))
28 #define JM_GET_NEXT_PTR(data, i) ((uint32_t*)(((char*)data) + sizeof(size_t) + (i * objSize)))
29 #define JM_GET_VALUE_PTR(data, i) \
30 ((void*)(((char*)data) + sizeof(size_t) + sizeof(uint32_t) + (i * objSize)))
31 #define JM_GET_NEXT(data, i) (*((uint32_t*)(((char*)data) + sizeof(size_t) + (i * objSize))))
32 #define JM_GET_VALUE(data, i, type) \
33 (*((type*)(((char*)data) + sizeof(size_t) + sizeof(uint32_t) + (i * objSize))))
40 template <
class ValueType>
74 uint32_t objSize = toMe.
objSize;
77 for (
int i = 0; i < toMe.
numSlots; i++) {
101 template <
class ValueType>
103 setUpAndCopyFrom(
this, &toMe);
106 template <
class ValueType>
110 size_t hashVal = me ==
JM_UNUSED ? 858931273 : me;
113 size_t slot = hashVal % (numSlots - 1);
116 for (
size_t slotsChecked = 0; slotsChecked < numSlots; slotsChecked++) {
125 return 1 + overflows[
JM_GET_NEXT(data, slot)].size();
134 if (slot == numSlots - 1)
143 std::cout <<
"Warning: Ran off the end of the hash table!!\n";
147 template <
class ValueType>
151 size_t hashVal = me ==
JM_UNUSED ? 858931273 : me;
154 size_t slot = hashVal % (numSlots - 1);
156 for (
size_t slotsChecked = 0; slotsChecked < numSlots; slotsChecked++) {
183 if (slot == numSlots - 1)
192 std::cout <<
"Fatal Error: Ran off the end of the hash table!!\n";
196 template <
class ValueType>
199 size_t hashVal = me ==
JM_UNUSED ? 858931273 : me;
202 size_t slot = hashVal % (numSlots - 1);
205 for (
size_t slotsChecked = 0; slotsChecked < numSlots; slotsChecked++) {
216 if (slot == numSlots - 1)
225 std::cout <<
"Fatal Error: Ran off the end of the hash table!!\n";
230 template <
class ValueType>
237 size_t hashVal = me ==
JM_UNUSED ? 858931273 : me;
240 size_t slot = hashVal % (numSlots - 1);
243 for (
size_t slotsChecked = 0; slotsChecked < numSlots; slotsChecked++) {
281 if (slot == numSlots - 1)
290 std::cout <<
"Fatal Error: Ran off the end of the hash table!!\n";
294 template <
class ValueType>
300 for (
unsigned int pow = 0; pow <= 31; pow++) {
301 if (val >= numSlotsIn) {
310 std::cout <<
"Fatal Error: Bad: could not get the correct size for the array\n";
319 for (
int i = 0; i <
numSlots; i++) {
325 template <
class ValueType>
327 return usedSlots >= maxSlots;
330 template <
class ValueType>
334 valueTypeInfo.setup<ValueType>();
352 template <
class ValueType>
356 if (!valueTypeInfo.descendsFromObject())
360 for (uint32_t i = 0; i < numSlots; i++) {
367 template <
class ValueType>
369 PDB_COUT <<
"bytes available in current allocator block: "
372 PDB_COUT <<
"inactive blocks: " << out << std::endl;
373 PDB_COUT <<
"usedSlots = " << usedSlots <<
", maxSlots = " << maxSlots << std::endl;
374 uint32_t howMany = numSlots * 2;
375 PDB_COUT <<
"doubleArray to " << howMany << std::endl;
378 makeObjectWithExtraStorage<JoinPairArray<ValueType>>(objSize * howMany, howMany);
384 for (uint32_t i = 0; i < numSlots; i++) {
389 ValueType* temp = &(newOne.push(
JM_GET_HASH(data, i)));
392 char* whereNextIs = ((
char*)temp) -
sizeof(uint32_t);
397 newOne.overflows = overflows;
403 template <
class ValueType>
408 template <
class ValueType>
413 template <
class ValueType>
419 template <
class ValueType>
421 : whichOne(whichOne), parent(parent) {}
423 template <
class ValueType>
425 uint32_t objSize = parent.objSize;
429 template <
class ValueType>
433 uint32_t objSize = parent.objSize;
437 if (
JM_GET_NEXT(parent.data, whichOne) != UINT32_MAX) {
438 if (
JM_GET_NEXT(parent.data, whichOne) < parent.overflows.size()) {
439 return parent.overflows[
JM_GET_NEXT(parent.data, whichOne)].size() + 1;
441 std::cout <<
"not invalid slot, return 0" << std::endl;
448 return JM_GET_NEXT(parent.data, whichOne) == UINT32_MAX
450 : parent.overflows[
JM_GET_NEXT(parent.data, whichOne)].size() + 1;
453 template <
class ValueType>
455 uint32_t objSize = parent.objSize;
456 return i == 0 ?
JM_GET_VALUE(parent.data, whichOne, ValueType)
457 : parent.overflows[
JM_GET_NEXT(parent.data, whichOne)][i - 1];
460 template <
class ValueType>
462 : iterateMe(&(*iterateMeIn)) {
474 template <
class ValueType>
476 : iterateMe(&(*iterateMeIn)) {
480 template <
class ValueType>
487 template <
class ValueType>
492 int objSize = iterateMe->objSize;
496 if (slot == iterateMe->numSlots)
500 template <
class ValueType>
507 template <
class ValueType>
509 if (!done || !me.
done)
JoinRecordList(uint32_t whichOne, JoinPairArray< ValueType > &parent)
JoinRecordList< ValueType > lookup(const size_t &which)
bool operator!=(const JoinMapIterator &me) const
#define JM_GET_VALUE_PTR(data, i)
Handle< JoinPairArray< ValueType > > doubleArray()
Vector< Vector< ValueType > > overflows
void setUnused(const size_t &clearMe)
Allocator & getAllocator()
size_t getSize(void *forMe)
PDBTemplateBase valueTypeInfo
void deleter(void *deleteMe, ObjType *dummy)
void deleteObject(void *deleteMe)
ValueType & push(const size_t &which)
ValueType & operator[](const size_t i)
size_t getBytesAvailableInCurrentAllocatorBlock()
void setUpAndCopyFrom(void *target, void *source) const
void setUpAndCopyFromConstituentObject(void *target, void *source) const
#define JM_GET_NEXT(data, i)
int count(const size_t &which)
void push_back(const TypeContained &val)
JoinPairArray< ValueType > * iterateMe
bool descendsFromObject() const
JoinRecordList< ValueType > * operator*()
#define JM_GET_VALUE(data, i, type)
#define JM_GET_HASH(data, i)
JoinMapRecordClass< Nothing > data[0]
std::string printInactiveBlocks()