예제 #1
0
void Retsu::Column::create() {
	tchdbtune(database, -1, -1, -1, HDBTLARGE | HDBTDEFLATE);
	
  if(open(HDBOWRITER | HDBOCREAT)) {
		this->close();
	} else {
		throw StorageError("Could not create column at " + path());
	}
}
예제 #2
0
static mrb_value
hdb_tune(mrb_state *mrb, mrb_value self)
{
  hdb_context *context = DATA_PTR(self);
  bool result;
  mrb_int bnum, apow, fpow , opts;

  mrb_get_args(mrb, "iiii", &bnum, &apow, &fpow, &opts);

  result = tchdbtune(context->hdb, bnum, apow, fpow, opts);

  return mrb_bool_value(result);
}
예제 #3
0
파일: tctest.c 프로젝트: Fleurer/nanodb
/* perform write command */
int dowrite(char *name, int rnum){
  TCHDB *hdb;
  int i, err, len;
  char buf[RECBUFSIZ];
  if(showprgr) printf("<Writing Test of Hash>\n  name=%s  rnum=%d\n\n", name, rnum);
  /* open a database */
  hdb = tchdbnew();
  tchdbtune(hdb, rnum * 3, 0, 0, 0);
  tchdbsetxmsiz(hdb, rnum * 48);
  if(!tchdbopen(hdb, name, HDBOWRITER | HDBOCREAT | HDBOTRUNC)){
    fprintf(stderr, "tchdbopen failed\n");
    tchdbdel(hdb);
    return 1;
  }
  err = FALSE;
  /* loop for each record */
  for(i = 1; i <= rnum; i++){
    /* store a record */
    len = sprintf(buf, "%08d", i);
    if(!tchdbputasync(hdb, buf, len, buf, len)){
      fprintf(stderr, "tchdbputasync failed\n");
      err = TRUE;
      break;
    }
    /* print progression */
    if(showprgr && rnum > 250 && i % (rnum / 250) == 0){
      putchar('.');
      fflush(stdout);
      if(i == rnum || i % (rnum / 10) == 0){
        printf(" (%08d)\n", i);
        fflush(stdout);
      }
    }
  }
  /* close the database */
  if(!tchdbclose(hdb)){
    fprintf(stderr, "tchdbclose failed\n");
    tchdbdel(hdb);
    return 1;
  }
  tchdbdel(hdb);
  if(showprgr && !err) printf("ok\n\n");
  return err ? 1 : 0;
}
예제 #4
0
파일: tchmgr.c 프로젝트: kadoma/fms
/* perform create command */
static int proccreate(const char *path, int bnum, int apow, int fpow, int opts){
  TCHDB *hdb = tchdbnew();
  if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd);
  if(!tchdbtune(hdb, bnum, apow, fpow, opts)){
    printerr(hdb);
    tchdbdel(hdb);
    return 1;
  }
  if(!tchdbopen(hdb, path, HDBOWRITER | HDBOCREAT | HDBOTRUNC)){
    printerr(hdb);
    tchdbdel(hdb);
    return 1;
  }
  bool err = false;
  if(!tchdbclose(hdb)){
    printerr(hdb);
    err = true;
  }
  tchdbdel(hdb);
  return err ? 1 : 0;
}
예제 #5
0
파일: tcfiler.c 프로젝트: wix/tcfiler
bool open_cabinet_db(int64_t bnum, bool optimize) {

    int ecode;

    if (optimize) fprintf(stdout, "Opening database optimized for %d items\n", bnum);

    /* tune up the db*/
    if (optimize && !tchdbtune(hdb, bnum, -1, -1, HDBTLARGE)) {
        ecode = tchdbecode(hdb);
        fprintf(stdout, "Failed to tune up database, error: %s\n", tchdberrmsg(ecode));
        return false;
    }

    /* open the database */
    if (!tchdbopen(hdb, tcxstrptr(db_file), HDBOWRITER | HDBOCREAT)) {
        ecode = tchdbecode(hdb);
        fprintf(stdout, "Failed to open database, error: %s\n", tchdberrmsg(ecode));
        return false;
    }

    return true;
}
예제 #6
0
파일: jbhmgr.c 프로젝트: Dean-Jansen/ejdb
/* perform create command */
static int proccreate(const char *path, int bnum, int apow, int fpow, int opts) {
    TCHDB *hdb = tchdbnew();
    if (!INVALIDHANDLE(g_dbgfd)) tchdbsetdbgfd(hdb, g_dbgfd);
    if (!tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL)) printerr(hdb);
    if (!tchdbtune(hdb, bnum, apow, fpow, opts)) {
        printerr(hdb);
        tchdbdel(hdb);
        return 1;
    }
    if (!tchdbopen(hdb, path, HDBOWRITER | HDBOCREAT | HDBOTRUNC)) {
        printerr(hdb);
        tchdbdel(hdb);
        return 1;
    }
    bool err = false;
    if (!tchdbclose(hdb)) {
        printerr(hdb);
        err = true;
    }
    tchdbdel(hdb);
    return err ? 1 : 0;
}
예제 #7
0
파일: db_obj.cpp 프로젝트: Quix0r/seeks
 bool db_obj_local::dbtune(int64_t bnum, int8_t apow, int8_t fpow, uint8_t opts)
 {
   return tchdbtune(_hdb,bnum,apow,fpow,opts);
 }
예제 #8
0
/* tune */
JNIEXPORT jboolean JNICALL Java_tokyocabinet_HDB_tune
(JNIEnv *env, jobject self, jlong bnum, jint apow, jint fpow, jint opts){
  TCHDB *hdb = (TCHDB *)(intptr_t)(*env)->GetLongField(env, self, hdb_fid_ptr);
  return tchdbtune(hdb, bnum, apow, fpow, opts);
}