-
Notifications
You must be signed in to change notification settings - Fork 59
Open
Description
Dear ladnir,
I am working on implementing a program that receives two tables A and B as input and computes the sum per category. The input tables are of the following structure:
A:
| key | cat |
|---|---|
| 1 | 1 |
| 2 | 1 |
| 3 | 2 |
B:
| key | val |
|---|---|
| 1 | 10 |
| 2 | 20 |
| 3 | 5 |
In this example, the computed result should be the following table:
C:
| cat | val |
|---|---|
| 1 | 30 |
| 2 | 5 |
Currently, this is my code:
#include <iostream>
#include <vector>
#include <assert.h>
#include "xtabs.h"
#include "aby3-DB/DBServer.h"
#include <cryptoTools/Network/IOService.h>
#include "aby3/sh3/Sh3Runtime.h"
#include "aby3/sh3/Sh3Encryptor.h"
#include "aby3/sh3/Sh3Evaluator.h"
using namespace oc;
using namespace aby3;
using namespace std;
void xtabs_test(u64 partyIdx, std::vector<int> ids, std::vector<int> values, int nCats)
{
std::cout << "testing xtabs..." << std::endl;
IOService ios;
DBServer srv;
PRNG prng(ZeroBlock);
if (partyIdx == 0)
{
Session s01(ios, "127.0.0.1:3030", SessionMode::Server, "01");
Session s02(ios, "127.0.0.1:3031", SessionMode::Server, "02");
srv.init(0, s02, s01, prng);
}
else if (partyIdx == 1)
{
Session s10(ios, "127.0.0.1:3030", SessionMode::Client, "01");
Session s12(ios, "127.0.0.1:3032", SessionMode::Server, "12");
srv.init(1, s10, s12, prng);
}
else
{
Session s20(ios, "127.0.0.1:3031", SessionMode::Client, "02");
Session s21(ios, "127.0.0.1:3032", SessionMode::Client, "12");
srv.init(2, s21, s20, prng);
}
auto keyBitCount = srv.mKeyBitCount;
std::vector<ColumnInfo>
catCols = {ColumnInfo{"key", TypeID::IntID, keyBitCount},
ColumnInfo{"cat", TypeID::IntID, keyBitCount}},
valCols = {ColumnInfo{"key", TypeID::IntID, keyBitCount},
ColumnInfo{"val", TypeID::IntID, keyBitCount}};
u64 rows = ids.size();
assert(ids.size() == rows);
assert(values.size() == rows);
Table catData(rows, catCols), valData(rows, valCols);
// initializes data into Table (still in the clear)
for (u64 i = 0; i < rows; ++i)
{
if (partyIdx == 0)
{
catData.mColumns[0].mData(i, 0) = ids[i];
catData.mColumns[0].mData(i, 1) = values[i];
}
else if (partyIdx == 1)
{
valData.mColumns[0].mData(i, 0) = ids[i];
valData.mColumns[0].mData(i, 1) = values[i];
}
}
SharedTable catTable, valTable;
catTable = (partyIdx == 0) ? srv.localInput(catData) : srv.remoteInput(0);
valTable = (partyIdx == 1) ? srv.localInput(valData) : srv.remoteInput(1);
auto res = srv.join(catTable["key"], valTable["key"], {catTable["cat"], valTable["val"]});
cout << "not reached " << endl;
}
This is not yet finished. As you see, I want to perform a join operation and later sum op the values per category (not implemented yet).
Unfortunately, the last line is not reached, as I get an error on the previous line:
testing xtabs...
testing xtabs...
testing xtabs...
~~~~~~~~~~~~~~~~ Runtime not empty!!! ~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~ Runtime not empty!!! ~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~ Runtime not empty!!! ~~~~~~~~~~~~~~~~
std::bad_alloc
std::bad_array_new_length
std::bad_array_new_length
Do you have an idea why this error pops up? I have read the source code of aby3 but was unable to get to the root of the problem.
Best, Juri
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels