Changeset: 3827bca32b8e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3827bca32b8e
Modified Files:
        sql/backends/monet5/miniseed/registrar.c
Branch: DVframework
Log Message:

registrar: Added new register function implementations for the new segments 
mode.


diffs (truncated from 826 to 300 lines):

diff --git a/sql/backends/monet5/miniseed/registrar.c 
b/sql/backends/monet5/miniseed/registrar.c
--- a/sql/backends/monet5/miniseed/registrar.c
+++ b/sql/backends/monet5/miniseed/registrar.c
@@ -48,8 +48,12 @@ lng get_line_num(str filename);
 lng get_file_paths(str repo_path, str** ret_file_paths);
 str mseed_create_temp_container(temp_container* ret_tc);
 str mseed_create_temp_container_with_data_tables(temp_container* ret_tc);
+str mseed_create_temp_container_segments_mode(temp_container* ret_tc);
+str mseed_create_temp_container_with_data_tables_segments_mode(temp_container* 
ret_tc);
 str mseed_register(str file_path, temp_container* ret_tc);
 str mseed_register_and_mount(str file_path, temp_container* ret_tc);
+str mseed_register_segments_mode(str file_path, temp_container* ret_tc);
+str mseed_register_and_mount_segments_mode(str file_path, temp_container* 
ret_tc);
 int concatenate_strs(str* words_to_concat, int num_words_to_concat, str* 
ret_concatenated);
 str prepare_insertion(Client cntxt, temp_container* tc);
 str insert_into_vault(Client cntxt, temp_container* tc);
@@ -60,6 +64,10 @@ void *register_files(void *args);
 pthread_mutex_t create_lock;
 pthread_mutex_t insert_lock;
 
+double  timetol      = -1.0; /* Time tolerance for continuous traces */
+double  sampratetol  = -1.0; /* Sample rate tolerance for continuous traces */
+int verbose = 1;
+
 /*
  * returns number of lines in a file.
  *
@@ -280,37 +288,37 @@ str mseed_create_temp_container_with_dat
        int num_c_cat = 7;
        int num_c_dat = 4;
        int c, t;
-
+       
        str sch_name = "mseed";
-
+       
        str cn_fil[] = {"file_location", "dataquality", "network", "station", 
"location", "channel", "encoding", "byte_order"};
        str cn_cat[] = {"file_location", "seq_no", "record_length", 
"start_time", "frequency", "sample_count", "sample_type"};
        str cn_dat[] = {"file_location", "seq_no", "sample_time", 
"sample_value"};
-
+       
        str cts_fil[] = {"string", "char", "string", "string", "string", 
"string", "tinyint", "boolean"};
        str cts_cat[] = {"string", "int", "int", "timestamp", "double", 
"bigint", "char"};
        str cts_dat[] = {"string", "int", "timestamp", "int"};
-
+       
        sht ct_fil[] = {TYPE_str, TYPE_str, TYPE_str, TYPE_str, TYPE_str, 
TYPE_str, TYPE_bte, TYPE_bit};
        sht ct_cat[] = {TYPE_str, TYPE_int, TYPE_int, TYPE_timestamp, TYPE_dbl, 
TYPE_lng, TYPE_str};
        sht ct_dat[] = {TYPE_str, TYPE_int, TYPE_timestamp, TYPE_int};
-
+       
        str tn[] = {"files", "catalog", "data"};
        int num_c[] = {8, 7, 4};
-
+       
        bat *cb_fil = (bat*)GDKmalloc(num_c_fil*sizeof(bat));
        bat *cb_cat = (bat*)GDKmalloc(num_c_cat*sizeof(bat));
        bat *cb_dat = (bat*)GDKmalloc(num_c_dat*sizeof(bat));
-
+       
        temp_subcontainer *tscs = 
(temp_subcontainer*)GDKmalloc(num_tables*sizeof(temp_subcontainer));
-
+       
        BAT *aBAT;
-
+       
        assert(cb_fil!=NULL);
        assert(cb_cat!=NULL);
        assert(cb_dat!=NULL);
        assert(tscs!=NULL);
-
+       
        /* cb_fil */
        for(c = 0; c < num_c_fil; c++)
        {
@@ -322,7 +330,7 @@ str mseed_create_temp_container_with_dat
                        
throw(MAL,"mseed_create_temp_container",MAL_MALLOC_FAIL);
                BBPkeepref(cb_fil[c] = aBAT->batCacheid);
        }
