-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBasicHashJoin.h
99 lines (82 loc) · 2.21 KB
/
BasicHashJoin.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef _BASICHASHJOIN_H_
#define _BASICHASHJOIN_H_
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <tbb/concurrent_hash_map.h>
#include <tbb/parallel_for.h>
#include <boost/foreach.hpp>
extern "C"
{
#include "Debug.h"
#include "Errors.h"
#include <stdio.h>
#include <stdlib.h>
typedef unsigned int uint;
typedef unsigned long ulong;
}
struct Record
{
//uint *data;
ulong *data;
};
typedef tbb::concurrent_hash_map<ulong, std::vector<Record*> > MAP;
//aisha typedef tbb::concurrent_hash_map<ulong, std::vector<Record> > MAP;
struct OuterRelation
{
int isEmpty;
pthread_t tid;
short num_keys;
MAP hash_table;
pthread_t subQ_tid;
short *join_keys_ndxs;
};
struct InnerRelation
{
int isEmpty;
pthread_t tid;
short num_keys;
MAP hash_table;
pthread_t ngbr_tid;
short *join_keys_ndxs;
};
struct Output
{
char *filename;
FILE *stream;
short num_cols;
short num_join_keys;
short *order;
};
struct Args
{
long chunk_size;
long offset;
void *instream;
FILE *outstream;
};
void joinResultSets (int my_worker_id, short *my_num_keys, char **my_keys[],
short ngbr_num_keys, char *ngbr_keys[], char *ngbr_result_set,
short final_num_keys, char *final_keys[], pthread_t subQ_tid, pthread_t ngbr_tid);
void mergeKeys(char **my_keys[], char *ngbr_keys[], short final_num_keys, char *final_keys[]);
void findJoinKeys (char *keys1[], char *keys2[]);
short countJoinKeys (char *keys1[], char *keys2[]);
int isEmpty (char *result_set);
void finalizeJoin ();
void initDatastructures ();
void clean ();
void *partitionOuterRelation (void *filename);
void *partitionInnerRelation (void *relation);
void *partitionOuterRelationHelper (void *arg);
void *partitionInnerRelationHelper (void *arg);
void bubbleSort (char *elems[], int num_elems);
void matchRelations ();
void matchRecords (std::vector<Record*> list1, std::vector<Record*> list2);
void matchRecord (Record* record1, Record* record2);
void writeRecord (Record* record1, Record* record2);
Record *createNewRecord (short num_keys);
void probe (Record *record1, ulong key, FILE *stream);
void freeRecord (Record **record);
void getUsage (char *task);
#endif