Lines Matching refs:hcp
100 HASH_CURSOR *hcp; local
123 hcp = (HASH_CURSOR *)dbc->internal;
124 GET_META(dbp, hcp, ret);
133 if (hcp->hdr->magic == DB_HASHMAGIC) {
138 hcp->hdr->version < 5 ? __ham_func4 : __ham_func5;
140 hcp->hdr->h_charkey) {
145 if (F_ISSET(hcp->hdr, DB_HASH_DUP))
154 ((ret = lock_put(dbenv->lk_info, hcp->hlock)) != 0 ||
156 &dbc->lock_dbt, DB_LOCK_WRITE, &hcp->hlock)) != 0)) {
165 F_SET(hcp->hdr, DB_HASH_DUP);
166 if ((ret = __ham_dirty_page(dbp, (PAGE *)hcp->hdr)) != 0)
171 RELEASE_META(dbp, hcp);
205 HASH_CURSOR *hcp; local
208 hcp = (HASH_CURSOR *)dbc->internal;
210 memset(hcp->hdr, 0, sizeof(HASHHDR));
211 hcp->hdr->ffactor = ffactor;
212 hcp->hdr->pagesize = dbp->pgsize;
213 ZERO_LSN(hcp->hdr->lsn);
214 hcp->hdr->magic = DB_HASHMAGIC;
215 hcp->hdr->version = DB_HASHVERSION;
218 dbp->h_hash = hcp->hdr->version < 5 ? __ham_func4 : __ham_func5;
219 hcp->hdr->h_charkey = dbp->h_hash(CHARKEY, sizeof(CHARKEY));
220 if (nelem != 0 && hcp->hdr->ffactor != 0) {
221 nelem = (nelem - 1) / hcp->hdr->ffactor + 1;
228 hcp->hdr->ovfl_point = l2;
229 hcp->hdr->last_freed = PGNO_INVALID;
231 hcp->hdr->max_bucket = hcp->hdr->high_mask = nbuckets - 1;
232 hcp->hdr->low_mask = (nbuckets >> 1) - 1;
233 memcpy(hcp->hdr->uid, dbp->fileid, DB_FILE_ID_LEN);
244 HASH_CURSOR *hcp; local
258 hcp = (HASH_CURSOR *)dbc->internal;
259 GET_META(dbp, hcp, ret);
263 hcp->stats.hash_deleted++;
265 if (F_ISSET(hcp, H_OK))
270 RELEASE_META(dbp, hcp);
337 HASH_CURSOR *hcp; local
339 hcp = (HASH_CURSOR *)dbc->internal;
340 if (hcp->split_buf != NULL)
341 __os_free(hcp->split_buf, dbc->dbp->pgsize);
342 __os_free(hcp, sizeof(HASH_CURSOR));
354 HASH_CURSOR *hcp; local
362 hcp = (HASH_CURSOR *)dbc->internal;
365 F_ISSET(dbc->dbp, DB_AM_RDONLY), IS_VALID(hcp))) != 0)
368 if (F_ISSET(hcp, H_DELETED))
389 GET_META(dbp, hcp, ret);
393 SAVE_CURSOR(hcp, &save_curs);
394 hcp->stats.hash_deleted++;
398 if (F_ISSET(hcp, H_ISDUP) && hcp->dpgno != PGNO_INVALID) {
422 ppgno = PREV_PGNO(hcp->dpagep);
424 NEXT_PGNO(hcp->dpagep) == PGNO_INVALID &&
425 NUM_ENT(hcp->dpagep) == 1)
429 chg_pgno = hcp->dpgno;
431 &hcp->dpagep, hcp->dndx, __ham_del_page)) != 0)
434 if (hcp->dpagep == NULL) {
436 hcp->dpgno = ppgno;
440 hcp->dndx = NUM_ENT(hcp->dpagep);
441 F_SET(hcp, H_DELETED);
444 hcp->dpgno = PGNO_INVALID;
451 } else if (PGNO(hcp->dpagep) != hcp->dpgno) {
452 hcp->dndx = 0; /* Case 2 */
453 hcp->dpgno = PGNO(hcp->dpagep);
455 memcpy(HOFFDUP_PGNO(P_ENTRY(hcp->pagep,
456 H_DATAINDEX(hcp->bndx))),
457 &hcp->dpgno, sizeof(db_pgno_t));
465 ret = __ham_put_page(dbp, hcp->pagep, 1);
466 hcp->pagep = NULL;
467 F_SET(hcp, H_DELETED);
469 F_SET(hcp, H_DELETED);
471 __ham_c_update(hcp, chg_pgno, 0, 0, 1);
472 } else if (F_ISSET(hcp, H_ISDUP)) { /* on page */
473 if (hcp->dup_off == 0 && DUP_SIZE(hcp->dup_len) ==
474 LEN_HDATA(hcp->pagep, hcp->hdr->pagesize, hcp->bndx))
479 repldbt.doff = hcp->dup_off;
480 repldbt.dlen = DUP_SIZE(hcp->dup_len);
483 HKEYDATA_DATA(H_PAIRDATA(hcp->pagep, hcp->bndx));
485 hcp->dup_tlen -= DUP_SIZE(hcp->dup_len);
486 F_SET(hcp, H_DELETED);
487 __ham_c_update(hcp, hcp->pgno,
488 DUP_SIZE(hcp->dup_len), 0, 1);
497 RELEASE_META(dbp, hcp);
498 RESTORE_CURSOR(dbp, hcp, &save_curs, ret);
513 HASH_CURSOR *hcp, save_curs; local
521 hcp = (HASH_CURSOR *)dbc->internal;
524 SAVE_CURSOR(hcp, &save_curs);
526 __db_cgetchk(dbp, key, data, flags, IS_VALID(hcp))) != 0)
536 GET_META(dbp, hcp, ret);
539 hcp->stats.hash_get++;
540 hcp->seek_size = 0;
546 if (hcp->bucket != BUCKET_INVALID) {
558 if (hcp->bucket == BUCKET_INVALID)
561 F_SET(hcp, H_DUPONLY);
566 if (hcp->bucket == BUCKET_INVALID)
567 hcp->bucket = 0;
574 F_SET(hcp, H_DUPONLY);
583 if (F_ISSET(hcp, H_DELETED)) {
599 else if (F_ISSET(hcp, H_OK)) {
601 if (get_key && (ret = __db_ret(dbp, hcp->pagep,
602 H_KEYINDEX(hcp->bndx), key, &dbc->rkey.data,
608 } else if (!F_ISSET(hcp, H_NOMORE)) {
620 if (hcp->bucket == 0) {
624 hcp->bucket--;
625 hcp->bndx = NDX_INVALID;
632 hcp->bndx = NDX_INVALID;
633 hcp->bucket++;
634 hcp->pgno = PGNO_INVALID;
635 hcp->pagep = NULL;
636 if (hcp->bucket > hcp->hdr->max_bucket) {
654 out: RELEASE_META(dbp, hcp);
655 RESTORE_CURSOR(dbp, hcp, &save_curs, ret);
668 HASH_CURSOR *hcp, save_curs; local
677 hcp = (HASH_CURSOR *)dbc->internal;
680 F_ISSET(dbp, DB_AM_RDONLY), IS_VALID(hcp))) != 0)
683 if (F_ISSET(hcp, H_DELETED) &&
705 GET_META(dbp, hcp, ret);
709 SAVE_CURSOR(hcp, &save_curs);
710 hcp->stats.hash_put++;
715 nbytes = (ISBIG(hcp, key->size) ? HOFFPAGE_PSIZE :
717 (ISBIG(hcp, data->size) ? HOFFPAGE_PSIZE :
722 if (hcp->seek_found_page != PGNO_INVALID &&
723 hcp->seek_found_page != hcp->pgno) {
726 hcp->pgno = hcp->seek_found_page;
727 hcp->bndx = NDX_INVALID;
762 if ((flags == DB_CURRENT && !F_ISSET(hcp, H_ISDUP)) ||
770 done: if (ret == 0 && F_ISSET(hcp, H_EXPAND)) {
772 F_CLR(hcp, H_EXPAND);
778 out: RELEASE_META(dbp, hcp);
779 RESTORE_CURSOR(dbp, hcp, &save_curs, ret);
796 HASH_CURSOR *hcp; local
802 hcp = (HASH_CURSOR *)dbc->internal;
804 DIRTY_META(dbp, hcp, ret);
817 if (__db_log2(hcp->hdr->max_bucket + 2) > hcp->hdr->ovfl_point) {
823 if (hcp->hdr->max_bucket + 1 >= 8 &&
824 hcp->hdr->spares[hcp->hdr->ovfl_point] <
825 hcp->hdr->spares[hcp->hdr->ovfl_point - 1] +
826 hcp->hdr->ovfl_point + 1)
834 hcp->hdr->max_bucket, hcp->hdr->ovfl_point,
835 hcp->hdr->spares[hcp->hdr->ovfl_point],
836 &hcp->hdr->lsn)) != 0)
839 hcp->hdr->lsn = new_lsn;
842 hcp->stats.hash_expansions++;
843 new_bucket = ++hcp->hdr->max_bucket;
844 old_bucket = (hcp->hdr->max_bucket & hcp->hdr->low_mask);
850 spare_ndx = __db_log2(hcp->hdr->max_bucket + 1);
851 if (spare_ndx > hcp->hdr->ovfl_point) {
852 hcp->hdr->spares[spare_ndx] =
853 hcp->hdr->spares[hcp->hdr->ovfl_point];
854 hcp->hdr->ovfl_point = spare_ndx;
857 if (new_bucket > hcp->hdr->high_mask) {
859 hcp->hdr->low_mask = hcp->hdr->high_mask;
860 hcp->hdr->high_mask = new_bucket | hcp->hdr->low_mask;
863 if (BUCKET_TO_PAGE(hcp, new_bucket) > MAX_PAGES(hcp)) {
877 __ham_call_hash(hcp, k, len) in __ham_call_hash() argument
878 HASH_CURSOR *hcp; in __ham_call_hash()
884 n = (u_int32_t)(hcp->dbc->dbp->h_hash(k, len));
886 bucket = n & hcp->hdr->high_mask;
887 if (bucket > hcp->hdr->max_bucket)
888 bucket = bucket & hcp->hdr->low_mask;
903 HASH_CURSOR *hcp; local
915 hcp = (HASH_CURSOR *)dbc->internal;
916 ndx = H_DATAINDEX(hcp->bndx);
917 type = HPAGE_TYPE(hcp->pagep, ndx);
918 pp = hcp->pagep;
934 if (!F_ISSET(hcp, H_ISDUP))
936 F_SET(hcp, H_ISDUP);
937 hcp->dup_tlen = LEN_HDATA(hcp->pagep,
938 hcp->hdr->pagesize, hcp->bndx);
939 hk = H_PAIRDATA(hcp->pagep, hcp->bndx);
941 hcp->dndx = 0;
942 hcp->dup_off = 0;
945 HKEYDATA_DATA(hk) + hcp->dup_off,
947 hcp->dup_off += DUP_SIZE(len);
948 hcp->dndx++;
949 } while (hcp->dup_off < hcp->dup_tlen);
950 hcp->dup_off -= DUP_SIZE(len);
951 hcp->dndx--;
955 hcp->dup_off = 0;
956 hcp->dndx = 0;
958 hcp->dup_len = len;
960 F_SET(hcp, H_ISDUP);
961 memcpy(&pgno, HOFFDUP_PGNO(P_ENTRY(hcp->pagep, ndx)),
965 pgno, &hcp->dpagep)) != 0)
967 hcp->dpgno = PGNO(hcp->dpagep);
968 hcp->dndx = NUM_ENT(hcp->dpagep) - 1;
980 if (F_ISSET(hcp, H_ISDUP)) {
981 if (hcp->dpgno != PGNO_INVALID) {
983 hcp->dpgno, &hcp->dndx, &hcp->dpagep, &cmp))
987 hcp->dpgno = PGNO(hcp->dpagep);
990 hcp->dup_off = off;
993 hk = H_PAIRDATA(hcp->pagep, hcp->bndx);
1008 tmp_val.size = LEN_HDATA(hcp->pagep,
1009 dbp->pgsize, hcp->bndx);
1024 if (F_ISSET(hcp, H_ISDUP))
1025 if (hcp->dpgno != PGNO_INVALID) {
1026 pp = hcp->dpagep;
1027 ndx = hcp->dndx;
1042 if (tmp_val.doff + hcp->dup_off > hcp->dup_len)
1045 hcp->dup_len)
1047 hcp->dup_len - tmp_val.doff;
1052 tmp_val.doff += hcp->dup_off;
1055 tmp_val.dlen = hcp->dup_len;
1056 tmp_val.doff = hcp->dup_off + sizeof(db_indx_t);
1085 HASH_CURSOR *hcp; local
1089 hcp = (HASH_CURSOR *)dbc->internal;
1097 hk = H_PAIRDATA(hcp->pagep, hcp->bndx);
1102 tmp_val.dlen = LEN_HDATA(hcp->pagep,
1103 hcp->hdr->pagesize,hcp->bndx);
1128 HASH_CURSOR *hcp; local
1135 hcp = (HASH_CURSOR *)dbc->internal;
1142 hcp->seek_size = sought;
1144 hcp->bucket = __ham_call_hash(hcp, (u_int8_t *)key->data, key->size);
1149 if (F_ISSET(hcp, H_NOMORE))
1152 hk = H_PAIRKEY(hcp->pagep, hcp->bndx);
1163 F_SET(hcp, H_OK);
1169 if (key->size == LEN_HKEY(hcp->pagep,
1170 hcp->hdr->pagesize, hcp->bndx) &&
1173 F_SET(hcp, H_OK);
1183 return (__db_pgfmt(dbp, PGNO(hcp->pagep)));
1185 hcp->stats.hash_collisions++;
1241 __ham_c_update(hcp, chg_pgno, len, add, is_dup) in __ham_c_update() argument
1242 HASH_CURSOR *hcp; in __ham_c_update()
1267 if (!is_dup || hcp->dpgno == PGNO_INVALID)
1269 chg_pgno != PGNO_INVALID && chg_pgno != hcp->pgno;
1272 chg_pgno != PGNO_INVALID && chg_pgno != hcp->dpgno;
1274 dbp = hcp->dbc->dbp;
1279 if (cp->internal == hcp)
1288 if (F_ISSET(hcp, H_DELETED) && lcp->pgno != chg_pgno)
1290 if (!F_ISSET(hcp, H_DELETED) && lcp->dpgno != chg_pgno)
1296 lcp->dpgno = hcp->dpgno;
1297 lcp->dndx = hcp->dndx;
1299 lcp->pgno = hcp->pgno;
1300 lcp->bndx = hcp->bndx;
1301 lcp->bucket = hcp->bucket;
1307 if (!is_dup && lcp->bndx > hcp->bndx)
1309 else if (!is_dup && lcp->bndx == hcp->bndx)
1311 else if (is_dup && lcp->bndx == hcp->bndx) {
1313 lcp->dpgno = hcp->dpgno;
1314 if (add && lcp->dndx >= hcp->dndx )
1316 else if (!add && lcp->dndx > hcp->dndx)
1318 else if (!add && lcp->dndx == hcp->dndx)
1325 if (lcp->dndx > hcp->dndx)
1329 if (lcp->dndx > hcp->dndx)