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