(file) Return to smpl_04.c CVS log (file) (dir) Up to [Development] / JSOC / proj / cookbook

File: [Development] / JSOC / proj / cookbook / smpl_04.c (download)
Revision: 1.2, Thu Nov 3 23:31:34 2011 UTC (11 years, 1 month ago) by rick
Branch: MAIN
CVS Tags: Ver_LATEST, Ver_DRMSLATEST, Ver_9-5, Ver_9-41, Ver_9-4, Ver_9-3, Ver_9-2, Ver_9-1, Ver_9-0, Ver_8-8, Ver_8-7, Ver_8-6, Ver_8-5, Ver_8-4, Ver_8-3, Ver_8-2, Ver_8-12, Ver_8-11, Ver_8-10, Ver_8-1, Ver_8-0, Ver_7-1, Ver_7-0, Ver_6-4, Ver_6-3, Ver_6-2, Ver_6-1, Ver_6-0, NetDRMS_Ver_LATEST, NetDRMS_Ver_9-5, NetDRMS_Ver_9-41, NetDRMS_Ver_9-4, NetDRMS_Ver_9-3, NetDRMS_Ver_9-2, NetDRMS_Ver_9-1, NetDRMS_Ver_9-0, NetDRMS_Ver_8-8, NetDRMS_Ver_8-7, NetDRMS_Ver_8-6, NetDRMS_Ver_8-5, NetDRMS_Ver_8-4, NetDRMS_Ver_8-3, NetDRMS_Ver_8-2, NetDRMS_Ver_8-12, NetDRMS_Ver_8-11, NetDRMS_Ver_8-10, NetDRMS_Ver_8-1, NetDRMS_Ver_8-0, NetDRMS_Ver_7-1, NetDRMS_Ver_7-0, NetDRMS_Ver_6-4, NetDRMS_Ver_6-3, NetDRMS_Ver_6-2, NetDRMS_Ver_6-1, NetDRMS_Ver_6-0, HEAD
Changes since 1.1: +1 -1 lines
strdup return of params_get_str()

 *  smpl_04.c						$DRMS/proj/cookbook/
 *  Prints the number of unique records in the selected data series, and
 *    the defined number of data segments per record for the series
 *  Illustrates features of the DRMS_Record struct, and concept of uniqueness
 *    for DRMS records
 *  Usage:
 *    smpl_04 ds= ...
 *  Revision history is at end of file.

char *module_name = "CookbookRecipe:04";
char *version_id = "1.0";

#include <jsoc_main.h>
#include <regex.h>

ModuleArgs_t module_args[] = {
  {ARG_STRING,	"ds", "", "name of data series"},

int DoIt (void) {
  CmdParams_t *params = &cmdparams;
  DB_Text_Result_t *qres;
  DRMS_Record_t *record;
  regmatch_t pmatch[10];
  int series, seriesct;
  int status = 0;
  char query[DRMS_MAXQUERYLEN];

  char *ds = strdup (params_get_str (params, "ds"));

  record = drms_template_record (drms_env, ds, &status);
  if (record && !status) {
    if (record->seriesinfo->pidx_num) {
      char qry[1024];
      sprintf (query, "select %s from %s group by %s",
	  (record->seriesinfo->pidx_keywords[0])->info->name, ds,
      for (int i=1; i<record->seriesinfo->pidx_num; i++) {
	sprintf (qry, ", %s",
	strcat (query, qry);
      if ((qres = drms_query_txt (drms_env->session, query))) {
	printf ("%s contains %d unique records", ds, qres->num_rows);
	db_free_text_result (qres);
    } else printf ("%s: no records found", ds);
    printf (", with %d data segment(s) per record\n", record->segments.num_total);
    drms_free_record (record);
  } else printf ("%s: no such series\n", ds);

  return status;

 *  Revision History
 *  09.04.20	file created by R Bogart

Karen Tian
Powered by
ViewCVS 0.9.4