Read the next tuple either from the current page if it has more tuples matching the predicate or from the next page by following the right sibling pointer. @return the next tuple matching the predicate, or null if none exists
()
| 1435 | * @return the next tuple matching the predicate, or null if none exists |
| 1436 | */ |
| 1437 | @Override |
| 1438 | protected Tuple readNext() throws TransactionAbortedException, DbException, |
| 1439 | NoSuchElementException { |
| 1440 | while (it != null) { |
| 1441 | |
| 1442 | while (it.hasNext()) { |
| 1443 | Tuple t = it.next(); |
| 1444 | if (t.getField(f.keyField()).compare(ipred.getOp(), ipred.getField())) { |
| 1445 | return t; |
| 1446 | } |
| 1447 | else if(ipred.getOp() == Op.LESS_THAN || ipred.getOp() == Op.LESS_THAN_OR_EQ) { |
| 1448 | // if the predicate was not satisfied and the operation is less than, we have |
| 1449 | // hit the end |
| 1450 | return null; |
| 1451 | } |
| 1452 | else if(ipred.getOp() == Op.EQUALS && |
| 1453 | t.getField(f.keyField()).compare(Op.GREATER_THAN, ipred.getField())) { |
| 1454 | // if the tuple is now greater than the field passed in and the operation |
| 1455 | // is equals, we have reached the end |
| 1456 | return null; |
| 1457 | } |
| 1458 | } |
| 1459 | |
| 1460 | BTreePageId nextp = curp.getRightSiblingId(); |
| 1461 | // if there are no more pages to the right, end the iteration |
| 1462 | if(nextp == null) { |
| 1463 | return null; |
| 1464 | } |
| 1465 | else { |
| 1466 | curp = (BTreeLeafPage) Database.getBufferPool().getPage(tid, |
| 1467 | nextp, Permissions.READ_ONLY); |
| 1468 | it = curp.iterator(); |
| 1469 | } |
| 1470 | } |
| 1471 | |
| 1472 | return null; |
| 1473 | } |
| 1474 | |
| 1475 | /** |
| 1476 | * rewind this iterator back to the beginning of the tuples |
nothing calls this directly
no test coverage detected