Commit d49b1229 authored by yiwenshao's avatar yiwenshao

tools/final_load and opti_load modify

parent 9fb94e3e
......@@ -360,48 +360,50 @@ main(int argc, char* argv[]){
glog<<"====================start table: "<<table<<"============================"<<"\n";
/*choose decryption onion, load and decrypt to plain text*/
ResType res = load_files(db,table);
if(res.success()) {
glog<<"load_files: "<<
std::to_string(t_init.lap()/1000000u)<<
"##"<<std::to_string(time(NULL))<<"\n";
std::string annoTableName = analysis.getTableMeta(db,table).getAnonTableName();
const std::string head = std::string("INSERT INTO `")+db+"`.`"+annoTableName+"` ";
/*reencryption to get the encrypted insert!!!*/
unsigned int i=0u;
while(true){
List<List_item> newList;
int localCount=0;
for(;i<res.rows.size();i++){
List<Item> * newList0 = processRow(res.rows[i],
res.names,
analysis,db,table);
newList.push_back(newList0);
localCount++;
if(localCount==constGlobalConstants.pipelineCount){
std::ostringstream o;
insertManyValues(o,newList);
std::cout<<(head+o.str())<<std::endl;
i++;
break;
}
}
if(i>=res.rows.size()){
if(localCount!=constGlobalConstants.pipelineCount) {
std::ostringstream o;
insertManyValues(o,newList);
std::cout<<(head+o.str())<<std::endl;
}
if(!res.success()){
glog<<"empty table\n";
continue;
}
glog<<"load_files: "<<
std::to_string(t_init.lap()/1000000u)<<
"##"<<std::to_string(time(NULL))<<"\n";
std::string annoTableName = analysis.getTableMeta(db,table).getAnonTableName();
const std::string head = std::string("INSERT INTO `")+db+"`.`"+annoTableName+"` ";
/*reencryption to get the encrypted insert!!!*/
unsigned int i=0u;
while(true){
List<List_item> newList;
int localCount=0;
for(;i<res.rows.size();i++){
List<Item> * newList0 = processRow(res.rows[i],
res.names,
analysis,db,table);
newList.push_back(newList0);
localCount++;
if(localCount==constGlobalConstants.pipelineCount){
std::ostringstream o;
insertManyValues(o,newList);
std::cout<<(head+o.str())<<std::endl;
i++;
break;
}
}
glog<<"reencryptionAndInsert: "<<
std::to_string(t_init.lap()/1000000u)<<
"##"<<std::to_string(time(NULL))<<"\n";
for(auto item:gcountMap) {
glog<<"onionComputed: "<<
TypeText<onion>::toText(item.first)<<"::"<<
std::to_string(item.second)<<"\n";
}
if(i>=res.rows.size()){
if(localCount!=constGlobalConstants.pipelineCount) {
std::ostringstream o;
insertManyValues(o,newList);
std::cout<<(head+o.str())<<std::endl;
}
break;
}
}
glog<<"reencryptionAndInsert: "<<
std::to_string(t_init.lap()/1000000u)<<
"##"<<std::to_string(time(NULL))<<"\n";
for(auto item:gcountMap) {
glog<<"onionComputed: "<<
TypeText<onion>::toText(item.first)<<"::"<<
std::to_string(item.second)<<"\n";
}
glog<<"====================finish table: "<<table<<"============================"<<"\n";
gcountMap.clear();
......
......@@ -18,12 +18,12 @@
#include "util/timer.hh"
#include "util/log.hh"
using std::cout;
using std::cin;
using std::endl;
using std::vector;
using std::string;
using std::to_string;
struct batch{
vector<string> field_names;
vector<int> field_types;
vector<int> field_lengths;
};
char * globalEsp=NULL;
int num_of_pipe = 4;
//global map, for each client, we have one WrapperState which contains ProxyState.
......@@ -36,22 +36,15 @@ std::string logfileName = logfilePrefix+constGlobalConstants.logFile+std::to_str
static
logToFile glog(logfileName);
//This connection mimics the behaviour of MySQL-Proxy
Connect *globalConn;
fullBackUp *gfb;
struct batch{
vector<string> field_names;
vector<int> field_types;
vector<int> field_lengths;
};
std::map<onion,unsigned long> gcountMap;
batch *ggbt;
static
std::vector<std::string>
getDbTables(std::string db) {
......@@ -61,7 +54,6 @@ getDbTables(std::string db) {
}
/*should choose the right decryption onion*/
static
std::shared_ptr<ReturnMeta> getReturnMeta(std::vector<FieldMeta*> fms,
std::vector<FieldMetaTrans> &tfds){
......@@ -96,6 +88,8 @@ std::shared_ptr<ReturnMeta> getReturnMeta(std::vector<FieldMeta*> fms,
}
return myReturnMeta;
}
/*init global full backup. */
static
void initGfb(std::vector<FieldMetaTrans> &res,std::string db,std::string table){
......@@ -228,7 +222,7 @@ static ResType load_files(std::string db, std::string table){
return finalresults;
}
std::map<onion,unsigned long> gcountMap;
static
void local_wrapper(const Item &i, const FieldMeta &fm, Analysis &a,
......@@ -374,8 +368,8 @@ main(int argc, char* argv[]){
if(localCount==constGlobalConstants.pipelineCount){
std::ostringstream o;
insertManyValues(o,newList);
globalConn->execute(head+o.str());
// std::cout<<(head+o.str())<<std::endl;
// globalConn->execute(head+o.str());
std::cout<<(head+o.str())<<std::endl;
i++;
break;
}
......@@ -384,8 +378,8 @@ main(int argc, char* argv[]){
if(localCount!=constGlobalConstants.pipelineCount) {
std::ostringstream o;
insertManyValues(o,newList);
globalConn->execute(head+o.str());
// std::cout<<(head+o.str())<<std::endl;
// globalConn->execute(head+o.str());
std::cout<<(head+o.str())<<std::endl;
}
break;
}
......
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