fix bug in distributed gstore, Join::preFilter

This commit is contained in:
bookug 2016-09-18 20:22:45 +08:00
parent 52b600d44c
commit fbd8213a6c
1 changed files with 58 additions and 194 deletions

View File

@ -2421,205 +2421,69 @@ Join::filterBySatellites(int _var)
// //
//we build a new idlist with all valid ones, and update to the original idlist //we build a new idlist with all valid ones, and update to the original idlist
//(consider in current_table is not good, too many duplicates) //(consider in current_table is not good, too many duplicates)
IDList* valid_list = NULL;
int *list = NULL;
int len = 0;
//TODO+BETTER:o2p and s2p may duplicate many times vector<int> valid_idlist;
for(int i = 0; i < size; ++i)
if (!in_edge_pre_id.empty())
{ {
int size2 = in_edge_pre_id.size(); int ele = cans[i];
for (int i = 0; i < size2; ++i) int* list = NULL;
{ int list_len = 0;
int preid = in_edge_pre_id[i]; bool exist_preid = true;
this->kvstore->getobjIDlistBypreID(preid, list, len);
if (i == 0) if(exist_preid && !in_edge_pre_id.empty())
{ {
if (size > len) //(this->kvstore)->getpreIDsubIDlistByobjID(entity_id, pair_list, pair_len);
{ (this->kvstore)->getpreIDlistByobjID(ele, list, list_len);
valid_list = IDList::intersect(cans, list, len);
} for(vector<int>::iterator itr_pre = in_edge_pre_id.begin(); itr_pre != in_edge_pre_id.end(); itr_pre++)
else {
{ int pre_id = (*itr_pre);
valid_list = new IDList; //the return value is pos, -1 if not found
int* list2 = NULL; if(Util::bsearch_int_uporder(pre_id, list, list_len) == -1)
int len2 = 0; exist_preid = false;
for (int j = 0; j < size; ++j) if(!exist_preid)
{ {
this->kvstore->getpreIDlistByobjID(cans[j], list2, len2); break;
if (Util::bsearch_int_uporder(preid, list2, len2) != -1) }
{ }
valid_list->addID(cans[j]); delete[] list;
} }
delete[] list2;
} //NOTICE:we do not use intersect here because the case is a little different
} //first the pre num is not so much in a query
} //second once a pre in query is not found, break directly
else
{ if(exist_preid && !out_edge_pre_id.empty())
if (valid_list->size() > len) {
{ //(this->kvstore)->getpreIDobjIDlistBysubID(entity_id, pair_list, pair_len);
valid_list->intersectList(list, len); (this->kvstore)->getpreIDlistBysubID(ele, list, list_len);
}
else for(vector<int>::iterator itr_pre = out_edge_pre_id.begin(); itr_pre != out_edge_pre_id.end(); itr_pre++)
{ {
int* list2 = NULL; int pre_id = (*itr_pre);
int len2 = 0; if(Util::bsearch_int_uporder(pre_id, list, list_len) == -1)
IDList* new_list = new IDList; exist_preid = false;
int size3 = valid_list->size(); if(!exist_preid)
for (int j = 0; j < size3; ++j) {
{ break;
this->kvstore->getpreIDlistByobjID(valid_list->getID(j), list2, len2); }
if (Util::bsearch_int_uporder(preid, list2, len2) != -1) }
{ delete[] list;
new_list->addID(valid_list->getID(j)); }
}
delete[] list2; //result sequence is illegal when there exists any missing filter predicate id.
} if(exist_preid)
delete valid_list; {
valid_list = new_list; valid_idlist.push_back(ele);
} }
}
delete[] list;
}
} }
if (!is_literal_var(_var) && valid_list != NULL && valid_list->empty()) //this is a core vertex, so if not literal var, exit when empty
if(!is_literal_var(_var) && valid_idlist.empty())
{ {
//cerr << "quit when empty in edge"<<endl; return false;
return false;
} }
cans.copy(valid_idlist);
if (!out_edge_pre_id.empty())
{
int size2 = out_edge_pre_id.size();
for (int i = 0; i < size2; ++i)
{
int preid = out_edge_pre_id[i];
this->kvstore->getsubIDlistBypreID(preid, list, len);
//cerr<<"p2s len "<<len<<endl;
if (valid_list == NULL && i == 0)
{
if (size > len)
{
valid_list = IDList::intersect(cans, list, len);
}
else
{
valid_list = new IDList;
int* list2 = NULL;
int len2 = 0;
for (int j = 0; j < size; ++j)
{
this->kvstore->getpreIDlistBysubID(cans[j], list2, len2);
if (Util::bsearch_int_uporder(preid, list2, len2) != -1)
{
valid_list->addID(cans[j]);
}
delete[] list2;
}
}
}
else
{
if (valid_list->size() > len)
{
valid_list->intersectList(list, len);
}
else
{
int* list2 = NULL;
int len2 = 0;
IDList* new_list = new IDList;
int size3 = valid_list->size();
for (int j = 0; j < size3; ++j)
{
this->kvstore->getpreIDlistBysubID(valid_list->getID(j), list2, len2);
if (Util::bsearch_int_uporder(preid, list2, len2) != -1)
{
new_list->addID(valid_list->getID(j));
}
delete[] list2;
}
delete valid_list;
valid_list = new_list;
}
}
delete[] list;
}
}
if (!is_literal_var(_var) && valid_list->empty())
{
//cerr << "quit when empty out edge"<<endl;
return false;
}
cans.copy(valid_list);
delete valid_list;
//vector<int> valid_idlist;
//for(int i = 0; i < size; ++i)
//{
// int ele = cans[i];
// int* list = NULL;
// int list_len = 0;
// bool exist_preid = true;
// if(exist_preid && !in_edge_pre_id.empty())
// {
// //(this->kvstore)->getpreIDsubIDlistByobjID(entity_id, pair_list, pair_len);
// (this->kvstore)->getpreIDlistByobjID(ele, list, list_len);
// for(vector<int>::iterator itr_pre = in_edge_pre_id.begin(); itr_pre != in_edge_pre_id.end(); itr_pre++)
// {
// int pre_id = (*itr_pre);
// //the return value is pos, -1 if not found
// if(Util::bsearch_int_uporder(pre_id, list, list_len) == -1)
// exist_preid = false;
// if(!exist_preid)
// {
// break;
// }
// }
// delete[] list;
// }
// //NOTICE:we do not use intersect here because the case is a little different
// //first the pre num is not so much in a query
// //second once a pre in query is not found, break directly
// if(exist_preid && !out_edge_pre_id.empty())
// {
// //(this->kvstore)->getpreIDobjIDlistBysubID(entity_id, pair_list, pair_len);
// (this->kvstore)->getpreIDlistBysubID(ele, list, list_len);
// for(vector<int>::iterator itr_pre = out_edge_pre_id.begin(); itr_pre != out_edge_pre_id.end(); itr_pre++)
// {
// int pre_id = (*itr_pre);
// if(Util::bsearch_int_uporder(pre_id, list, list_len) == -1)
// exist_preid = false;
// if(!exist_preid)
// {
// break;
// }
// }
// delete[] list;
// }
// //result sequence is illegal when there exists any missing filter predicate id.
// if(exist_preid)
// {
// valid_idlist.push_back(ele);
// }
//}
////this is a core vertex, so if not literal var, exit when empty
//if(!is_literal_var(_var) && valid_idlist.empty())
//{
// return false;
//}
//cans.copy(valid_idlist);
cerr << "var " << _var << "size after pre_filter " << cans.size() << endl; cerr << "var " << _var << "size after pre_filter " << cans.size() << endl;
return true; return true;
@ -3170,4 +3034,4 @@ Join::join(string &internal_tag_str)
} }
return ret; return ret;
} }