void Retsu::Column::optimize() { if(tchdbrnum(this->database) % (1<<16) == 0) { if(!tchdboptimize(database, -1, -1, -1, HDBTLARGE | HDBTDEFLATE)) { throw StorageError("Could not optimize column at " + path()); } } }
static mrb_value hdb_empty_(mrb_state *mrb, mrb_value self) { hdb_context *context = DATA_PTR(self); uint64_t records = tchdbrnum(context->hdb); return mrb_bool_value(records == 0); }
static mrb_value hdb_record_num(mrb_state *mrb, mrb_value self) { hdb_context *context = DATA_PTR(self); uint64_t records = tchdbrnum(context->hdb); return mrb_fixnum_value(records); }
/* perform inform command */ static int procinform(const char *path, int omode) { TCHDB *hdb = tchdbnew(); if (!INVALIDHANDLE(g_dbgfd)) tchdbsetdbgfd(hdb, g_dbgfd); tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL); if (!tchdbopen(hdb, path, HDBOREADER | omode)) { printerr(hdb); tchdbdel(hdb); return 1; } bool err = false; const char *npath = tchdbpath(hdb); if (!npath) npath = "(unknown)"; printf("path: %s\n", npath); const char *type = "(unknown)"; switch (tchdbtype(hdb)) { case TCDBTHASH: type = "hash"; break; case TCDBTBTREE: type = "btree"; break; case TCDBTFIXED: type = "fixed"; break; case TCDBTTABLE: type = "table"; break; } printf("database type: %s\n", type); uint8_t flags = tchdbflags(hdb); printf("additional flags:"); if (flags & HDBFOPEN) printf(" open"); if (flags & HDBFFATAL) printf(" fatal"); printf("\n"); printf("bucket number: %" PRIu64 "\n", (uint64_t) tchdbbnum(hdb)); #ifndef NDEBUG if (hdb->cnt_writerec >= 0) printf("used bucket number: %" PRId64 "\n", (int64_t) tchdbbnumused(hdb)); #endif printf("alignment: %u\n", tchdbalign(hdb)); printf("free block pool: %u\n", tchdbfbpmax(hdb)); printf("inode number: %" PRId64 "\n", (int64_t) tchdbinode(hdb)); char date[48]; tcdatestrwww(tchdbmtime(hdb), INT_MAX, date); printf("modified time: %s\n", date); uint8_t opts = tchdbopts(hdb); printf("options:"); if (opts & HDBTLARGE) printf(" large"); if (opts & HDBTDEFLATE) printf(" deflate"); if (opts & HDBTBZIP) printf(" bzip"); if (opts & HDBTTCBS) printf(" tcbs"); if (opts & HDBTEXCODEC) printf(" excodec"); printf("\n"); printf("record number: %" PRIu64 "\n", (uint64_t) tchdbrnum(hdb)); printf("file size: %" PRIu64 "\n", (uint64_t) tchdbfsiz(hdb)); if (!tchdbclose(hdb)) { if (!err) printerr(hdb); err = true; } tchdbdel(hdb); return err ? 1 : 0; }
/* perform count command */ static int proccount(const char *path, int omode){ TCHDB *hdb = tchdbnew(); if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd); tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL); if(!tchdbopen(hdb, path, HDBOREADER | omode)){ printerr(hdb); tchdbdel(hdb); return 1; } bool err = false; printf("%llu\n", (unsigned long long)tchdbrnum(hdb)); if(!tchdbclose(hdb)){ if(!err) printerr(hdb); err = true; } tchdbdel(hdb); return err ? 1 : 0; }
/* perform inform command */ static int procinform(const char *path, int omode){ TCHDB *hdb = tchdbnew(); if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd); if(!tchdbopen(hdb, path, HDBOREADER | omode)){ printerr(hdb); tchdbdel(hdb); return 1; } bool err = false; const char *npath = tchdbpath(hdb); if(!npath) npath = "(unknown)"; printf("path: %s\n", npath); const char *type = "(unknown)"; switch(tchdbtype(hdb)){ case HDBTHASH: type = "hash"; break; case HDBTBTREE: type = "btree"; break; } printf("database type: %s\n", type); uint8_t flags = tchdbflags(hdb); printf("additional flags:"); if(flags & HDBFOPEN) printf(" open"); if(flags & HDBFFATAL) printf(" fatal"); printf("\n"); printf("bucket number: %llu\n", (unsigned long long)tchdbbnum(hdb)); if(hdb->cnt_writerec >= 0) printf("used bucket number: %lld\n", (long long)tchdbbnumused(hdb)); printf("alignment: %u\n", tchdbalign(hdb)); printf("free block pool: %u\n", tchdbfbpmax(hdb)); uint8_t opts = tchdbopts(hdb); printf("options:"); if(opts & HDBTLARGE) printf(" large"); if(opts & HDBTDEFLATE) printf(" deflate"); printf("\n"); printf("record number: %llu\n", (unsigned long long)tchdbrnum(hdb)); printf("file size: %llu\n", (unsigned long long)tchdbfsiz(hdb)); if(!tchdbclose(hdb)){ if(!err) printerr(hdb); err = true; } tchdbdel(hdb); return err ? 1 : 0; }
uint64_t db_obj_local::dbrnum() const { return tchdbrnum(_hdb); }
bool cnt(boost::uint64_t & cnt) { assert_data_store_open(); cnt = tchdbrnum(pdb_); return true; }
/* rnum */ JNIEXPORT jlong JNICALL Java_tokyocabinet_HDB_rnum (JNIEnv *env, jobject self){ TCHDB *hdb = (TCHDB *)(intptr_t)(*env)->GetLongField(env, self, hdb_fid_ptr); return tchdbrnum(hdb); }