00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 char *module_name = "CookbookRecipe:04";
00016 char *version_id = "1.0";
00017
00018 #include <jsoc_main.h>
00019 #include <regex.h>
00020
00021 ModuleArgs_t module_args[] = {
00022 {ARG_STRING, "ds", "", "name of data series"},
00023 {ARG_END}
00024 };
00025
00026 int DoIt (void) {
00027 CmdParams_t *params = &cmdparams;
00028 DB_Text_Result_t *qres;
00029 DRMS_Record_t *record;
00030 regmatch_t pmatch[10];
00031 int series, seriesct;
00032 int status = 0;
00033 char query[DRMS_MAXQUERYLEN];
00034
00035 char *ds = strdup (params_get_str (params, "ds"));
00036
00037 record = drms_template_record (drms_env, ds, &status);
00038 if (record && !status) {
00039 if (record->seriesinfo->pidx_num) {
00040 char qry[1024];
00041 sprintf (query, "select %s from %s group by %s",
00042 (record->seriesinfo->pidx_keywords[0])->info->name, ds,
00043 (record->seriesinfo->pidx_keywords[0])->info->name);
00044 for (int i=1; i<record->seriesinfo->pidx_num; i++) {
00045 sprintf (qry, ", %s",
00046 (record->seriesinfo->pidx_keywords[i])->info->name);
00047 strcat (query, qry);
00048 }
00049 if ((qres = drms_query_txt (drms_env->session, query))) {
00050 printf ("%s contains %d unique records", ds, qres->num_rows);
00051 db_free_text_result (qres);
00052 }
00053 } else printf ("%s: no records found", ds);
00054 printf (", with %d data segment(s) per record\n", record->segments.num_total);
00055 drms_free_record (record);
00056 } else printf ("%s: no such series\n", ds);
00057
00058 return status;
00059 }
00060
00061
00062
00063
00064
00065