Commit 046afba1 authored by yiwenshao's avatar yiwenshao

able to use custom data in insert

parent a5135821
...@@ -128,6 +128,11 @@ void initGfb(std::vector<FieldMetaTrans> &res,std::string db,std::string table){ ...@@ -128,6 +128,11 @@ void initGfb(std::vector<FieldMetaTrans> &res,std::string db,std::string table){
} }
gfb.annoOnionNameToFileVector[gfb.field_names[i]] = std::move(column); gfb.annoOnionNameToFileVector[gfb.field_names[i]] = std::move(column);
} }
//init another map
for(unsigned int i=0;i<gfb.field_names.size();i++){
gfb.annoOnionNameToType[gfb.field_names[i]] = gfb.field_types[i];
}
} }
...@@ -157,8 +162,8 @@ static ResType load_files(std::string db="tdb", std::string table="student"){ ...@@ -157,8 +162,8 @@ static ResType load_files(std::string db="tdb", std::string table="student"){
//load fields in the stored file //load fields in the stored file
//Fast version //Fast version
vector<vector<string>> resss_field = loadTableFieldsForDecryption(db,table,field_names, field_types, field_lengths); vector<vector<string>> resss_field = loadTableFieldsForDecryption(db,
table,field_names, field_types, field_lengths);
vector<vector<string>> res_field; vector<vector<string>> res_field;
for(auto item:field_names){ for(auto item:field_names){
res_field.push_back(gfb.annoOnionNameToFileVector[item]); res_field.push_back(gfb.annoOnionNameToFileVector[item]);
...@@ -188,8 +193,7 @@ static ResType load_files(std::string db="tdb", std::string table="student"){ ...@@ -188,8 +193,7 @@ static ResType load_files(std::string db="tdb", std::string table="student"){
static static
void local_wrapper(const Item &i, const FieldMeta &fm, Analysis &a, void local_wrapper(const Item &i, const FieldMeta &fm, Analysis &a,
List<Item> *const append_list){ List<Item> *const append_list){
//为什么这里不是push item?? //append_list->push_back(&(const_cast<Item&>(i)));
// append_list->push_back(&(const_cast<Item&>(i)));
//do not use the plain strategy //do not use the plain strategy
std::vector<Item *> l; std::vector<Item *> l;
const uint64_t salt = fm.getHasSalt() ? randomValue() : 0; const uint64_t salt = fm.getHasSalt() ? randomValue() : 0;
...@@ -197,8 +201,21 @@ void local_wrapper(const Item &i, const FieldMeta &fm, Analysis &a, ...@@ -197,8 +201,21 @@ void local_wrapper(const Item &i, const FieldMeta &fm, Analysis &a,
for (auto it : fm.orderedOnionMetas()) { for (auto it : fm.orderedOnionMetas()) {
const onion o = it.first->getValue(); const onion o = it.first->getValue();
OnionMeta * const om = it.second; OnionMeta * const om = it.second;
std::string annoOnionName = om->getAnonOnionName();
if(gfb.annoOnionNameToFileVector.find(annoOnionName)!=gfb.annoOnionNameToFileVector.end()){
enum_field_types type = static_cast<enum_field_types>(gfb.annoOnionNameToType[annoOnionName]);
if(IS_NUM(type)){
std::string in("11");
l.push_back(MySQLFieldTypeToItem(type,in));
}else{
std::string in("hehe");
l.push_back(MySQLFieldTypeToItem(type,in));
}
//l.push_back(&(const_cast<Item&>(i)));
}else{
l.push_back(my_encrypt_item_layers(i, o, *om, a, IV)); l.push_back(my_encrypt_item_layers(i, o, *om, a, IV));
} }
}
if (fm.getHasSalt()) { if (fm.getHasSalt()) {
l.push_back(new Item_int(static_cast<ulonglong>(salt))); l.push_back(new Item_int(static_cast<ulonglong>(salt)));
} }
......
...@@ -459,3 +459,22 @@ insertManyValues(std::ostream &out,List<List_item> &newList){ ...@@ -459,3 +459,22 @@ insertManyValues(std::ostream &out,List<List_item> &newList){
return out; return out;
} }
std::unique_ptr<Item>
getIntItem(int i){
Item * it = new Item_int(i);
return std::unique_ptr<Item>(it);
}
std::unique_ptr<Item>
getStringItem(std::string s){
Item * it = new Item_string(make_thd_string(s),s.length(),&my_charset_bin);
return std::unique_ptr<Item>(it);
}
...@@ -167,6 +167,7 @@ struct fullBackUp{ ...@@ -167,6 +167,7 @@ struct fullBackUp{
std::vector<int> field_types; std::vector<int> field_types;
std::vector<int> field_lengths; std::vector<int> field_lengths;
std::map<std::string,std::vector<std::string>> annoOnionNameToFileVector;//field name to vector of string std::map<std::string,std::vector<std::string>> annoOnionNameToFileVector;//field name to vector of string
std::map<std::string,int> annoOnionNameToType;
}; };
...@@ -177,3 +178,9 @@ std::ostream& ...@@ -177,3 +178,9 @@ std::ostream&
insertManyValues(std::ostream &out,List<List_item> &newList); insertManyValues(std::ostream &out,List<List_item> &newList);
std::unique_ptr<Item>
getIntItem(int i);
std::unique_ptr<Item>
getStringItem(std::string s);
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