Here the final patch with also the option to see the process when in debug mode, I had forgot to remove them in the previous -------------------------------------------------------------------------
Index: constraints_parser.c =================================================================== --- constraints_parser.c (revision 4) +++ constraints_parser.c (working copy) @@ -657,6 +657,7 @@ struct stat st; char src[256];
+ char buffer[16*1024]; setvbuf(stdout, buffer, _IOFBF, sizeof(buffer));
@@ -727,11 +728,16 @@ char src_file[256]; struct dirent *de; src_dir = opendir(src); + int file_count = 0; + + +/* while(NULL != (de = readdir(src_dir))){ if(!strncmp(de->d_name, ".", sizeof(de->d_name))) continue; if(!strncmp(de->d_name, "..", sizeof(de->d_name))) continue; snprintf(src_file, sizeof(src_file), "%s/%s", src, de->d_name); if(debug) { fprintf(stderr, "Processing %s\n", src_file); } + fprintf(stderr, "Processing %s\n", src_file); if(0 == (fn = open_ibfile(src_file))){ fprintf(stderr, "Can't open %s\n", src_file); perror("open_ibfile"); @@ -740,7 +746,82 @@ process_ibfile(fn); close(fn); } +*/ +/*The pages are NOT read from the readdir function in sorted order + * To have them sorted we have to process them first + * + * Below we first identify the number of files to parse + * + * then we create an array with all the names and we sort it + * + * Then we process it. + * + * Process can be optimize, but at least is not presenting the pages in sparse order in the result file. + * + * Use debug option to enable the progress view + */ + +/* + * Start Patch \/ + */ + while(NULL != (de = readdir(src_dir))){ + if(!strncmp(de->d_name, ".", sizeof(de->d_name))) continue; + if(!strncmp(de->d_name, "..", sizeof(de->d_name))) continue; + file_count++; + + } + + char result[file_count][255]; + int indexres = 0; + + src_dir = opendir(src); + while(NULL != (de = readdir(src_dir))){ + if(!strncmp(de->d_name, ".", sizeof(de->d_name))) continue; + if(!strncmp(de->d_name, "..", sizeof(de->d_name))) continue; + snprintf(src_file, sizeof(src_file), "%s/%s", src, de->d_name); + + strcpy(result[indexres++], src_file) ; + if(debug){ fprintf(stderr, "Processing %s\n", src_file); } + } + closedir(src_dir); + + int i,j; + char t[file_count]; + + for(i=1;i<file_count;i++){ + for(j=1;j<file_count;j++) + { + //fprintf(stderr, "value %d\n", strcmp(result[j-1],result[j])>0); + if(strcmp(result[j-1],result[j])>0) + { + strcpy(t,result[j-1]); + strcpy(result[j-1],result[j]); + strcpy(result[j],t); + } + } + } + + + indexres = 0; + if(debug){fprintf(stderr, "Processing, \nTotal pages to process %d %s",file_count, ":");} + while(indexres<file_count){ + if(debug){fprintf(stderr, "%s", ".");} + if(0 == (fn = open_ibfile(result[indexres]))){ + fprintf(stderr, "Can't open %s\n", result[indexres]); + perror("open_ibfile"); + exit(-1); + } + process_ibfile(fn); + indexres++; + close(fn); + } + if(debug){fprintf(stderr, "%s\n", "END Processing\n");} +/* + * END Patch /\ + */ + + } else{ if(0 == (fn = open_ibfile(src))){ @@ -751,6 +832,7 @@ process_ibfile(fn); close(fn); } + table_def_t *table = &(table_definitions[0]); fprintf(stderr, "SET FOREIGN_KEY_CHECKS=0;\n"); fprintf(stderr, "LOAD DATA INFILE '");
Here the final patch with also the option to see the process when in debug mode, I had forgot to remove them in the previous ------- ------- ------- ------- ------- ------- ------- ------- ------- ---
-------
Index: constraints_ parser. c ======= ======= ======= ======= ======= ======= ======= ======= ==== parser. c (revision 4) parser. c (working copy)
=======
--- constraints_
+++ constraints_
@@ -657,6 +657,7 @@
struct stat st;
char src[256];
+
setvbuf( stdout, buffer, _IOFBF, sizeof(buffer));
char buffer[16*1024];
@@ -727,11 +728,16 @@ !strncmp( de->d_name, ".", sizeof( de->d_name) )) continue; !strncmp( de->d_name, "..", sizeof( de->d_name) )) continue;
snprintf( src_file, sizeof(src_file), "%s/%s", src, de->d_name); src_file) )){ stderr, "Can't open %s\n", src_file); "open_ibfile" ); ibfile( fn); de->d_name, ".", sizeof( de->d_name) )) continue; de->d_name, "..", sizeof( de->d_name) )) continue; file_count] [255]; de->d_name, ".", sizeof( de->d_name) )) continue; de->d_name, "..", sizeof( de->d_name) )) continue; result[ indexres+ +], src_file) ; src_dir) ; i<file_ count;i+ +){ j<file_ count;j+ +) result[ j-1],result[ j])>0); result[ j-1],result[ j])>0) t,result[ j-1]); result[ j-1],result[ j]); result[ j],t); {fprintf( stderr, "Processing, \nTotal pages to process %d %s",file_count, ":");} file_count) { {fprintf( stderr, "%s", ".");} result[ indexres] ))){ "open_ibfile" ); {fprintf( stderr, "%s\n", "END Processing\n");} ibfile( fn); definitions[ 0]); KEY_CHECKS= 0;\n");
char src_file[256];
struct dirent *de;
src_dir = opendir(src);
+ int file_count = 0;
+
+
+/*
while(NULL != (de = readdir(src_dir))){
if(
if(
if(debug) { fprintf(stderr, "Processing %s\n", src_file); }
+ fprintf(stderr, "Processing %s\n", src_file);
if(0 == (fn = open_ibfile(
fprintf(
perror(
@@ -740,7 +746,82 @@
process_
close(fn);
}
+*/
+/*The pages are NOT read from the readdir function in sorted order
+ * To have them sorted we have to process them first
+ *
+ * Below we first identify the number of files to parse
+ *
+ * then we create an array with all the names and we sort it
+ *
+ * Then we process it.
+ *
+ * Process can be optimize, but at least is not presenting the pages in sparse order in the result file.
+ *
+ * Use debug option to enable the progress view
+ */
+
+/*
+ * Start Patch \/
+ */
+ while(NULL != (de = readdir(src_dir))){
+ if(!strncmp(
+ if(!strncmp(
+ file_count++;
+
+ }
+
+ char result[
+ int indexres = 0;
+
+ src_dir = opendir(src);
+ while(NULL != (de = readdir(src_dir))){
+ if(!strncmp(
+ if(!strncmp(
+ snprintf(src_file, sizeof(src_file), "%s/%s", src, de->d_name);
+
+ strcpy(
+ if(debug){ fprintf(stderr, "Processing %s\n", src_file); }
+ }
+
closedir(
+
+ int i,j;
+ char t[file_count];
+
+ for(i=1;
+ for(j=1;
+ {
+ //fprintf(stderr, "value %d\n", strcmp(
+ if(strcmp(
+ {
+ strcpy(
+ strcpy(
+ strcpy(
+ }
+ }
+ }
+
+
+ indexres = 0;
+ if(debug)
+ while(indexres<
+ if(debug)
+ if(0 == (fn = open_ibfile(
+ fprintf(stderr, "Can't open %s\n", result[indexres]);
+ perror(
+ exit(-1);
+ }
+ process_ibfile(fn);
+ indexres++;
+ close(fn);
+ }
+ if(debug)
+/*
+ * END Patch /\
+ */
+
+
}
else{
if(0 == (fn = open_ibfile(src))){
@@ -751,6 +832,7 @@
process_
close(fn);
}
+
table_def_t *table = &(table_
fprintf(stderr, "SET FOREIGN_
fprintf(stderr, "LOAD DATA INFILE '");