-
+       
        /* cb_cat */
        for(c = 0; c < num_c_cat; c++)
        {
@@ -334,7 +342,7 @@ str mseed_create_temp_container_with_dat
                        
throw(MAL,"mseed_create_temp_container",MAL_MALLOC_FAIL);
                BBPkeepref(cb_cat[c] = aBAT->batCacheid);
        }
-
+       
        /* cb_dat */
        for(c = 0; c < num_c_dat; c++)
        {
@@ -346,11 +354,11 @@ str mseed_create_temp_container_with_dat
                        
throw(MAL,"mseed_create_temp_container",MAL_MALLOC_FAIL);
                BBPkeepref(cb_dat[c] = aBAT->batCacheid);
        }
-
+       
        (tscs+0)->column_bats = cb_fil;
        (tscs+1)->column_bats = cb_cat;
        (tscs+2)->column_bats = cb_dat;
-
+       
        (tscs+0)->column_names = (str*) GDKmalloc(num_c[0]*sizeof(str));
        (tscs+0)->column_types_strs = (str*) GDKmalloc(num_c[0]*sizeof(str));
        for(c = 0; c < num_c[0]; c++)
@@ -358,7 +366,7 @@ str mseed_create_temp_container_with_dat
                (tscs+0)->column_names[c] = GDKstrdup(cn_fil[c]);
                (tscs+0)->column_types_strs[c] = GDKstrdup(cts_fil[c]);
        }
-
+       
        (tscs+1)->column_names = (str*) GDKmalloc(num_c[1]*sizeof(str));
        (tscs+1)->column_types_strs = (str*) GDKmalloc(num_c[1]*sizeof(str));
        for(c = 0; c < num_c[1]; c++)
@@ -366,7 +374,7 @@ str mseed_create_temp_container_with_dat
                (tscs+1)->column_names[c] = GDKstrdup(cn_cat[c]);
                (tscs+1)->column_types_strs[c] = GDKstrdup(cts_cat[c]);
        }
-
+       
        (tscs+2)->column_names = (str*) GDKmalloc(num_c[2]*sizeof(str));
        (tscs+2)->column_types_strs = (str*) GDKmalloc(num_c[2]*sizeof(str));
        for(c = 0; c < num_c[2]; c++)
@@ -374,10 +382,10 @@ str mseed_create_temp_container_with_dat
                (tscs+2)->column_names[c] = GDKstrdup(cn_dat[c]);
                (tscs+2)->column_types_strs[c] = GDKstrdup(cts_dat[c]);
        }
-
+       
        ret_tc->schema_name = sch_name;
        ret_tc->tables_columns = tscs;
-
+       
        ret_tc->table_names = (str*) GDKmalloc(num_tables*sizeof(str));
        ret_tc->num_columns = (int*) GDKmalloc(num_tables*sizeof(int));
        for(t = 0; t < num_tables; t++)
@@ -385,9 +393,239 @@ str mseed_create_temp_container_with_dat
                ret_tc->table_names[t] = GDKstrdup(tn[t]);
                ret_tc->num_columns[t] = num_c[t];
        }
+       
+       ret_tc->num_tables = num_tables;
+       
+       return MAL_SUCCEED;
+}
 
