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;
vector<int> valid_idlist;
for(int i = 0; i < size; ++i)
{
int ele = cans[i];
int* list = NULL; int* list = NULL;
int len = 0; int list_len = 0;
bool exist_preid = true;
//TODO+BETTER:o2p and s2p may duplicate many times if(exist_preid && !in_edge_pre_id.empty())
{
//(this->kvstore)->getpreIDsubIDlistByobjID(entity_id, pair_list, pair_len);
(this->kvstore)->getpreIDlistByobjID(ele, list, list_len);
if (!in_edge_pre_id.empty()) for(vector<int>::iterator itr_pre = in_edge_pre_id.begin(); itr_pre != in_edge_pre_id.end(); itr_pre++)
{ {
int size2 = in_edge_pre_id.size(); int pre_id = (*itr_pre);
for (int i = 0; i < size2; ++i) //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)
{ {
int preid = in_edge_pre_id[i]; break;
this->kvstore->getobjIDlistBypreID(preid, list, len);
if (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->getpreIDlistByobjID(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->getpreIDlistByobjID(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; delete[] list;
} }
}
if (!is_literal_var(_var) && valid_list != NULL && valid_list->empty()) //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
//cerr << "quit when empty in edge"<<endl; //second once a pre in query is not found, break directly
return false;
}
if (!out_edge_pre_id.empty()) if(exist_preid && !out_edge_pre_id.empty())
{ {
int size2 = out_edge_pre_id.size(); //(this->kvstore)->getpreIDobjIDlistBysubID(entity_id, pair_list, pair_len);
for (int i = 0; i < size2; ++i) (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 preid = out_edge_pre_id[i]; int pre_id = (*itr_pre);
this->kvstore->getsubIDlistBypreID(preid, list, len); if(Util::bsearch_int_uporder(pre_id, list, list_len) == -1)
//cerr<<"p2s len "<<len<<endl; exist_preid = false;
if (valid_list == NULL && i == 0) if(!exist_preid)
{ {
if (size > len) break;
{
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; delete[] list;
} }
//result sequence is illegal when there exists any missing filter predicate id.
if(exist_preid)
{
valid_idlist.push_back(ele);
}
} }
if (!is_literal_var(_var) && 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 out edge"<<endl;
return false; return false;
} }
cans.copy(valid_list); cans.copy(valid_idlist);
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;