Lines Matching defs:hashp

85 	((u_int16_t *)(P))[1] = hashp->BSIZE - 3 * sizeof(u_int16_t); \
86 ((u_int16_t *)(P))[2] = hashp->BSIZE; \
125 __delpair(HTAB *hashp, BUFHEAD *bufp, int ndx)
134 return (__big_delete(hashp, bufp));
138 newoff = hashp->BSIZE;
158 if (ndx == hashp->cndx) {
164 hashp->cndx -= 2;
171 hashp->NKEYS--;
182 __split_page(HTAB *hashp, u_int32_t obucket, u_int32_t nbucket)
192 copyto = (u_int16_t)hashp->BSIZE;
193 off = (u_int16_t)hashp->BSIZE;
194 old_bufp = __get_buf(hashp, obucket, NULL, 0);
197 new_bufp = __get_buf(hashp, nbucket, NULL, 0);
211 retval = ugly_split(hashp, obucket, old_bufp, new_bufp,
221 if (__call_hash(hashp, key.data, key.size) == obucket) {
276 ugly_split(HTAB *hashp,
304 if (__big_split(hashp, old_bufp,
332 bufp = __get_buf(hashp, ov_addr, bufp, 0);
338 scopyto = hashp->BSIZE;
342 __free_ovflpage(hashp, last_bfp);
346 off = hashp->BSIZE;
355 if (__call_hash(hashp, key.data, key.size) == obucket) {
361 __add_ovflpage(hashp, old_bufp);
374 __add_ovflpage(hashp, new_bufp);
385 __free_ovflpage(hashp, last_bfp);
397 __addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
411 bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
425 bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
436 bufp = __add_ovflpage(hashp, bufp);
444 if (__big_insert(hashp, bufp, key, val))
453 hashp->NKEYS++;
455 (hashp->NKEYS / (hashp->MAX_BUCKET + 1) > hashp->FFACTOR))
456 return (__expand_table(hashp));
467 __add_ovflpage(HTAB *hashp, BUFHEAD *bufp)
476 if (hashp->FFACTOR == DEF_FFACTOR) {
477 hashp->FFACTOR = sp[0] >> 1;
478 if (hashp->FFACTOR < MIN_FFACTOR)
479 hashp->FFACTOR = MIN_FFACTOR;
482 ovfl_num = overflow_page(hashp);
487 if (!ovfl_num || !(bufp->ovfl = __get_buf(hashp, ovfl_num, bufp, 1)))
517 __get_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_disk,
523 fd = hashp->fp;
524 size = hashp->BSIZE;
534 if ((rsize = pread(fd, p, size, (off_t)page << hashp->BSHIFT)) == -1)
547 if (hashp->LORDER != BYTE_ORDER) {
551 max = hashp->BSIZE >> 2; /* divide by 4 */
572 __put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap)
576 size = hashp->BSIZE;
577 if ((hashp->fp == -1) && open_temp(hashp))
579 fd = hashp->fp;
581 if (hashp->LORDER != BYTE_ORDER) {
585 max = hashp->BSIZE >> 2; /* divide by 4 */
598 if ((wsize = pwrite(fd, p, size, (off_t)page << hashp->BSHIFT)) == -1)
614 __ibitmap(HTAB *hashp, int pnum, int nbits, int ndx)
619 if ((ip = (u_int32_t *)malloc(hashp->BSIZE)) == NULL)
621 hashp->nmaps++;
626 hashp->BSIZE - clearbytes);
629 hashp->BITMAPS[ndx] = (u_int16_t)pnum;
630 hashp->mapp[ndx] = ip;
649 overflow_page(HTAB *hashp)
658 splitnum = hashp->OVFL_POINT;
659 max_free = hashp->SPARES[splitnum];
661 free_page = (max_free - 1) >> (hashp->BSHIFT + BYTE_SHIFT);
662 free_bit = (max_free - 1) & ((hashp->BSIZE << BYTE_SHIFT) - 1);
665 first_page = hashp->LAST_FREED >>(hashp->BSHIFT + BYTE_SHIFT);
667 if (!(freep = (u_int32_t *)hashp->mapp[i]) &&
668 !(freep = fetch_bitmap(hashp, i)))
673 in_use_bits = (hashp->BSIZE << BYTE_SHIFT) - 1;
676 bit = hashp->LAST_FREED &
677 ((hashp->BSIZE << BYTE_SHIFT) - 1);
690 hashp->LAST_FREED = hashp->SPARES[splitnum];
691 hashp->SPARES[splitnum]++;
692 offset = hashp->SPARES[splitnum] -
693 (splitnum ? hashp->SPARES[splitnum - 1] : 0);
702 hashp->OVFL_POINT = splitnum;
703 hashp->SPARES[splitnum] = hashp->SPARES[splitnum-1];
704 hashp->SPARES[splitnum-1]--;
709 if (free_bit == (hashp->BSIZE << BYTE_SHIFT) - 1) {
727 if (__ibitmap(hashp,
730 hashp->SPARES[splitnum]++;
742 hashp->OVFL_POINT = splitnum;
743 hashp->SPARES[splitnum] = hashp->SPARES[splitnum-1];
744 hashp->SPARES[splitnum-1]--;
776 bit = 1 + bit + (i * (hashp->BSIZE << BYTE_SHIFT));
777 if (bit >= hashp->LAST_FREED)
778 hashp->LAST_FREED = bit - 1;
781 for (i = 0; (i < splitnum) && (bit > hashp->SPARES[i]); i++);
782 offset = (i ? bit - hashp->SPARES[i - 1] : bit);
802 __free_ovflpage(HTAB *hashp, BUFHEAD *obufp)
815 (ndx ? hashp->SPARES[ndx - 1] : 0) + (addr & SPLITMASK) - 1;
816 if (bit_address < hashp->LAST_FREED)
817 hashp->LAST_FREED = bit_address;
818 free_page = (bit_address >> (hashp->BSHIFT + BYTE_SHIFT));
819 free_bit = bit_address & ((hashp->BSIZE << BYTE_SHIFT) - 1);
821 if (!(freep = hashp->mapp[free_page]))
822 freep = fetch_bitmap(hashp, free_page);
837 __reclaim_buf(hashp, obufp);
846 open_temp(HTAB *hashp)
865 if ((hashp->fp = mkostemp(path, O_CLOEXEC)) != -1)
868 return (hashp->fp != -1 ? 0 : -1);
901 fetch_bitmap(HTAB *hashp, int ndx)
903 if (ndx >= hashp->nmaps)
905 if ((hashp->mapp[ndx] = (u_int32_t *)malloc(hashp->BSIZE)) == NULL)
907 if (__get_page(hashp,
908 (char *)hashp->mapp[ndx], hashp->BITMAPS[ndx], 0, 1, 1)) {
909 free(hashp->mapp[ndx]);
912 return (hashp->mapp[ndx]);
923 bufp = __get_buf(hashp, addr, NULL, 0);
929 bufp = __get_buf(hashp, (int)oaddr, bufp, 0);