Beispiel #1
0
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;
}
Beispiel #2
0
static Container *_ht_list_container(QSP_ARG_DECL  Hash_Tbl *htp)
{
	Container *cnt_p;

	cnt_p = new_container(LIST_CONTAINER);
	cnt_p->cnt_lp = ht_list(htp);
	return cnt_p;
}
Beispiel #3
0
//~~~~~~~~~~~~~~~~~MAIN~~~~~~~~~~~~~~~~~~~~~~~
int main(int argc, char* argv[]){
  int debug = 0, flag = 1, arg, numRead = 0;
  char command, *stream;
  Line line = line_init( stdin);
  gen_parse_args( argc, argv, &debug);
  Htable htable = ht_init( ht_mod_hash);

  while(flag){
    arg = -1;
    fprintf( stdout, "\ncommand: ");
    line_read_line( line);
    stream = get_line( line);
    sscanf( stream, " %c%n", &command, &numRead);
    switch( command){
      case 'q': flag = 0; break;
      case 'i': sscanf( stream+numRead, "%d", &arg);
                if( arg < 0) fprintf( stderr, "MUST BE >= 0\n");
                else ht_add( htable, arg, arg, debug);
                break;
      case 'd': sscanf( stream+numRead, "%d", &arg);
                if( arg < 0) fprintf( stderr, "MUST BE >= 0\n");
                else{
                  int pos = ht_mod_hash( htable, arg);
                  node_delete( &((htable->table)[pos]), arg, arg, debug); 
                }
                break;
      case 'c': sscanf( stream+numRead, "%d", &arg);
                if( arg < 0) fprintf( stderr, "MUST BE >= 0\n");
                else{
                  if( ht_exists( htable, arg, debug) )
                    fprintf( stdout, "The value, %d, exists!\n", arg);
                  else
                    fprintf( stdout, "The value, %d, does NOT exist\n", arg);
                }
                break;
      case 'e': ht_erase( htable); break;
      case 'r': sscanf( stream+numRead, "%d", &arg);
                if( arg >= 1) ht_resize( htable, arg, debug);
                else fprintf( stderr, "Error, size must be >= 1\n");
                break;
      case 'l': ht_list( htable); break;
      case '\n': break;
      default: fprintf( stdout, "Sorry, Invalid command\n"); break;
    }
    free(stream);
  }
  line_free( line);
  ht_free( htable);
  return 0;
}
Beispiel #4
0
static void _hash_tbl_substring_find(QSP_ARG_DECL  Frag_Match_Info *fmi_p,const char *frag)
{
	Container *cnt_p;
	//Container *list_cnt_p;
	List *lp;

	cnt_p = FMI_CONTAINER(fmi_p);
	//list_cnt_p = ht_list_container(cnt_p->cnt_htp);
	lp = ht_list(cnt_p->cnt_htp);

	// fmi_p still points to the hash_tbl container...
	search_list_for_fragment(lp,fmi_p,frag);
	//zap_list(list_cnt_p->cnt_lp);	// what does "zap" mean?  BUG?
	zap_list(lp);	// what does "zap" mean?  BUG?
	// BUG memory leak?
}
Beispiel #5
0
char* bc_list(Bitcask *bc, const char* pos, const char* prefix)
{
    return ht_list(bc->tree, pos, prefix);
}