Is this a bug of TokyoCabinet?
It's basically a binary tree which first searches against hash to decide whether it's `left` or `right`:

    if(hash > rec.hash){
      off = rec.left;
      entoff = rec.off + (sizeof(uint8_t) + sizeof(uint8_t));
    } else if(hash < rec.hash){
      off = rec.right;
      entoff = rec.off + (sizeof(uint8_t) + sizeof(uint8_t)) +
        (hdb->ba64 ? sizeof(uint64_t) : sizeof(uint32_t));
    } else {
      if(!rec.kbuf && !tchdbreadrecbody(hdb, &rec)) return false;
      int kcmp = tcreckeycmp(kbuf, ksiz, rec.kbuf, rec.ksiz);
      if(kcmp > 0){
        off = rec.left;
        ...
      } else if(kcmp < 0){
        off = rec.right;
        ...

Here's how hash calculated:


    static uint64_t tchdbbidx(TCHDB *hdb, const char *kbuf, int ksiz, uint8_t *hp){
      ...
      uint32_t hash = 751;
      const char *rp = kbuf + ksiz;
      while(ksiz--){
        ...
        hash = (hash * 31) ^ *(uint8_t *)--rp;
      }
      *hp = hash;
      ...
    }


But it seems the way the hash calculated can't ensure the orderness of keys,

is it a bug?
Is this a bug of TokyoCabinet?
===

It's basically a binary tree which first searches against hash to decide whether it's `left` or `right`:

    if(hash > rec.hash){
      off = rec.left;
      entoff = rec.off + (sizeof(uint8_t) + sizeof(uint8_t));
    } else if(hash < rec.hash){
      off = rec.right;
      entoff = rec.off + (sizeof(uint8_t) + sizeof(uint8_t)) +
        (hdb->ba64 ? sizeof(uint64_t) : sizeof(uint32_t));
    } else {
      if(!rec.kbuf && !tchdbreadrecbody(hdb, &rec)) return false;
      int kcmp = tcreckeycmp(kbuf, ksiz, rec.kbuf, rec.ksiz);
      if(kcmp > 0){
        off = rec.left;
        ...
      } else if(kcmp < 0){
        off = rec.right;
        ...

Here's how hash calculated:


    static uint64_t tchdbbidx(TCHDB *hdb, const char *kbuf, int ksiz, uint8_t *hp){
      ...
      uint32_t hash = 751;
      const char *rp = kbuf + ksiz;
      while(ksiz--){
        ...
        hash = (hash * 31) ^ *(uint8_t *)--rp;
      }
      *hp = hash;
      ...
    }


But it seems the way the hash calculated can't ensure the orderness of keys,

is it a bug?