]> git.llucax.com Git - z.facultad/75.06/jacu.git/commitdiff
Subo esto que tira mucha fruta, pero ayuda a visualizar las cosas
authorRicardo Markiewicz <gazer.arg@gmail.com>
Wed, 23 Jun 2004 02:59:21 +0000 (02:59 +0000)
committerRicardo Markiewicz <gazer.arg@gmail.com>
Wed, 23 Jun 2004 02:59:21 +0000 (02:59 +0000)
src/blocksorting/bs.c
src/jacu.c

index 59a0de9ad2b092b6ddbf3f7632605ca36f23ca8b..b95b74b7612300475790dbe2ac61909b3bbf5769 100644 (file)
@@ -102,7 +102,7 @@ void bs_solve(char *in, char *out, t_BlockSort *bs, Uint32 *k, Uint32 leido)
        /* Guardo el k y el tamaño en el array */
        memcpy(out, &leido, sizeof(Uint32));
        memcpy(out+sizeof(Uint32), k, sizeof(Uint32));
-
+       printf("%ld -> %ld\n", *k, *(Uint32 *)(out+sizeof(Uint32)));
        bs->len = l;
 }
 
index d0deb90431a11270449666361958bd6521cee38a..bc56a41350462d52983219a79a19e7d5a88e763d 100644 (file)
@@ -115,9 +115,16 @@ int main(int argc, char* argv[])
                        /* Hago el BS */
                        bs_solve(data, salida, bs, &k, i);
 
-                       printf("BS k=%ld\n", k);
-                       printf("PageSize = %ld\n", i);
+                       printf("BS k=%ld\n", *(Uint32 *)(salida+sizeof(Uint32)));
+                       printf("PageSize = %ld\n", *(Uint32 *)salida);
 
+                       printf("Antes de MTF = %ld [", i);
+                       {
+                               int ii;
+                               for(ii=0; ii<(i+sizeof(Uint32)); ii++)
+                                       printf("(%c)", salida[ii+sizeof(Uint32)]);
+                               printf("]\n");
+                       }
                        /* Le aplico el MTF, salteo el tamaño del bloque para que no se pierda. */
                        mtf = jacu_mtf(salida+sizeof(Uint32), i+sizeof(Uint32), &z, &z_len);
 
@@ -140,15 +147,21 @@ int main(int argc, char* argv[])
                                        if ((len = zg_group(&zg, buff, mtf[j]))) fwrite(buff, 1, len, fp_out);
                        } else {
                                /* Guardo el PageSize */
-                               fwrite(&i, sizeof(Uint32), 1, fp_out);
+                               fwrite(salida, sizeof(Uint32), 1, fp_out);
 
                                /* Guardo el Z len y el Z */
                                fwrite(&z_len, sizeof(int), 1, fp_out);
                                fwrite(z, z_len, sizeof(char), fp_out);
 
                                /* Guardo la salida del MTF */
-                               for(j=sizeof(Uint32); j<i; j++)
-                                       fputc(mtf[j], fp_out);
+                               printf("Despues de MTF : [");
+                               for(j=0; j<(i+sizeof(Uint32)); j++) {
+                                       fputc(mtf[j+sizeof(Uint32)], fp_out);
+                                       putchar('(');
+                                       fputc(mtf[j+sizeof(Uint32)], stdout);
+                                       putchar(')');
+                               }
+                               printf("]\n");
                        }
                        free(mtf);
                        free(z);
@@ -203,15 +216,30 @@ int main(int argc, char* argv[])
                        if (block_size > 0) {
                                block = malloc(block_size*sizeof(char)+sizeof(Uint32));
                                orig = malloc(block_size*sizeof(char));
-                               fread(block, block_size, sizeof(char), fp_in);
+                               fread(block, block_size+sizeof(Uint32), sizeof(char), fp_in);
 
+                               printf("Antes MTF_inv = [");
+                               {
+                                       int ii;
+                                       for(ii=0; ii<block_size+sizeof(Uint32); ii++)
+                                               printf("(%c)", block[ii]);
+                                       printf("]\n");
+                               }
                                /* Hago el MTF inverso */
                                PERR("Haciendo MTF Inv");
-                               mtf = jacu_mtf_inv(z, block, block_size);
+                               mtf = jacu_mtf_inv(z, block, block_size*sizeof(char)+sizeof(Uint32));
+
+                               printf("Luego de MTF = [");
+                               {
+                                       int ii;
+                                       for(ii=0; ii<block_size+sizeof(Uint32); ii++)
+                                               printf("%c", mtf[ii]);
+                                       printf("]\n");
+                               }
 
                                /* Luego de hacer el MTF inverso ya puedo recuperar el k */
                                PERR("Recuperando K");
-                               memcpy(&k, block, sizeof(Uint32));
+                               memcpy(&k, mtf, sizeof(Uint32));
 
                                printf("Restored : k=%ld\n", k);
                                PERR("BS_Restore");