Commit 251a19a3 authored by yiwenshao's avatar yiwenshao

able to use onionindex in load and store

parent 114f77df
#pragma once #pragma once
/*class metadata_file{
class metadata_files{
public:
string db,table; string db,table;
int num_of_fields; /*selected fields*/
vector<string> field_types; vector<vector<int>> selected_field_types;
vector<int> field_lengths; vector<vector<int>> selected_field_lengths;
vector<string> field_names; vector<vector<string>> selected_field_names;
vector<int> choosen_onions; vector<string> has_salt;
vector<int> dec_onion_index;/*should be 0,1,2,3...*/
std::string serialize_vec_int(std::string s,vector<int> vec_int);
std::string serialize_vec_str(std::string s,vector<string> vec_str);
vector<string> string_to_vec_str(string line);
vector<int> string_to_vec_int(string line);
static bool make_path(std::string directory);
public: public:
void set_db(std::string idb){db=idb;} void set_db(std::string idb){db=idb;}
std::string get_db(){return db;} std::string get_db(){return db;}
void set_table(std::string itable){table=itable;} void set_table(std::string itable){table=itable;}
std::string get_table(){return table;} std::string get_table(){return table;}
void set_db_table(std::string idb,std::string itable){db=idb;table=itable;}
void set_num_of_fields(int num){num_of_fields = num;}
int get_num_of_fields(){return num_of_fields;}
void set_field_types(vector<string> input){field_types = input;}
std::vector<std::string> & get_field_types(){return field_types;}
void set_field_lengths(vector<int> input){field_lengths = input;}
std::vector<int> & get_field_lengths(){return field_lengths;}
void set_field_names(vector<string> input){field_names = input;}
std::vector<std::string> & get_field_names(){return field_names;}
void set_choosen_onions(vector<int> input){choosen_onions = input;}
std::vector<int>& get_choosen_onions(){return choosen_onions;}
void serilize();
void deserialize(std::string filename);
void show();
static bool make_path(std::string directory){
struct stat st;
if(directory.size()==0||directory[0]=='/') return false;
if(directory.back()=='/') directory.pop_back();
int start = 0,next=0;
while(stat(directory.c_str(),&st)==-1&&next!=-1){
next = directory.find('/',start);
if(next!=-1){
string sub = directory.substr(0,next);
if(stat(sub.c_str(),&st)==-1)
mkdir(sub.c_str(),0700);
start = next + 1;
}else{
mkdir(directory.c_str(),0700);
}
}
return true;
}
};
void metadata_file::serilize(){
FILE * localmeta = NULL;
string prefix = string("data/")+db+"/"+table;
make_path(prefix);
localmeta = fopen((prefix+"/metadata.data").c_str(),"w");
string s = string("database:")+db;
s+="\n";
fwrite(s.c_str(),1,s.size(),localmeta);
s = string("table:")+table;
s+="\n";
fwrite(s.c_str(),1,s.size(),localmeta);
s = string("num_of_fields:")+to_string(num_of_fields)+"\n";
fwrite(s.c_str(),1,s.size(),localmeta);
s = string("field_types:");
for(auto item:field_types){
s+=item+=" ";
}
s.back()='\n';
fwrite(s.c_str(),1,s.size(),localmeta);
s = string("field_lengths:"); void set_db_table(std::string idb,std::string itable){db=idb;table=itable;}
for(auto item : field_lengths){
s+=to_string(item)+=" ";
}
s.back()='\n';
fwrite(s.c_str(),1,s.size(),localmeta);
s = string("field_names:");
for(auto item : field_names){
s+=item+=" ";
}
s.back()='\n';
fwrite(s.c_str(),1,s.size(),localmeta);
s = string("choosen_onions:"); void set_selected_field_types(vector<vector<int>> input){selected_field_types = input;}
for(auto item : choosen_onions){ vector<vector<int>> &get_selected_field_types(){return selected_field_types;};
s+=to_string(item)+=" ";
}
s.back()='\n';
fwrite(s.c_str(),1,s.size(),localmeta);
fclose(localmeta);
}
void metadata_file::deserialize(std::string filename){ void set_selected_field_lengths(vector<vector<int>> input){selected_field_lengths = input;}
filename = string("data/")+db+"/"+table+"/"+filename; vector<vector<int>> &get_selected_field_lengths(){return selected_field_lengths;}
std::ifstream infile(filename);
string line;
while(std::getline(infile,line)){
int index = line.find(":");
string head = line.substr(0,index);
if(head=="database"){
set_db(line.substr(index+1));
}else if(head=="table"){
set_table(line.substr(index+1));
}else if(head=="num_of_fields"){
set_num_of_fields(std::stoi(line.substr(index+1)));
}else if(head=="field_types"){
string types = line.substr(index+1);
int start=0,next=0;
std::vector<std::string> tmp;
while((next=types.find(' ',start))!=-1){
string item = types.substr(start,next-start);
tmp.push_back(item);
start = next+1;
}
string item = types.substr(start);
tmp.push_back(item);
set_field_types(tmp);
}else if(head=="field_lengths"){
string lengths = line.substr(index+1);
int start=0,next=0;
std::vector<int> tmp;
while((next=lengths.find(' ',start))!=-1){
string item = lengths.substr(start,next-start);
tmp.push_back(std::stoi(item));
start = next+1;
}
string item = lengths.substr(start);
tmp.push_back(std::stoi(item));
set_field_lengths(tmp);
}else if(head=="field_names"){
std::vector<std::string> tmp;
string names = line.substr(index+1);
int start=0,next=0;
while((next=names.find(' ',start))!=-1){
string item = names.substr(start,next-start);
tmp.push_back(item);
start = next+1;
}
string item = names.substr(start);
tmp.push_back(item);
set_field_names(tmp);
}else if(head=="choosen_onions"){
std::vector<int> tmp;
string c_onions = line.substr(index+1);
int start=0,next=0;
while((next=c_onions.find(' ',start))!=-1){
string item = c_onions.substr(start,next-start);
tmp.push_back(std::stoi(item));
start = next+1;
}
string item = c_onions.substr(start);
tmp.push_back(std::stoi(item));
set_choosen_onions(tmp);
}
}
infile.close();
}
void metadata_file::show(){ void set_selected_field_names(vector<vector<string>> input){selected_field_names = input;}
cout<<db<<endl; vector<vector<string>> &get_selected_field_names(){return selected_field_names;}
cout<<table<<endl;
cout<<num_of_fields<<endl;
for(auto item:field_types){
cout<<item<<"\t";
}
cout<<endl;
for(auto item:field_lengths){
cout<<item<<"\t";
}
cout<<endl;
for(auto item:field_names){
cout<<item<<"\t";
}
cout<<endl;
for(auto item:choosen_onions){
cout<<item<<"\t";
}
cout<<endl;
}
*/
void set_dec_onion_index(vector<int> input){dec_onion_index = input;}
vector<int> &get_dec_onion_index(){return dec_onion_index;}
void set_has_salt(vector<string> input){has_salt = input;}
vector<string> &get_has_salt(){return has_salt;}
/*******************************************************************************************************************/ void serialize();
void deserialize(std::string filename);
};
class metadata_files{ std::string metadata_files::serialize_vec_int(std::string s,vector<int> vec_int){
public:
string db,table;
/*selected fields*/
vector<vector<int>> selected_field_types;
vector<vector<int>> selected_field_lengths;
vector<vector<string>> selected_field_names;
vector<string> has_salt;
vector<int> dec_onion_index;/*should be 0,1,2,3...*/
std::string serialize_vec_int(std::string s,vector<int> vec_int){
s+=":"; s+=":";
for(auto item:vec_int){ for(auto item:vec_int){
s+=to_string(item)+=" "; s+=to_string(item)+=" ";
} }
s.back()='\n'; s.back()='\n';
return s; return s;
} }
std::string serialize_vec_str(std::string s,vector<string> vec_str){ std::string metadata_files::serialize_vec_str(std::string s,vector<string> vec_str){
s+=":"; s+=":";
for(auto item:vec_str){ for(auto item:vec_str){
s+=item+=" "; s+=item+=" ";
} }
s.back()='\n'; s.back()='\n';
return s; return s;
} }
vector<string> string_to_vec_str(string line){
vector<string> metadata_files::string_to_vec_str(string line){
int start=0,next=0; int start=0,next=0;
std::vector<std::string> tmp; std::vector<std::string> tmp;
while((next=line.find(' ',start))!=-1){ while((next=line.find(' ',start))!=-1){
...@@ -220,9 +74,10 @@ public: ...@@ -220,9 +74,10 @@ public:
string item = line.substr(start); string item = line.substr(start);
tmp.push_back(item); tmp.push_back(item);
return tmp; return tmp;
} }
vector<int> string_to_vec_int(string line){ vector<int> metadata_files::string_to_vec_int(string line){
int start=0,next=0; int start=0,next=0;
std::vector<int> tmp; std::vector<int> tmp;
while((next=line.find(' ',start))!=-1){ while((next=line.find(' ',start))!=-1){
...@@ -233,22 +88,10 @@ public: ...@@ -233,22 +88,10 @@ public:
string item = line.substr(start); string item = line.substr(start);
tmp.push_back(std::stoi(item)); tmp.push_back(std::stoi(item));
return tmp; return tmp;
} }
public:
void set_db(std::string idb){db=idb;}
std::string get_db(){return db;}
void set_table(std::string itable){table=itable;}
std::string get_table(){return table;}
void set_db_table(std::string idb,std::string itable){db=idb;table=itable;}
void set_selected_field_types(vector<vector<int>> input){selected_field_types = input;}
void set_selected_field_lengths(vector<vector<int>> input){selected_field_lengths = input;}
void set_selected_field_names(vector<vector<string>> input){selected_field_names = input;}
void set_dec_onion_index(vector<int> input){dec_onion_index = input;}
void set_has_salt(vector<string> input){has_salt = input;}
void serialize();
void deserialize(std::string filename);
static bool make_path(std::string directory){
bool metadata_files::make_path(std::string directory){
struct stat st; struct stat st;
if(directory.size()==0||directory[0]=='/') return false; if(directory.size()==0||directory[0]=='/') return false;
if(directory.back()=='/') directory.pop_back(); if(directory.back()=='/') directory.pop_back();
...@@ -265,8 +108,8 @@ public: ...@@ -265,8 +108,8 @@ public:
} }
} }
return true; return true;
} }
};
void metadata_files::serialize(){ void metadata_files::serialize(){
FILE * localmeta = NULL; FILE * localmeta = NULL;
...@@ -316,9 +159,9 @@ void metadata_files::deserialize(std::string filename){ ...@@ -316,9 +159,9 @@ void metadata_files::deserialize(std::string filename){
string head = line.substr(0,index); string head = line.substr(0,index);
if(head == "INDEX"){ if(head == "INDEX"){
//INIT HERE //INIT HERE
selected_field_types.push_back(vector<int>()); // selected_field_types.push_back(vector<int>());
selected_field_lengths.push_back(vector<int>()); // selected_field_lengths.push_back(vector<int>());
selected_field_names.push_back(vector<string>()); // selected_field_names.push_back(vector<string>());
}else if(head=="database"){ }else if(head=="database"){
set_db(line.substr(index+1)); set_db(line.substr(index+1));
}else if(head=="table"){ }else if(head=="table"){
......
...@@ -54,18 +54,62 @@ vector<T> flat_vec(vector<vector<T>> &input){ ...@@ -54,18 +54,62 @@ vector<T> flat_vec(vector<vector<T>> &input){
} }
return res; return res;
} }
struct batch{
vector<string> field_names;
vector<int> field_types;
vector<int> field_lengths;
};
static vector<vector<string>> load_table_fields(metadata_files & input) { static
batch get_batch(metadata_files & input,std::vector<transField> &tfms){
vector<vector<int>> selected_field_types = input.get_selected_field_types();
vector<vector<int>> selected_field_lengths = input.get_selected_field_lengths();
vector<vector<string>> selected_field_names = input.get_selected_field_names();
vector<int> dec_onion_index = input.get_dec_onion_index();
vector<string> has_salt = input.get_has_salt();
vector<string> field_names;
vector<int> field_types;
vector<int> field_lengths;
for(auto i=0u;i<tfms.size();i++){
int index = dec_onion_index[i];
string dec_field_name = tfms[i].fields[index];
auto f = find(selected_field_names[i].begin(),selected_field_names[i].end(),dec_field_name);
assert(f!=selected_field_names[i].end());
int j = f - selected_field_names[i].begin();
if(has_salt[i]==string("true")){
field_names.push_back(selected_field_names[i][j]);
field_types.push_back(selected_field_types[i][j]);
field_lengths.push_back(selected_field_lengths[i][j]);
field_names.push_back(selected_field_names[i].back());
field_types.push_back(selected_field_types[i].back());
field_lengths.push_back(selected_field_lengths[i].back());
}else{
assert(1==2);
}
}
batch bt;
bt.field_names = field_names;
bt.field_types = field_types;
bt.field_lengths = field_lengths;
return bt;
}
#include <algorithm>
static vector<vector<string>> load_table_fields(metadata_files & input,std::vector<transField> &tfms) {
string db = input.get_db(); string db = input.get_db();
string table = input.get_table(); string table = input.get_table();
vector<vector<string>> res; vector<vector<string>> res;
string prefix = string("data/")+db+"/"+table+"/"; string prefix = string("data/")+db+"/"+table+"/";
vector<string> datafiles; auto bt = get_batch(input,tfms);
auto field_names = flat_vec(input.selected_field_names); vector<string> field_names = bt.field_names;
auto field_types = flat_vec(input.selected_field_types); vector<int> field_types = bt.field_types;
auto field_lengths = flat_vec(input.selected_field_lengths); vector<int> field_lengths = bt.field_lengths;
vector<string> datafiles;
for(auto item:field_names){ for(auto item:field_names){
datafiles.push_back(prefix+item); datafiles.push_back(prefix+item);
} }
...@@ -87,37 +131,32 @@ static vector<vector<string>> load_table_fields(metadata_files & input) { ...@@ -87,37 +131,32 @@ static vector<vector<string>> load_table_fields(metadata_files & input) {
return res; return res;
} }
static ResType load_files(std::string db="tdb", std::string table="student"){ static ResType load_files(std::string db="tdb", std::string table="student"){
std::unique_ptr<SchemaInfo> schema = myLoadSchemaInfo(); std::unique_ptr<SchemaInfo> schema = myLoadSchemaInfo();
//get all the fields in the tables. //get all the fields in the tables.
std::vector<FieldMeta*> fms = getFieldMeta(*schema,db,table); std::vector<FieldMeta*> fms = getFieldMeta(*schema,db,table);
auto res = getTransField(fms); auto res = getTransField(fms);
std::vector<enum_field_types> types;//Added std::vector<enum_field_types> types;//Added
for(auto item:fms){
types.push_back(item->getSqlType());
}//Add new field form FieldMeta
if(types.size()==1){
//to be
}
metadata_files res_meta = load_meta(db,table); metadata_files res_meta = load_meta(db,table);
std::shared_ptr<ReturnMeta> rm = getReturnMeta(fms,res); std::shared_ptr<ReturnMeta> rm = getReturnMeta(fms,res);
//why do we need this?? //why do we need this??
create_embedded_thd(0); create_embedded_thd(0);
rawMySQLReturnValue resraw; rawMySQLReturnValue resraw;
//load fields in the stored file //load fields in the stored file
vector<vector<string>> res_field = load_table_fields(res_meta); vector<vector<string>> res_field = load_table_fields(res_meta,res);
resraw.rowValues = res_field; resraw.rowValues = res_field;
auto field_names = flat_vec(res_meta.selected_field_names);
auto field_types = flat_vec(res_meta.selected_field_types); // auto field_names = flat_vec(res_meta.selected_field_names);
auto field_lengths = flat_vec(res_meta.selected_field_lengths); // auto field_types = flat_vec(res_meta.selected_field_types);
// auto field_lengths = flat_vec(res_meta.selected_field_lengths);
auto bt = get_batch(res_meta,res);
vector<string> field_names = bt.field_names;
vector<int> field_types = bt.field_types;
vector<int> field_lengths = bt.field_lengths;
resraw.fieldNames = field_names; resraw.fieldNames = field_names;
for(unsigned int i=0;i<field_types.size();++i) { for(unsigned int i=0;i<field_types.size();++i){
resraw.fieldTypes.push_back(static_cast<enum_field_types>(field_types[i])); resraw.fieldTypes.push_back(static_cast<enum_field_types>(field_types[i]));
} }
ResType rawtorestype = MygetResTypeFromLuaTable(false, &resraw); ResType rawtorestype = MygetResTypeFromLuaTable(false, &resraw);
......
...@@ -131,8 +131,7 @@ static ...@@ -131,8 +131,7 @@ static
ResType MygetResTypeFromLuaTable(bool isNULL,rawMySQLReturnValue *inRow = NULL,int in_last_insert_id = 0){ ResType MygetResTypeFromLuaTable(bool isNULL,rawMySQLReturnValue *inRow = NULL,int in_last_insert_id = 0){
std::vector<std::string> names; std::vector<std::string> names;
std::vector<enum_field_types> types; std::vector<enum_field_types> types;
std::vector<std::vector<Item *> > rows; std::vector<std::vector<Item *>> rows;
//return NULL restype //return NULL restype
if(isNULL){ if(isNULL){
return ResType(true,0,0,std::move(names), return ResType(true,0,0,std::move(names),
...@@ -151,9 +150,7 @@ ResType MygetResTypeFromLuaTable(bool isNULL,rawMySQLReturnValue *inRow = NULL,i ...@@ -151,9 +150,7 @@ ResType MygetResTypeFromLuaTable(bool isNULL,rawMySQLReturnValue *inRow = NULL,i
} }
rows.push_back(curTempRow); rows.push_back(curTempRow);
} }
return ResType(true, 0 , return ResType(true,0,in_last_insert_id,std::move(names),std::move(types),std::move(rows));
in_last_insert_id, std::move(names),
std::move(types), std::move(rows));
} }
} }
...@@ -323,17 +320,12 @@ ResType decryptResults(const ResType &dbres, const ReturnMeta &rmeta) { ...@@ -323,17 +320,12 @@ ResType decryptResults(const ResType &dbres, const ReturnMeta &rmeta) {
dec_names.push_back(rf.fieldCalled()); dec_names.push_back(rf.fieldCalled());
} }
} }
const unsigned int real_cols = dec_names.size(); const unsigned int real_cols = dec_names.size();
std::vector<std::vector<Item *> > dec_rows(rows); std::vector<std::vector<Item *> > dec_rows(rows);
//real cols depends on plain text names. //real cols depends on plain text names.
for (unsigned int i = 0; i < rows; i++) { for (unsigned int i = 0; i < rows; i++) {
dec_rows[i] = std::vector<Item *>(real_cols); dec_rows[i] = std::vector<Item *>(real_cols);
} }
// //
unsigned int col_index = 0; unsigned int col_index = 0;
for (unsigned int c = 0; c < cols; c++) { for (unsigned int c = 0; c < cols; c++) {
...@@ -341,16 +333,13 @@ ResType decryptResults(const ResType &dbres, const ReturnMeta &rmeta) { ...@@ -341,16 +333,13 @@ ResType decryptResults(const ResType &dbres, const ReturnMeta &rmeta) {
if (rf.getIsSalt()) { if (rf.getIsSalt()) {
continue; continue;
} }
//the key is in fieldMeta //the key is in fieldMeta
FieldMeta *const fm = rf.getOLK().key; FieldMeta *const fm = rf.getOLK().key;
for (unsigned int r = 0; r < rows; r++) { for (unsigned int r = 0; r < rows; r++) {
// //
if (!fm || dbres.rows[r][c]->is_null()) { if (!fm || dbres.rows[r][c]->is_null()) {
dec_rows[r][col_index] = dbres.rows[r][c]; dec_rows[r][col_index] = dbres.rows[r][c];
} else { } else {
uint64_t salt = 0; uint64_t salt = 0;
const int salt_pos = rf.getSaltPosition(); const int salt_pos = rf.getSaltPosition();
//read salt from remote datab for descrypting. //read salt from remote datab for descrypting.
...@@ -360,7 +349,6 @@ ResType decryptResults(const ResType &dbres, const ReturnMeta &rmeta) { ...@@ -360,7 +349,6 @@ ResType decryptResults(const ResType &dbres, const ReturnMeta &rmeta) {
assert_s(!salt_item->null_value, "salt item is null"); assert_s(!salt_item->null_value, "salt item is null");
salt = salt_item->value; salt = salt_item->value;
} }
//specify fieldMeta, onion, and salt should be able to decrpyt //specify fieldMeta, onion, and salt should be able to decrpyt
//peel onion //peel onion
dec_rows[r][col_index] = dec_rows[r][col_index] =
...@@ -369,13 +357,10 @@ ResType decryptResults(const ResType &dbres, const ReturnMeta &rmeta) { ...@@ -369,13 +357,10 @@ ResType decryptResults(const ResType &dbres, const ReturnMeta &rmeta) {
} }
col_index++; col_index++;
} }
std::vector<enum_field_types> types; std::vector<enum_field_types> types;
for(auto item:dec_rows[0]){ for(auto item:dec_rows[0]){
types.push_back(item->field_type()); types.push_back(item->field_type());
} }
//resType is used befor and after descrypting. //resType is used befor and after descrypting.
return ResType(dbres.ok, dbres.affected_rows, dbres.insert_id, return ResType(dbres.ok, dbres.affected_rows, dbres.insert_id,
std::move(dec_names), std::move(dec_names),
...@@ -383,40 +368,6 @@ ResType decryptResults(const ResType &dbres, const ReturnMeta &rmeta) { ...@@ -383,40 +368,6 @@ ResType decryptResults(const ResType &dbres, const ReturnMeta &rmeta) {
std::move(dec_rows)); std::move(dec_rows));
} }
struct meta_file{
string db,table;
int num_of_fields;
vector<string> field_types;
vector<int> field_lengths;
vector<string> field_names;
vector<int> choosen_onions;
void show(){
cout<<db<<endl;
cout<<table<<endl;
cout<<num_of_fields<<endl;
for(auto item:field_types){
cout<<item<<"\t";
}
cout<<endl;
for(auto item:field_lengths){
cout<<item<<"\t";
}
cout<<endl;
for(auto item:field_names){
cout<<item<<"\t";
}
cout<<endl;
for(auto item:choosen_onions){
cout<<item<<"\t";
}
cout<<endl;
}
};
static void init(){ static void init(){
std::string client="192.168.1.1:1234"; std::string client="192.168.1.1:1234";
//one Wrapper per user. //one Wrapper per user.
...@@ -464,11 +415,8 @@ static void construct_insert(rawMySQLReturnValue & str,std::string table,std::ve ...@@ -464,11 +415,8 @@ static void construct_insert(rawMySQLReturnValue & str,std::string table,std::ve
cur+="("; cur+="(";
for(unsigned int j=0u;j<str.rowValues[i].size();j++){ for(unsigned int j=0u;j<str.rowValues[i].size();j++){
if(IS_NUM(str.fieldTypes[j])) { if(IS_NUM(str.fieldTypes[j])) {
// cout<<str.fieldTypes[j]<<endl;
cur+=str.rowValues[i][j]+=","; cur+=str.rowValues[i][j]+=",";
// cout<<"isnum"<<endl;
}else{ }else{
//cur+=string("\"")+=str.rowValues[i][j]+="\",";
int len = str.rowValues[i][j].size(); int len = str.rowValues[i][j].size();
mysql_real_escape_string(globalConn->get_conn(),globalEsp, mysql_real_escape_string(globalConn->get_conn(),globalEsp,
str.rowValues[i][j].c_str(),len); str.rowValues[i][j].c_str(),len);
......
#include "debug/store.hh" #include "debug/store.hh"
#include "debug/common.hh" #include "debug/common.hh"
static void write_meta(rawMySQLReturnValue& resraw,std::vector<transField> &res,string db,string table){ static void write_meta(rawMySQLReturnValue& resraw,std::vector<transField> &res,string db,string table){
metadata_files mf; metadata_files mf;
mf.set_db_table(db,table); mf.set_db_table(db,table);
vector<vector<int>> selected_field_types; vector<vector<int>> selected_field_types;
vector<vector<int>> selected_field_lengths; vector<vector<int>> selected_field_lengths;
vector<vector<string>> selected_field_names; vector<vector<string>> selected_field_names;
vector<vector<int>> selected_onion_index;
vector<int> dec_onion_index; vector<int> dec_onion_index;
vector<string> has_salt; vector<string> has_salt;
unsigned int type_index=0u,length_index=0u;
for(auto item:res){ for(auto item:res){
vector<int> field_types; vector<int> field_types;
vector<int> field_lengths; vector<int> field_lengths;
vector<string> field_names=item.fields;
vector<string> field_names;
//only choosen fields
for(auto i:item.choosenOnions){
field_names.push_back(item.fields[i]);
}
if(item.hasSalt){
field_names.push_back(item.fields.back());
}
int onion_index = item.onionIndex; int onion_index = item.onionIndex;
for(auto tp:resraw.fieldTypes)
field_types.push_back(static_cast<int>(tp)); for(unsigned int i=0u;i<field_names.size();i++){
field_lengths = resraw.lengths; field_types.push_back(static_cast<int>(resraw.fieldTypes[type_index]));
type_index++;
}
// field_lengths = resraw.lengths;
for(unsigned int i=0u;i<field_names.size();i++){
field_lengths.push_back(resraw.lengths[length_index]);
length_index++;
}
if(item.hasSalt){ if(item.hasSalt){
has_salt.push_back("true"); has_salt.push_back("true");
}else has_salt.push_back("false"); }else has_salt.push_back("false");
...@@ -70,6 +86,7 @@ static void store(std::string db, std::string table){ ...@@ -70,6 +86,7 @@ static void store(std::string db, std::string table){
std::vector<FieldMeta*> fms = getFieldMeta(*schema,db,table); std::vector<FieldMeta*> fms = getFieldMeta(*schema,db,table);
//transform the field so that selected onions can be used //transform the field so that selected onions can be used
std::vector<transField> res = getTransField(fms); std::vector<transField> res = getTransField(fms);
for(auto &item:res){ for(auto &item:res){
(void)item; (void)item;
item.choosenOnions.push_back(0); item.choosenOnions.push_back(0);
...@@ -80,7 +97,6 @@ static void store(std::string db, std::string table){ ...@@ -80,7 +97,6 @@ static void store(std::string db, std::string table){
//write the tuples into files //write the tuples into files
write_raw_data_to_files(resraw,res,db,table); write_raw_data_to_files(resraw,res,db,table);
} }
int int
main(int argc, char* argv[]){ main(int argc, char* argv[]){
init(); init();
......
...@@ -60,7 +60,6 @@ struct transField{ ...@@ -60,7 +60,6 @@ struct transField{
vector<int> choosenOnions; vector<int> choosenOnions;
//used to construct return meta //used to construct return meta
int onionIndex = 0; int onionIndex = 0;
int numOfOnions=0;
//onions //onions
std::vector<std::string> fields; std::vector<std::string> fields;
std::vector<onion> onions; std::vector<onion> onions;
...@@ -192,11 +191,6 @@ rawMySQLReturnValue executeAndGetResultRemote(Connect * curConn,std::string quer ...@@ -192,11 +191,6 @@ rawMySQLReturnValue executeAndGetResultRemote(Connect * curConn,std::string quer
return myRaw; return myRaw;
} }
//first step of back //first step of back
static static
std::vector<FieldMeta *> std::vector<FieldMeta *>
...@@ -217,9 +211,6 @@ getFieldMeta(SchemaInfo &schema, ...@@ -217,9 +211,6 @@ getFieldMeta(SchemaInfo &schema,
} }
} }
static std::unique_ptr<SchemaInfo> myLoadSchemaInfo() { static std::unique_ptr<SchemaInfo> myLoadSchemaInfo() {
std::unique_ptr<Connect> e_conn(Connect::getEmbedded(embeddedDir)); std::unique_ptr<Connect> e_conn(Connect::getEmbedded(embeddedDir));
std::unique_ptr<SchemaInfo> schema(new SchemaInfo()); std::unique_ptr<SchemaInfo> schema(new SchemaInfo());
...@@ -283,7 +274,6 @@ std::string getTestQuery(SchemaInfo &schema, std::vector<transField> &tfds, ...@@ -283,7 +274,6 @@ std::string getTestQuery(SchemaInfo &schema, std::vector<transField> &tfds,
res += item.originalFm->getSaltName()+" , "; res += item.originalFm->getSaltName()+" , ";
} }
} }
res = res.substr(0,res.size()-2); res = res.substr(0,res.size()-2);
res = res + "FROM `"+db+std::string("`.`")+annotablename+"`"; res = res + "FROM `"+db+std::string("`.`")+annotablename+"`";
return res; return res;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment