Lines Matching defs:hashp

78 	((u_int16_t *)(P))[1] = hashp->BSIZE - 3 * sizeof(u_int16_t); \
79 ((u_int16_t *)(P))[2] = hashp->BSIZE; \
118 __delpair(HTAB *hashp, BUFHEAD *bufp, int ndx)
127 return (__big_delete(hashp, bufp));
131 newoff = hashp->BSIZE;
151 if (ndx == hashp->cndx) {
157 hashp->cndx -= 2;
164 hashp->NKEYS--;
175 __split_page(HTAB *hashp, u_int32_t obucket, u_int32_t nbucket)
185 copyto = (u_int16_t)hashp->BSIZE;
186 off = (u_int16_t)hashp->BSIZE;
187 old_bufp = __get_buf(hashp, obucket, NULL, 0);
190 new_bufp = __get_buf(hashp, nbucket, NULL, 0);
204 retval = ugly_split(hashp, obucket, old_bufp, new_bufp,
214 if (__call_hash(hashp, key.data, key.size) == obucket) {
269 ugly_split(HTAB *hashp,
297 if (__big_split(hashp, old_bufp,
325 bufp = __get_buf(hashp, ov_addr, bufp, 0);
331 scopyto = hashp->BSIZE;
335 __free_ovflpage(hashp, last_bfp);
339 off = hashp->BSIZE;
348 if (__call_hash(hashp, key.data, key.size) == obucket) {
354 __add_ovflpage(hashp, old_bufp);
367 __add_ovflpage(hashp, new_bufp);
378 __free_ovflpage(hashp, last_bfp);
390 __addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
404 bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
418 bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
429 bufp = __add_ovflpage(hashp, bufp);
437 if (__big_insert(hashp, bufp, key, val))
446 hashp->NKEYS++;
448 (hashp->NKEYS / (hashp->MAX_BUCKET + 1) > hashp->FFACTOR))
449 return (__expand_table(hashp));
460 __add_ovflpage(HTAB *hashp, BUFHEAD *bufp)
469 if (hashp->FFACTOR == DEF_FFACTOR) {
470 hashp->FFACTOR = sp[0] >> 1;
471 if (hashp->FFACTOR < MIN_FFACTOR)
472 hashp->FFACTOR = MIN_FFACTOR;
475 ovfl_num = overflow_page(hashp);
480 if (!ovfl_num || !(bufp->ovfl = __get_buf(hashp, ovfl_num, bufp, 1)))
510 __get_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_disk,
516 fd = hashp->fp;
517 size = hashp->BSIZE;
527 if ((rsize = pread(fd, p, size, (off_t)page << hashp->BSHIFT)) == -1)
540 if (hashp->LORDER != BYTE_ORDER) {
544 max = hashp->BSIZE >> 2; /* divide by 4 */
565 __put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap)
569 size = hashp->BSIZE;
570 if ((hashp->fp == -1) && open_temp(hashp))
572 fd = hashp->fp;
574 if (hashp->LORDER != BYTE_ORDER) {
578 max = hashp->BSIZE >> 2; /* divide by 4 */
591 if ((wsize = pwrite(fd, p, size, (off_t)page << hashp->BSHIFT)) == -1)
607 __ibitmap(HTAB *hashp, int pnum, int nbits, int ndx)
612 if ((ip = (u_int32_t *)malloc(hashp->BSIZE)) == NULL)
614 hashp->nmaps++;
619 hashp->BSIZE - clearbytes);
622 hashp->BITMAPS[ndx] = (u_int16_t)pnum;
623 hashp->mapp[ndx] = ip;
642 overflow_page(HTAB *hashp)
651 splitnum = hashp->OVFL_POINT;
652 max_free = hashp->SPARES[splitnum];
654 free_page = (max_free - 1) >> (hashp->BSHIFT + BYTE_SHIFT);
655 free_bit = (max_free - 1) & ((hashp->BSIZE << BYTE_SHIFT) - 1);
658 first_page = hashp->LAST_FREED >>(hashp->BSHIFT + BYTE_SHIFT);
660 if (!(freep = (u_int32_t *)hashp->mapp[i]) &&
661 !(freep = fetch_bitmap(hashp, i)))
666 in_use_bits = (hashp->BSIZE << BYTE_SHIFT) - 1;
669 bit = hashp->LAST_FREED &
670 ((hashp->BSIZE << BYTE_SHIFT) - 1);
683 hashp->LAST_FREED = hashp->SPARES[splitnum];
684 hashp->SPARES[splitnum]++;
685 offset = hashp->SPARES[splitnum] -
686 (splitnum ? hashp->SPARES[splitnum - 1] : 0);
695 hashp->OVFL_POINT = splitnum;
696 hashp->SPARES[splitnum] = hashp->SPARES[splitnum-1];
697 hashp->SPARES[splitnum-1]--;
702 if (free_bit == (hashp->BSIZE << BYTE_SHIFT) - 1) {
720 if (__ibitmap(hashp,
723 hashp->SPARES[splitnum]++;
735 hashp->OVFL_POINT = splitnum;
736 hashp->SPARES[splitnum] = hashp->SPARES[splitnum-1];
737 hashp->SPARES[splitnum-1]--;
769 bit = 1 + bit + (i * (hashp->BSIZE << BYTE_SHIFT));
770 if (bit >= hashp->LAST_FREED)
771 hashp->LAST_FREED = bit - 1;
774 for (i = 0; (i < splitnum) && (bit > hashp->SPARES[i]); i++);
775 offset = (i ? bit - hashp->SPARES[i - 1] : bit);
795 __free_ovflpage(HTAB *hashp, BUFHEAD *obufp)
808 (ndx ? hashp->SPARES[ndx - 1] : 0) + (addr & SPLITMASK) - 1;
809 if (bit_address < hashp->LAST_FREED)
810 hashp->LAST_FREED = bit_address;
811 free_page = (bit_address >> (hashp->BSHIFT + BYTE_SHIFT));
812 free_bit = bit_address & ((hashp->BSIZE << BYTE_SHIFT) - 1);
814 if (!(freep = hashp->mapp[free_page]))
815 freep = fetch_bitmap(hashp, free_page);
830 __reclaim_buf(hashp, obufp);
839 open_temp(HTAB *hashp)
858 if ((hashp->fp = mkostemp(path, O_CLOEXEC)) != -1) {
862 return (hashp->fp != -1 ? 0 : -1);
895 fetch_bitmap(HTAB *hashp, int ndx)
897 if (ndx >= hashp->nmaps)
899 if ((hashp->mapp[ndx] = (u_int32_t *)malloc(hashp->BSIZE)) == NULL)
901 if (__get_page(hashp,
902 (char *)hashp->mapp[ndx], hashp->BITMAPS[ndx], 0, 1, 1)) {
903 free(hashp->mapp[ndx]);
906 return (hashp->mapp[ndx]);
917 bufp = __get_buf(hashp, addr, NULL, 0);
923 bufp = __get_buf(hashp, (int)oaddr, bufp, 0);