[Xapian-discuss] Weird problem on PositionIterator
zhiguo li
zhiguo.li at gmail.com
Thu Nov 13 11:55:45 GMT 2008
Hi, all,
I just found a weird problem about PositionIterator, and I really hope
somebody could help me out.
My example code looks like the following:
Xapian::MSetIterator im;
Xapian::TermIterator it1, it2;
Xapian::PositionIterator ip1_begin, ip1_end, ip2_begin, ip2_end;
ip1_begin = db.positionlist_begin(*im, *it1);
ip1_end = db.positionlist_end(*im, *it1);
ip2_begin = db.positionlist_begin(*im, *it2);
ip2_end = db.positionlist_end(*im, *it2);
for (Xapian::PositionIterator ip1 = ip1_begin; ip1 != ip1_end; ip1++)
{
cout << *ip1 << endl;
for (Xapian::PositionIterator ip2 = ip2_begin; ip2 != ip2_end;
ip2++)
{
cout << *ip2 << endl;
}
}
Suppose PositionIterator ip1 points to [1 3], andPositionIterator ip2 points
to [2 4], then with the above code it will output:
1
2
4
3
random number
random number
random number
random number
...
and finally end up with a segmentation fault. If I remove one layer of the
loop (either remove layer ip1 or ip2), the program always execture
correctly. I wonder what I did wrong?
Thanks.
Kevin
More information about the Xapian-discuss
mailing list