class BDB::Recno
Public Instance Methods
<<(p1)
click to toggle source
static VALUE bdb_append(obj, val) VALUE val, obj; { return bdb_append_internal(1, &val, obj, DB_APPEND, Qfalse); }
compact(p1 = v1, p2 = v2, p3 = v3)
click to toggle source
static VALUE bdb_treerec_compact(int argc, VALUE *argv, VALUE obj) { bdb_DB *dbst; DB_TXN *txnid; DBT start, stop, end; DBT *pstart, *pstop; DB_COMPACT cdata; db_recno_t recno_start, recno_stop; int flags; VALUE a, b, c, result; pstop = pstart = NULL; MEMZERO(&cdata, DB_COMPACT, 1); flags = 0; INIT_TXN(txnid, obj, dbst); switch (rb_scan_args(argc, argv, "03", &a, &b, &c)) { case 3: if (FIXNUM_P(c)) { flags = NUM2INT(c); } else { struct data_flags *dtf; VALUE dtobj; dtobj = Data_Make_Struct(rb_cData, struct data_flags, 0, free, dtf); dtf->cdata = &cdata; dtf->flags = 0; rb_iterate(rb_each, c, bdb_compact_i, dtobj); flags = dtf->flags; } /* ... */ case 2: if (!NIL_P(b)) { MEMZERO(&stop, DBT, 1); b = bdb_test_recno(obj, &start, &recno_stop, b); pstop = &stop; } /* ... */ case 1: if (!NIL_P(a)) { MEMZERO(&start, DBT, 1); a = bdb_test_recno(obj, &start, &recno_start, a); pstart = &start; } } MEMZERO(&end, DBT, 1); bdb_test_error(dbst->dbp->compact(dbst->dbp, txnid, pstart, pstop, &cdata, flags, &end)); result = rb_hash_new(); rb_hash_aset(result, rb_tainted_str_new2("end"), bdb_test_load_key(obj, &end)); rb_hash_aset(result, rb_tainted_str_new2("compact_deadlock"), INT2NUM(cdata.compact_deadlock)); rb_hash_aset(result, rb_tainted_str_new2("compact_levels"), INT2NUM(cdata.compact_levels)); rb_hash_aset(result, rb_tainted_str_new2("compact_pages_free"), INT2NUM(cdata.compact_pages_free)); rb_hash_aset(result, rb_tainted_str_new2("compact_pages_examine"), INT2NUM(cdata.compact_pages_examine)); rb_hash_aset(result, rb_tainted_str_new2("compact_pages_truncated"), INT2NUM(cdata.compact_pages_truncated)); return result; }
each_index(*args)
click to toggle source
VALUE bdb_each_key(int argc, VALUE *argv, VALUE obj) { return bdb_each_kvc(argc, argv, obj, DB_NEXT, Qfalse, BDB_ST_KEY); }
push(*args)
click to toggle source
static VALUE bdb_append_m(int argc, VALUE *argv, VALUE obj) { return bdb_append_internal(argc, argv, obj, DB_APPEND, Qtrue); }
stat(p1 = v1)
click to toggle source
VALUE bdb_tree_stat(int argc, VALUE *argv, VALUE obj) { bdb_DB *dbst; DB_BTREE_STAT *bdb_stat; VALUE hash, flagv; char pad; 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("bt_magic"), INT2NUM(bdb_stat->bt_magic)); rb_hash_aset(hash, rb_tainted_str_new2("bt_version"), INT2NUM(bdb_stat->bt_version)); rb_hash_aset(hash, rb_tainted_str_new2("bt_dup_pg"), INT2NUM(bdb_stat->bt_dup_pg)); rb_hash_aset(hash, rb_tainted_str_new2("bt_dup_pgfree"), INT2NUM(bdb_stat->bt_dup_pgfree)); rb_hash_aset(hash, rb_tainted_str_new2("bt_free"), INT2NUM(bdb_stat->bt_free)); rb_hash_aset(hash, rb_tainted_str_new2("bt_int_pg"), INT2NUM(bdb_stat->bt_int_pg)); rb_hash_aset(hash, rb_tainted_str_new2("bt_int_pgfree"), INT2NUM(bdb_stat->bt_int_pgfree)); rb_hash_aset(hash, rb_tainted_str_new2("bt_leaf_pg"), INT2NUM(bdb_stat->bt_leaf_pg)); rb_hash_aset(hash, rb_tainted_str_new2("bt_leaf_pgfree"), INT2NUM(bdb_stat->bt_leaf_pgfree)); rb_hash_aset(hash, rb_tainted_str_new2("bt_levels"), INT2NUM(bdb_stat->bt_levels)); rb_hash_aset(hash, rb_tainted_str_new2("bt_minkey"), INT2NUM(bdb_stat->bt_minkey)); #if HAVE_ST_DB_BTREE_STAT_BT_NRECS rb_hash_aset(hash, rb_tainted_str_new2("bt_nrecs"), INT2NUM(bdb_stat->bt_nrecs)); #endif #if HAVE_ST_DB_BTREE_STAT_BT_NKEYS rb_hash_aset(hash, rb_tainted_str_new2("bt_nkeys"), INT2NUM(bdb_stat->bt_nkeys)); #if ! HAVE_ST_DB_BTREE_STAT_BT_NRECS rb_hash_aset(hash, rb_tainted_str_new2("bt_nrecs"), INT2NUM(bdb_stat->bt_nkeys)); #endif #endif #if HAVE_ST_DB_BTREE_STAT_BT_NDATA rb_hash_aset(hash, rb_tainted_str_new2("bt_ndata"), INT2NUM(bdb_stat->bt_ndata)); #endif rb_hash_aset(hash, rb_tainted_str_new2("bt_over_pg"), INT2NUM(bdb_stat->bt_over_pg)); rb_hash_aset(hash, rb_tainted_str_new2("bt_over_pgfree"), INT2NUM(bdb_stat->bt_over_pgfree)); rb_hash_aset(hash, rb_tainted_str_new2("bt_pagesize"), INT2NUM(bdb_stat->bt_pagesize)); rb_hash_aset(hash, rb_tainted_str_new2("bt_re_len"), INT2NUM(bdb_stat->bt_re_len)); pad = (char)bdb_stat->bt_re_pad; rb_hash_aset(hash, rb_tainted_str_new2("bt_re_pad"), rb_tainted_str_new(&pad, 1)); #if HAVE_ST_DB_BTREE_STAT_BT_PAGECNT rb_hash_aset(hash, rb_tainted_str_new2("bt_pagecnt"), INT2NUM(bdb_stat->bt_pagecnt)); #endif free(bdb_stat); return hash; }
unshift(*args)
click to toggle source
static VALUE bdb_unshift(int argc, VALUE *argv, VALUE obj) { bdb_DB *dbst; DB_TXN *txnid; int flag; INIT_TXN(txnid, obj, dbst); if (dbst->flags & DB_RENUMBER) { flag = 0; } else { flag = DB_NOOVERWRITE; } return bdb_append_internal(argc, argv, obj, flag, Qtrue); }