1: # include   "../ingres.h"
   2: # include   "../aux.h"
   3: # include   "../symbol.h"
   4: # include   "../access.h"
   5: # include   "../lock.h"
   6: 
   7: /* tTf flag 92		TTF */
   8: 
   9: long rhash(des, key)
  10: struct descriptor   *des;
  11: char            key[MAXTUP];
  12: /*
  13:  * RHASH will perform a randomizing hash on the full key.
  14:  *
  15:  */
  16: {
  17:     register struct descriptor  *d;
  18:     register int            i;
  19:     register char           *cp;
  20:     long                bucket;
  21:     char                tmp;
  22:     int             j, *k, knt, numeric;
  23: 
  24:     d = des;
  25:     bucket = 0;
  26:     knt = 0;
  27:     for (i = 1; i <= d->relatts; i++)
  28:         if (d->relxtra[i])
  29:         {
  30:             /* form pointer to field */
  31:             cp = &key[d->reloff[i]];
  32:             numeric = d->relfrmt[i] != CHAR;
  33:             for (j = 0; j < (d->relfrml[i] & I1MASK); j++)
  34:                 if (((tmp = *cp++) != ' ') || numeric)
  35:                     addabyte(tmp, &bucket, knt++);
  36:         }
  37:     /* remove sign bit from bucket the hard way */
  38:     k = (int *) &bucket;
  39:     *k &= 077777;
  40: #	ifdef xATR3
  41:     if (tTf(92, 8))
  42:         printf("rhash:hval=%s", locv(bucket));
  43: #	endif
  44:     bucket %= d->relprim;
  45: #	ifdef xATR3
  46:     if (tTf(92, 8))
  47:         printf(",returning %s\n", locv(bucket));
  48: #	endif
  49:     return (bucket);
  50: }
  51: 
  52: addabyte(ch, word, knt1)
  53: char    ch;
  54: long    *word;
  55: int knt1;
  56: /*
  57:  * ADDABYTE is used to map a long key into a four byte integer.
  58:  * As bytes are added, they are first rotated, then exclusive ored
  59:  * into the existing key.
  60:  *
  61:  */
  62: {
  63:     register int    knt;
  64:     long        i;
  65: 
  66:     knt = knt1;
  67:     i = ch & 0377;  /*get rid of any sign extension*/
  68:     knt += 8 * (knt & 3);   /*alternately add 0, 8, 16 or 24 to knt */
  69:     knt &= 037;
  70:     *word ^= (i << (knt) | i >> (32 - knt));
  71: }

Defined functions

addabyte defined in line 52; used 1 times
  • in line 35
rhash defined in line 9; used 4 times
Last modified: 1995-02-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 461
Valid CSS Valid XHTML 1.0 Strict