Skip to content

Commit 2c90ed0

Browse files
committed
Fix MiddleWaveletIterator skip method
1 parent a9d68db commit 2c90ed0

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

libhdt/src/triples/BitmapTriplesIterators.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,18 +455,23 @@ void MiddleWaveletIterator::skip(unsigned int pos) {
455455
//goTo(predicateOcurrence+pos);
456456

457457
int numJumps = 0;
458+
unsigned int posLeft = pos;
458459
while ((numJumps<pos)&&(posZ<maxZ)){
459-
if((posZ+pos)>nextZ) {
460+
if((posZ+posLeft)>nextZ) {
460461
numJumps += (nextZ-posZ)+1; // count current jump
461462
predicateOcurrence++; // jump to the next occurrence
463+
posLeft = pos-numJumps; // set remaining offset
462464
if (predicateOcurrence<=numOcurrences){
463465
posY = predicateIndex->getAppearance(patY, predicateOcurrence);
464466
posZ = prevZ = adjZ.find(posY);
465467
nextZ = adjZ.last(posY);
466468
}
469+
else {
470+
throw std::runtime_error("Cannot goTo on this pattern.");
471+
}
467472

468473
} else {
469-
posZ=(posZ+pos);
474+
posZ=(posZ+posLeft);
470475
numJumps=pos;
471476
}
472477
}

0 commit comments

Comments
 (0)