+/*
+ * fills the temp_container structure with the "mseed" metadata tables' info.
+ *
+ * returns error or MAL_SUCCEED
+ *
+ * TODO: This function is now hardcoding every info. It can be made generic,
+ * because required info is in sql_catalog.
+ */
+str mseed_create_temp_container_segments_mode(temp_container* ret_tc)
+{
+       /* seg: (metadata) segments, fil: (metadata) files. */
+       int num_tables = 2;
+       int num_c_fil = 8;
+       int num_c_seg = 8;
+       int c, t;
+       
+       str sch_name = "mseed";
+       
+       str cn_fil[] = {"file_location", "dataquality", "network", "station", 
"location", "channel", "encoding", "byte_order"};
+       str cn_seg[] = {"file_location", "segment_id", "start_time", 
"end_time", "prev_gap", "frequency", "sample_count", "sample_type"};
+       
+       str cts_fil[] = {"string", "char", "string", "string", "string", 
"string", "tinyint", "boolean"};
+       str cts_seg[] = {"string", "int", "timestamp", "timestamp", "double", 
"double", "bigint", "char"};
+       
+       sht ct_fil[] = {TYPE_str, TYPE_str, TYPE_str, TYPE_str, TYPE_str, 
TYPE_str, TYPE_bte, TYPE_bit};
+       sht ct_seg[] = {TYPE_str, TYPE_int, TYPE_timestamp, TYPE_timestamp, 
TYPE_dbl, TYPE_dbl, TYPE_lng, TYPE_str};
+       
+       str tn[] = {"files", "segments"};
+       int num_c[] = {8, 8};
+       
+       bat *cb_fil = (bat*)GDKmalloc(num_c_fil*sizeof(bat));
+       
+       bat *cb_seg = (bat*)GDKmalloc(num_c_seg*sizeof(bat));
+       
+       temp_subcontainer *tscs = 
(temp_subcontainer*)GDKmalloc(num_tables*sizeof(temp_subcontainer));
+       
+       BAT *aBAT;
+       
+       assert(cb_fil!=NULL);
+       assert(cb_seg!=NULL);
+       assert(tscs!=NULL);
+       
+       /* cb_fil */
+       for(c = 0; c < num_c_fil; c++)
+       {
+               aBAT = BATnew(TYPE_void, ct_fil[c], 0); /* create empty BAT for 
each column. */
+               if ( aBAT == NULL)
+                       
throw(MAL,"mseed_create_temp_container",MAL_MALLOC_FAIL);
+               BATseqbase(aBAT, 0);
+               if ( aBAT == NULL)
+                       
throw(MAL,"mseed_create_temp_container",MAL_MALLOC_FAIL);
+               BBPkeepref(cb_fil[c] = aBAT->batCacheid);
+       }
+       
+       /* cb_seg */
+       for(c = 0; c < num_c_seg; c++)
+       {
+               aBAT = BATnew(TYPE_void, ct_seg[c], 0); /* create empty BAT for 
each column. */
+               if ( aBAT == NULL)
+                       
throw(MAL,"mseed_create_temp_container",MAL_MALLOC_FAIL);
+               BATseqbase(aBAT, 0);
+               if ( aBAT == NULL)
+                       
throw(MAL,"mseed_create_temp_container",MAL_MALLOC_FAIL);
+               BBPkeepref(cb_seg[c] = aBAT->batCacheid);
+       }
+       
+       (tscs+0)->column_bats = cb_fil;
+       
+       (tscs+1)->column_bats = cb_seg;
+       
+       (tscs+0)->column_names = (str*) GDKmalloc(num_c[0]*sizeof(str));
+       (tscs+0)->column_types_strs = (str*) GDKmalloc(num_c[0]*sizeof(str));
+       for(c = 0; c < num_c[0]; c++)
+       {
+               (tscs+0)->column_names[c] = GDKstrdup(cn_fil[c]);
+               (tscs+0)->column_types_strs[c] = GDKstrdup(cts_fil[c]);
+       }
+       
+       (tscs+1)->column_names = (str*) GDKmalloc(num_c[1]*sizeof(str));
+       (tscs+1)->column_types_strs = (str*) GDKmalloc(num_c[1]*sizeof(str));
+       for(c = 0; c < num_c[1]; c++)
+       {
+               (tscs+1)->column_names[c] = GDKstrdup(cn_seg[c]);
+               (tscs+1)->column_types_strs[c] = GDKstrdup(cts_seg[c]);
+       }
+       
+       ret_tc->schema_name = sch_name;
+       ret_tc->tables_columns = tscs;
+       
+       ret_tc->table_names = (str*) GDKmalloc(num_tables*sizeof(str));
+       ret_tc->num_columns = (int*) GDKmalloc(num_tables*sizeof(int));
+       for(t = 0; t < num_tables; t++)
+       {
+               ret_tc->table_names[t] = GDKstrdup(tn[t]);
+               ret_tc->num_columns[t] = num_c[t];
+       }
+       
        ret_tc->num_tables = num_tables;
+       
+       return MAL_SUCCEED;
+}
 
