Lines Matching +full:ep +full:- +full:side
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
58 * __bt_seq --
77 t = dbp->internal;
80 if (t->bt_pinned != NULL) {
81 mpool_put(t->bt_mp, t->bt_pinned, 0);
82 t->bt_pinned = NULL;
93 if (F_ISSET(&t->bt_cursor, CURS_INIT)) {
109 __bt_setcur(t, e.page->pgno, e.index);
112 __bt_ret(t, &e, key, &t->bt_rkey, data, &t->bt_rdata, 0);
119 mpool_put(t->bt_mp, e.page, 0);
121 t->bt_pinned = e.page;
127 * __bt_seqset --
132 * ep: storage for returned key
136 * Side effects:
143 __bt_seqset(BTREE *t, EPG *ep, DBT *key, int flags)
160 if (key->data == NULL || key->size == 0) {
164 return (__bt_first(t, key, ep, &exact));
167 /* Walk down the left-hand side of the tree. */
169 if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
174 mpool_put(t->bt_mp, h, 0);
178 if (h->flags & (P_BLEAF | P_RLEAF))
180 pg = GETBINTERNAL(h, 0)->pgno;
181 mpool_put(t->bt_mp, h, 0);
183 ep->page = h;
184 ep->index = 0;
188 /* Walk down the right-hand side of the tree. */
190 if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
195 mpool_put(t->bt_mp, h, 0);
199 if (h->flags & (P_BLEAF | P_RLEAF))
201 pg = GETBINTERNAL(h, NEXTINDEX(h) - 1)->pgno;
202 mpool_put(t->bt_mp, h, 0);
205 ep->page = h;
206 ep->index = NEXTINDEX(h) - 1;
213 * __bt_seqadvance --
220 * Side effects:
227 __bt_seqadv(BTREE *t, EPG *ep, int flags)
239 c = &t->bt_cursor;
245 * match or not -- if it's an exact match, the record was added after
250 return (__bt_first(t, &c->key, ep, &exact));
253 if ((h = mpool_get(t->bt_mp, c->pg.pgno, 0)) == NULL)
269 idx = c->pg.index;
271 pg = h->nextpg;
272 mpool_put(t->bt_mp, h, 0);
275 if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
288 ep->page = h;
289 ep->index = c->pg.index;
292 idx = c->pg.index;
294 pg = h->prevpg;
295 mpool_put(t->bt_mp, h, 0);
298 if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
300 idx = NEXTINDEX(h) - 1;
302 --idx;
306 ep->page = h;
307 ep->index = idx;
312 * __bt_first --
329 EPG *ep, save;
340 if ((ep = __bt_search(t, key, exactp)) == NULL)
344 *erval = *ep;
353 save = *ep;
354 h = ep->page;
356 if (save.page->pgno != ep->page->pgno) {
357 mpool_put(t->bt_mp, save.page, 0);
358 save = *ep;
360 save.index = ep->index;
367 if (ep->index == 0) {
368 if (h->prevpg == P_INVALID)
370 if (h->pgno != save.page->pgno)
371 mpool_put(t->bt_mp, h, 0);
372 if ((h = mpool_get(t->bt_mp,
373 h->prevpg, 0)) == NULL) {
374 if (h->pgno == save.page->pgno)
375 mpool_put(t->bt_mp,
379 ep->page = h;
380 ep->index = NEXTINDEX(h);
382 --ep->index;
383 } while (__bt_cmp(t, key, ep) == 0);
390 if (h->pgno != save.page->pgno)
391 mpool_put(t->bt_mp, h, 0);
398 if (ep->index == NEXTINDEX(ep->page)) {
399 h = ep->page;
400 pg = h->nextpg;
401 mpool_put(t->bt_mp, h, 0);
404 if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
406 ep->index = 0;
407 ep->page = h;
409 *erval = *ep;
414 * __bt_setcur --
426 if (t->bt_cursor.key.data != NULL) {
427 free(t->bt_cursor.key.data);
428 t->bt_cursor.key.size = 0;
429 t->bt_cursor.key.data = NULL;
431 F_CLR(&t->bt_cursor, CURS_ACQUIRE | CURS_AFTER | CURS_BEFORE);
434 t->bt_cursor.pg.pgno = pgno;
435 t->bt_cursor.pg.index = idx;
436 F_SET(&t->bt_cursor, CURS_INIT);