Skip to content

Commit

Permalink
Reorganized sequence of operations on header
Browse files Browse the repository at this point in the history
  • Loading branch information
Snafkin547 committed Sep 18, 2024
1 parent 32af8ef commit fae09c3
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions src/tests/c_api/test_join_sail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ int main(int argc, char** argv) {
js1_header.push_back(curr_header);
}

// Send header to P2
MPI_Send(js1_header_toSend.data(), js1_header_toSend.size(), MPI_LONG_LONG, 1, HEADER_TAG, MPI_COMM_WORLD);

// Receive P2's header and convert to string
std::vector<long long> js2_header_toReceive(COLS2);
MPI_Recv(js2_header_toReceive.data(), COLS2, MPI_LONG_LONG, 1, HEADER_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);

std::vector<std::string> js2_header;
for(size_t i = 0; i<js2_header_toReceive.size(); i++){
std::string curr_header = decodeIntToString(js2_header_toReceive[i]);
js2_header.push_back(curr_header);
}

// Organize body
ojson js1 = ojson::array();
for (size_t i = 1; i < js1_orig.size(); i++) {
Expand Down Expand Up @@ -239,18 +252,6 @@ int main(int argc, char** argv) {

// JSON object to hold the results
jsoncons::json output_json = jsoncons::json::array();

MPI_Send(js1_header_toSend.data(), js1_header_toSend.size(), MPI_LONG_LONG, 1, HEADER_TAG, MPI_COMM_WORLD);

// Receive P2's header and convert to string
std::vector<long long> js2_header_toReceive(COLS2);
MPI_Recv(js2_header_toReceive.data(), COLS2, MPI_LONG_LONG, 1, HEADER_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);

std::vector<std::string> js2_header;
for(size_t i = 0; i<js2_header_toReceive.size(); i++){
std::string curr_header = decodeIntToString(js2_header_toReceive[i]);
js2_header.push_back(curr_header);
}

// Construct json for the body part
for (int i = 0; i < size_to_receive; i++) {
Expand Down Expand Up @@ -309,6 +310,19 @@ int main(int argc, char** argv) {
std::cout << curr_header << ", ";
}

// Receive P1's header and convert to string
std::vector<long long> js1_header_toReceive(COLS1);
MPI_Recv(js1_header_toReceive.data(), COLS1, MPI_LONG_LONG, 0, HEADER_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);

std::vector<std::string> js1_header;
for(size_t i = 0; i<js1_header_toReceive.size(); i++){
std::string currHeader = decodeIntToString(js1_header_toReceive[i]);
js1_header.push_back(currHeader);
}

// Send header to P1
MPI_Send(js2_header_toSend.data(), js2_header_toSend.size(), MPI_LONG_LONG, 0, HEADER_TAG, MPI_COMM_WORLD);

// Organize body
ojson js2 = ojson::array();
for (int i = 1; i < js2_orig.size(); i++) {
Expand Down Expand Up @@ -428,18 +442,6 @@ int main(int argc, char** argv) {
std::cout << "/// Joined Table ///" << std::endl;
jsoncons::json output_json = jsoncons::json::array();

// Receive P1's header and convert to string
std::vector<long long> js1_header_toReceive(COLS1);
MPI_Recv(js1_header_toReceive.data(), COLS1, MPI_LONG_LONG, 0, HEADER_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);

std::vector<std::string> js1_header;
for(size_t i = 0; i<js1_header_toReceive.size(); i++){
std::string currHeader = decodeIntToString(js1_header_toReceive[i]);
js1_header.push_back(currHeader);
}

MPI_Send(js2_header_toSend.data(), js2_header_toSend.size(), MPI_LONG_LONG, 0, HEADER_TAG, MPI_COMM_WORLD);

// Print P1 header
for (size_t i = 1; i< js1_header.size(); i++){
std::string curr = js1_header[i];
Expand Down

0 comments on commit fae09c3

Please sign in to comment.