# class BDB::Hash

### Public Instance Methods

stat(p1 = v1) click to toggle source

    static VALUE
    bdb_hash_stat(int argc, VALUE *argv, VALUE obj)
    {
        bdb_DB *dbst;
        DB_HASH_STAT *bdb_stat;
        VALUE hash, flagv;
        int flags = 0;
    #if HAVE_DB_STAT_4_TXN
        DB_TXN *txnid = NULL;
    #endif

        if (rb_scan_args(argc, argv, "01", &flagv) == 1) {
            flags = NUM2INT(flagv);
        }
        GetDB(obj, dbst);
    #if HAVE_DB_STAT_4
    #if HAVE_DB_STAT_4_TXN
        if (RTEST(dbst->txn)) {
            bdb_TXN *txnst;

            GetTxnDB(dbst->txn, txnst);
            txnid = txnst->txnid;
        }
        bdb_test_error(dbst->dbp->stat(dbst->dbp, txnid, &bdb_stat, flags));
    #else
        bdb_test_error(dbst->dbp->stat(dbst->dbp, &bdb_stat, 0, flags));
    #endif
    #else
        bdb_test_error(dbst->dbp->stat(dbst->dbp, &bdb_stat, flags));
    #endif
        hash = rb_hash_new();
        rb_hash_aset(hash, rb_tainted_str_new2("hash_magic"), INT2NUM(bdb_stat->hash_magic));
        rb_hash_aset(hash, rb_tainted_str_new2("hash_version"), INT2NUM(bdb_stat->hash_version));
        rb_hash_aset(hash, rb_tainted_str_new2("hash_pagesize"), INT2NUM(bdb_stat->hash_pagesize));
    #if HAVE_ST_DB_HASH_STAT_HASH_NKEYS
        rb_hash_aset(hash, rb_tainted_str_new2("hash_nkeys"), INT2NUM(bdb_stat->hash_nkeys));
    #if ! HAVE_ST_DB_HASH_STAT_HASH_NRECS
        rb_hash_aset(hash, rb_tainted_str_new2("hash_nrecs"), INT2NUM(bdb_stat->hash_nkeys));
    #endif
    #endif
    #if HAVE_ST_DB_HASH_STAT_HASH_NRECS
        rb_hash_aset(hash, rb_tainted_str_new2("hash_nrecs"), INT2NUM(bdb_stat->hash_nrecs));
    #endif
    #if HAVE_ST_DB_HASH_STAT_HASH_NDATA
        rb_hash_aset(hash, rb_tainted_str_new2("hash_ndata"), INT2NUM(bdb_stat->hash_ndata));
    #endif
    #if HAVE_ST_DB_HASH_STAT_HASH_NELEM
        rb_hash_aset(hash, rb_tainted_str_new2("hash_nelem"), INT2NUM(bdb_stat->hash_nelem));
    #endif
        rb_hash_aset(hash, rb_tainted_str_new2("hash_ffactor"), INT2NUM(bdb_stat->hash_ffactor));
        rb_hash_aset(hash, rb_tainted_str_new2("hash_buckets"), INT2NUM(bdb_stat->hash_buckets));
        rb_hash_aset(hash, rb_tainted_str_new2("hash_free"), INT2NUM(bdb_stat->hash_free));
        rb_hash_aset(hash, rb_tainted_str_new2("hash_bfree"), INT2NUM(bdb_stat->hash_bfree));
        rb_hash_aset(hash, rb_tainted_str_new2("hash_bigpages"), INT2NUM(bdb_stat->hash_bigpages));
        rb_hash_aset(hash, rb_tainted_str_new2("hash_big_bfree"), INT2NUM(bdb_stat->hash_big_bfree));
        rb_hash_aset(hash, rb_tainted_str_new2("hash_overflows"), INT2NUM(bdb_stat->hash_overflows));
        rb_hash_aset(hash, rb_tainted_str_new2("hash_ovfl_free"), INT2NUM(bdb_stat->hash_ovfl_free));
        rb_hash_aset(hash, rb_tainted_str_new2("hash_dup"), INT2NUM(bdb_stat->hash_dup));
        rb_hash_aset(hash, rb_tainted_str_new2("hash_dup_free"), INT2NUM(bdb_stat->hash_dup_free));
    #if HAVE_ST_DB_HASH_STAT_HASH_PAGECNT
        rb_hash_aset(hash, rb_tainted_str_new2("hash_pagecnt"), INT2NUM(bdb_stat->hash_pagecnt));
    #endif
        free(bdb_stat);
        return hash;
    }