+
+/*
+ * fills the temp_container structure with the "mseed" meta-data and data 
tables' info.
+ *
+ * returns error or MAL_SUCCEED
+ *
+ * TODO: This function is now hardcoding every info. It can be made generic,
+ * because required info is in sql_catalog.
+ */
+str mseed_create_temp_container_with_data_tables_segments_mode(temp_container* 
ret_tc)
+{
+       /* seg: (metadata) segments, fil: (metadata) files. */
+       int num_tables = 3;
+       int num_c_fil = 8;
+       int num_c_seg = 8;
+       int num_c_dat = 4;
+       int c, t;
+       
+       str sch_name = "mseed";
+       
+       str cn_fil[] = {"file_location", "dataquality", "network", "station", 
"location", "channel", "encoding", "byte_order"};
+       str cn_seg[] = {"file_location", "segment_id", "start_time", 
"end_time", "prev_gap", "frequency", "sample_count", "sample_type"};
+       str cn_dat[] = {"file_location", "segment_id", "sample_time", 
"sample_value"};
+       
+       str cts_fil[] = {"string", "char", "string", "string", "string", 
"string", "tinyint", "boolean"};
+       str cts_seg[] = {"string", "int", "timestamp", "timestamp", "double", 
"double", "bigint", "char"};
+       str cts_dat[] = {"string", "int", "timestamp", "int"};
+       
+       sht ct_fil[] = {TYPE_str, TYPE_str, TYPE_str, TYPE_str, TYPE_str, 
TYPE_str, TYPE_bte, TYPE_bit};
+       sht ct_seg[] = {TYPE_str, TYPE_int, TYPE_timestamp, TYPE_timestamp, 
TYPE_dbl, TYPE_dbl, TYPE_lng, TYPE_str};
+       sht ct_dat[] = {TYPE_str, TYPE_int, TYPE_timestamp, TYPE_int};
+       
+       str tn[] = {"files", "segments", "data"};
+       int num_c[] = {8, 8, 4};
+       
+       bat *cb_fil = (bat*)GDKmalloc(num_c_fil*sizeof(bat));
+       bat *cb_seg = (bat*)GDKmalloc(num_c_seg*sizeof(bat));
+       bat *cb_dat = (bat*)GDKmalloc(num_c_dat*sizeof(bat));
+       
+       temp_subcontainer *tscs = 
(temp_subcontainer*)GDKmalloc(num_tables*sizeof(temp_subcontainer));
+       
+       BAT *aBAT;
+       
+       assert(cb_fil!=NULL);
+       assert(cb_seg!=NULL);
+       assert(cb_dat!=NULL);
+       assert(tscs!=NULL);
+       
+       /* cb_fil */
+       for(c = 0; c < num_c_fil; c++)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to