コード例 #1
0
ファイル: test_htree.c プロジェクト: 29n/beansdb
int main(int argc, char** argv)
{
    HTree *t = ht_open("*", 0);
    printf("hash %d\n", ht_get_hash(t, "@", NULL));
    printf("%s\n", ht_list(t,""));
    ht_clear(t);
    //printf("hash %d\n", ht_get_hash(t, "@", NULL));
    //printf("%s\n", ht_list(t,""));

    int i=0;
    char buf[100];
    for (int k=0;k<1;k++){
        for (i=0;i<200000;i++){
            sprintf(buf, "/photo/photo/%d.jpg", i);
            //printf(buf);
            ht_add(t, buf, 1, 3, 0);
        }
        printf("add complete\n");
        for (i=0;i<1000;i++){
            sprintf(buf, "/photo/photo/%d.jpg", i);
            /*sprintf(buf, "/photo/photo/xxxxxxxxxxxxxxxxxxxxxxfile%d", i);*/
            //ht_remove(t, buf, 0);
        }
        printf("remove complete\n");
    }
    //remove_from_htree(buf);
    printf("update complete\n");
    // print_tree(&tree);
   
    printf("hash %d\n", ht_get_hash(t, "@", NULL));
    printf("%s\n", ht_list(t,""));

    ht_close(t);
    return 0;
}
コード例 #2
0
ファイル: bitcask.c プロジェクト: haiger/beansdb
uint32_t   bc_count(Bitcask *bc, uint32_t* curr)
{
    uint32_t total = 0;
    ht_get_hash(bc->tree, "@", &total);
    if (NULL != curr && NULL != bc->curr_tree) {
        ht_get_hash(bc->curr_tree, "@", curr);
    }
    return total;
}
コード例 #3
0
ファイル: bitcask.c プロジェクト: haiger/beansdb
/*
 * bc_close() is not thread safe, should stop other threads before call it.
 * */
void bc_close(Bitcask *bc)
{
    int i=0;
    pthread_mutex_lock(&bc->write_lock);
    bc_flush(bc, 0, 0);
    
    if (NULL != bc->curr_tree) {
        uint32_t curr;
        ht_get_hash(bc->curr_tree, "@", &curr);
        if (curr > 0) {
            char name[255], buf[255];
            sprintf(name, HINT_FILE, bc->curr);
            sprintf(buf, "%s/%s", mgr_alloc(bc->mgr, name), name);
            build_hint(bc->curr_tree, buf);
        }else{
            ht_destroy(bc->curr_tree);
        }
        bc->curr_tree = NULL;
    }
    bc->curr = 0;
    ht_destroy(bc->tree);
    mgr_destroy(bc->mgr);
    free(bc->write_buffer);
    free(bc);
}
コード例 #4
0
ファイル: bitcask.c プロジェクト: alexband/beansdb
uint16_t bc_get_hash(Bitcask *bc, const char * pos, int *count)
{
    return ht_get_hash(bc->tree, pos, count);
}