X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/c1df639f58f6d3c08247c1543916644e375f8ce2..483a5117682096de3de466a07f2e409a2166f164:/emufs/b_plus_test.c diff --git a/emufs/b_plus_test.c b/emufs/b_plus_test.c index 0dc7603..2bc6eb3 100644 --- a/emufs/b_plus_test.c +++ b/emufs/b_plus_test.c @@ -1,56 +1,62 @@ -#include "b_plus.h" +#include "emufs.h" +#include "indices.h" +#include "indice_bplus.h" int main(int argc, char* argv[]) { /* Locals */ INDEX_DAT querydata; +int i = 0; +int exitcode = 0; +int tam_nodo = SIZE_B_PLUS_HEADER + sizeof(CLAVE)*5 + sizeof(CLAVE)*6; /*NODO_B_PLUS *memnodo;*/ -int i; + /* Creamos un handler EMUFS, luego un Indice B+ y testing... */ -INDEXSPECS indice; -indice.tam_bloque = SIZE_B_PLUS_HEADER + sizeof(int)*5 + sizeof(int)*6; -indice.size_claves = (indice.tam_bloque - SIZE_B_PLUS_HEADER - sizeof(int))/2; -indice.size_hijos = indice.size_claves + sizeof(int); -indice.filename = "idxbplus_primary.idx"; -printf("\nTam Nodo: %i Size Claves: %i Size_Hijos: %i\n",indice.tam_bloque,indice.size_claves,indice.size_hijos); -emufs_b_plus_crear(&indice); - -for (i=1;i<34;++i) +EMUFS *emu = emufs_crear("fact",T1,512,0); +emufs_agregar_indice(emu,"nrofact",IND_PRIMARIO,IND_B_PLUS,IDX_INT,16,tam_nodo); +printf("\nTam Nodo: %i Size Claves: %i Size_Hijos: %i\n",emu->indices->tam_bloque,emu->indices->size_claves,emu->indices->size_hijos); + +for (i=1;i<34;i = i*2) { -querydata.num_bloque = i; +printf("Insertando clave %i\n",i); +querydata.num_bloque = floor(i/2)+3; querydata.clave.i_clave = i; -b_plus_insertar(&indice,&querydata); +emufs_b_plus_insertar(emu->indices,&querydata); } +/* NOTA: Deberia devolver el mismo 104 y Exitcode = -1 */ +/*querydata.num_bloque = 104; +querydata.clave.i_clave = 0; +exitcode = emufs_b_plus_get_bloque(emu->indices,&querydata,0); +printf("Numero de bloque donde grabar clave 0: %i\n",(int)(querydata.num_bloque)); +printf("Exit Code del get bloque: %i\n",exitcode);*/ + +/* NOTA: Deberia devolver un numero de bloque X y Exitcode = 0 */ +/*querydata.num_bloque = 104; +querydata.clave.i_clave = 25; +exitcode = emufs_b_plus_get_bloque(emu->indices,&querydata,0); +printf("Numero de bloque donde grabar clave 25: %i\n",(int)(querydata.num_bloque)); +printf("Exit Code del get bloque: %i\n",exitcode);*/ + /* querydata.num_bloque = 2; querydata.clave.i_clave = 7; b_plus_insertar(&indice,&querydata); querydata.num_bloque = 7; -<<<<<<< .mine -querydata.clave.i_clave = 5; -b_plus_insertar_clave(&indice,&querydata); -======= querydata.clave.i_clave = 5; b_plus_insertar(&indice,&querydata); ->>>>>>> .r497 querydata.num_bloque = 5; -<<<<<<< .mine querydata.clave.i_clave = 3; b_plus_insertar_clave(&indice,&querydata); -======= -querydata.clave.i_clave = 3; -b_plus_insertar(&indice,&querydata); ->>>>>>> .r497 querydata.num_bloque = 8; querydata.clave.i_clave = 63; b_plus_insertar(&indice,&querydata); -/*num_node = 0; +num_node = 0; memnodo = b_plus_leer_nodo(&indice, num_node); printf("Dumping Node_%i\n",num_node); printf("Nivel: %i Cant Claves: %i\n",memnodo->nivel,memnodo->cant_claves); @@ -59,8 +65,8 @@ memnodo = b_plus_leer_nodo(&indice, num_node); printf("\nHijos:"); for (i = 0; i < indice.size_hijos/sizeof(int); ++i) printf(" %i",memnodo->hijos[i]); printf("\nEnd Dump\n"); -free(memnodo);*/ - /* +free(memnodo); + querydata.num_bloque = 54; querydata.clave.i_clave = 1; b_plus_insertar(&indice, &querydata); @@ -77,7 +83,7 @@ querydata.num_bloque = 22; querydata.clave.i_clave = 4; b_plus_insertar(&indice, &querydata); -/*querydata.num_bloque = 6; +querydata.num_bloque = 6; querydata.clave.i_clave = 100; b_plus_insertar(&indice, &querydata);*/ return 0;