Ejemplo n.º 1
0
 bool del(
    void const * pkey, size_t const ksize
    )
 {
    assert_data_store_open();
    return tchdbout(pdb_, pkey, ksize);
 }
Ejemplo n.º 2
0
void purge_dbb_beyond(INOBNO *inobno)
{
    char *asc_hash = NULL;
    char *key, *value;
    int size;
    int vsize;
    INOBNO inobnocur;

    printf("purge_dbb_beyond : purge fileblock metadata after blocknr %llu\n",inobno->blocknr);
    /* traverse records */
    tchdbiterinit(dbb);
    while ((key = tchdbiternext(dbb, &size)) != NULL) {
        value = tchdbget(dbb, key, size, &vsize);
        memcpy(&inobnocur.inode, key, sizeof(unsigned long long));
        memcpy(&inobnocur.blocknr, key + sizeof(unsigned long long),
               sizeof(unsigned long long));
        if ( inobno->inode == inobnocur.inode ) {
           if ( inobnocur.blocknr > inobno->blocknr ) {
              printf("delete reference %llu-%llu\n",inobnocur.inode,inobnocur.blocknr);
              tchdbout(dbb,&inobnocur,sizeof(INOBNO));
// Verify dbu in this case.
           }
        }
        free(asc_hash);
        free(value);
        free(key);
    }
}
Ejemplo n.º 3
0
static bool Delete(TCHDB *hdb, const void *key, int key_size)
{
    if (!tchdbout(hdb, key, key_size) && tchdbecode(hdb) != TCENOREC)
    {
        Log(LOG_LEVEL_ERR, "Could not delete Tokyo key. (tchdbout: %s)",
            ErrorMessage(hdb));
        return false;
    }

    return true;
}
Ejemplo n.º 4
0
static bool Delete(TCHDB *hdb, const void *key, int key_size)
{
    if (!tchdbout(hdb, key, key_size) && tchdbecode(hdb) != TCENOREC)
    {
        CfOut(cf_error, "", "!! tchdbout: Could not delete key: %s",
              ErrorMessage(hdb));
        return false;
    }

    return true;
}
Ejemplo n.º 5
0
/** 
 * delete a record by key 
 */
int DeleteRecord(tcDatabase hdb, tcKey key)
{
    int ecode;
    if(!tchdbout((TCHDB*)hdb, &key, sizeof(tcKey)))
    {
        ecode = tchdbecode(hdb);
        fprintf(stderr, "delete error: %s\n", tchdberrmsg(ecode));
        return FAILURE;
    }
    return SUCCESS;
}
Ejemplo n.º 6
0
static int
_tc_delete (mu_dbm_file_t db, struct mu_dbm_datum const *key)
{
  TCHDB *hdb = db->db_descr;

  if (tchdbout (hdb, key->mu_dptr, key->mu_dsize))
    return 0;
  db->db_errno.n = tchdbecode (hdb);
  if (db->db_errno.n == TCENOREC)
    return MU_ERR_NOENT;
  return MU_ERR_FAILURE;
}
Ejemplo n.º 7
0
void check_orphaned_data_blocks()
{
    char *key;

    /* traverse records */
    tchdbiterinit(dbdta);
    while ((key = tchdbiternext2(dbdta)) != NULL) {
        if ( 0 == check_inuse((unsigned char *)key)) {
           printhash("Deleting orphaned hash",(unsigned char *)key);
           if (!tchdbout(dbdta, key, config->hashlen)) {
              die_syserr();
           }
        }
        free(key);
    }
}
Ejemplo n.º 8
0
/* out */
JNIEXPORT jboolean JNICALL Java_tokyocabinet_HDB_out
(JNIEnv *env, jobject self, jbyteArray key){
  if(!key){
    throwillarg(env);
    return false;
  }
  TCHDB *hdb = (TCHDB *)(intptr_t)(*env)->GetLongField(env, self, hdb_fid_ptr);
  jboolean ick;
  jbyte *kbuf = (*env)->GetByteArrayElements(env, key, &ick);
  if(!kbuf){
    throwoutmem(env);
    return false;
  }
  int ksiz = (*env)->GetArrayLength(env, key);
  bool rv = tchdbout(hdb, kbuf, ksiz);
  if(ick) (*env)->ReleaseByteArrayElements(env, key, kbuf, JNI_ABORT);
  return rv;
}
Ejemplo n.º 9
0
static mrb_value
hdb_out(mrb_state *mrb, mrb_value self)
{
  hdb_context *context = DATA_PTR(self);
  bool result;
  mrb_value key;
  void *kbuf;
  int ksize;
  mrb_int kint;

  mrb_get_args(mrb, "o", &key);

  if (!get_content(key, &kint, &kbuf, &ksize)) {
    mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid type of key");
  }
  result = tchdbout(context->hdb, kbuf, ksize);

  return mrb_bool_value(result);
}
Ejemplo n.º 10
0
Archivo: tchmgr.c Proyecto: kadoma/fms
/* perform out command */
static int procout(const char *path, const char *kbuf, int ksiz, int omode){
  TCHDB *hdb = tchdbnew();
  if(g_dbgfd >= 0) tchdbsetdbgfd(hdb, g_dbgfd);
  if(!tchdbopen(hdb, path, HDBOWRITER | omode)){
    printerr(hdb);
    tchdbdel(hdb);
    return 1;
  }
  bool err = false;
  if(!tchdbout(hdb, kbuf, ksiz)){
    printerr(hdb);
    err = true;
  }
  if(!tchdbclose(hdb)){
    if(!err) printerr(hdb);
    err = true;
  }
  tchdbdel(hdb);
  return err ? 1 : 0;
}
Ejemplo n.º 11
0
/* perform out command */
static int procout(const char *path, const char *kbuf, int ksiz, int omode) {
    TCHDB *hdb = tchdbnew();
    if (!INVALIDHANDLE(g_dbgfd)) tchdbsetdbgfd(hdb, g_dbgfd);
    if (!tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL)) printerr(hdb);
    if (!tchdbopen(hdb, path, HDBOWRITER | omode)) {
        printerr(hdb);
        tchdbdel(hdb);
        return 1;
    }
    bool err = false;
    if (!tchdbout(hdb, kbuf, ksiz)) {
        printerr(hdb);
        err = true;
    }
    if (!tchdbclose(hdb)) {
        if (!err) printerr(hdb);
        err = true;
    }
    tchdbdel(hdb);
    return err ? 1 : 0;
}