00001 #include "jsoc_main.h"
00002 #include "drms.h"
00003 #include "atoinc.h"
00004
00005
00006
00007
00008
00009
00010
00227 #define NOT_SPECIFIED "NOT_SPECIFIED"
00228
00229 #define DATA_OK ('\0')
00230 #define DATA_MISS ('\1')
00231 #define DATA_UNK ('\2')
00232 #define DATA_GONE ('\3')
00233
00234
00235 char primestr[100];
00236
00237 char *primevalstr(TIME prime, DRMS_Type_t type, char *unit, char *format)
00238 {
00239 if (type==DRMS_TYPE_TIME)
00240 sprint_time(primestr, prime, unit, atoi(format));
00241 else
00242 sprintf(primestr, (type <= DRMS_TYPE_LONGLONG ? "%.0f" : "%f"), prime);
00243 return(primestr);
00244 }
00245
00246 void printprime(FILE *fp, TIME prime, DRMS_Type_t type, char *unit, char *format)
00247 {
00248 fprintf(fp, primevalstr(prime, type, unit, format));
00249 }
00250
00251 ModuleArgs_t module_args[] =
00252 {
00253 {ARG_STRING, "ds", NOT_SPECIFIED, "Input data series."},
00254
00255 {ARG_STRING, "block", NOT_SPECIFIED, "interval for block summaries of the coverage."},
00256 {ARG_STRING, "low", NOT_SPECIFIED, "Low limit for coverage map."},
00257 {ARG_STRING, "high", NOT_SPECIFIED, "High limit for coverage map."},
00258 {ARG_STRING, "key", NOT_SPECIFIED, "Prime key name to use, default is first prime"},
00259 {ARG_STRING, "other", NOT_SPECIFIED, "additional clauses for queries"},
00260 {ARG_INT, "mask", "0", "Mask to use for bits in QUALITY that will cause the record to be counted as MISS"},
00261 {ARG_INT, "ignore", "0", "Mask to use for bits to ignore in QUALITY tests with mask that will cause the record to be counted as MISS"},
00262 {ARG_INT, "chunk", "10000", "Number of records to request per get_vector query"},
00263 {ARG_FLAG, "o", "0", "Verify - verify that SU is available for records with data"},
00264 {ARG_FLAG, "m", "0", "no_miss -treat otherwise MISS records as UNK"},
00265 {ARG_FLAG, "g", "0", "no_gone -treat otherwise GONE records as UNK and treat otherwise UNK as MISS"},
00266 {ARG_FLAG, "s", "0", "Summary - Print the total number of records in each category: OK, MISS, UNK, GONE"},
00267 {ARG_FLAG, "t", "0", "times - Print the first and last time of each segment of OK, MISS, UNK, GONE"},
00268 {ARG_FLAG, "i", "0", "Index - Print index values instead of prime slot values"},
00269 {ARG_FLAG, "q", "0", "Quiet - omit series header info"},
00270 {ARG_FLAG, "v", "0", "Verbose - Print processing status"},
00271 {ARG_FLAG, "h", "0", "Help - Print usage and exit"},
00272 {ARG_END}
00273 };
00274
00275 #define DIE(msg) {fprintf(stderr,"%s\n",msg);exit(1);}
00276
00277 char *module_name = "show_coverage";
00278
00279 int nice_intro ()
00280 {
00281 int usage = cmdparams_get_int (&cmdparams, "h", NULL);
00282 if (usage)
00283 {
00284 printf ("Usage:\nshow_coverage [-hiqv] "
00285 "ds=<seriesname> {key=<pkey>} {low=<starttime>} <high=<stoptime>}\n"
00286 " {key=<prime-key>} {block=<blocklength>} {<other>=<pkeylist>}.\n"
00287 " -h: help - show this message then exit\n"
00288 " -i: list index values vs slot values\n"
00289 " -q: quiet, do not print header\n"
00290 " -g: no_gone -treat otherwise GONE records as UNK and otherwise UNK records as MISS\n"
00291 " -m: no_miss -treat otherwise MISS records as UNK\n"
00292 " -s: Summary - Print the total number of records in each category: OK, MISS, UNK, GONE\n"
00293 " -t: Summary - Print first and last time of each segment of OK, MISS, UNK, GONE\n"
00294 " -o: online - check with SUMS for expired data\n"
00295 " -v: verbose - Print processing status\n"
00296 "ds=<seriesname> - required\n"
00297 "key=<prime_key> - prime key to use if not the first available\n"
00298 "block=<blocklength> - interval span for summary data\n"
00299 "mask=<bad_bit_mask> - mask to be checked in QUALITY\n"
00300 "ignore=<ignore_bit_mask> - mask for bits to be ignored in QUALITY tests\n"
00301 "low=<starttime> - start of range for completeness survey, defaults to [^]\n"
00302 "high=<stoptime> - end of range for completeness summary, defaults to [$]\n"
00303 "<other>=<value> - optional additional filters to limit the survey\n"
00304 );
00305 return(1);
00306 }
00307 return (0);
00308 }
00309
00310
00311 int DoIt(void)
00312 {
00313 FILE *out;
00314 int status = 0;
00315 int slotted, blocked;
00316 long long lowslot, highslot, serieslowslot, serieshighslot;
00317 DRMS_RecordSet_t *rs;
00318 DRMS_Record_t *rec, *template;
00319 DRMS_Keyword_t *skey, *pkey;
00320 DRMS_Type_t ptype;
00321 char name[DRMS_MAXNAMELEN];
00322 int npkeys;
00323 char *pname;
00324 char *piname;
00325 char *punit;
00326 char *pformat;
00327 char *seriesname;
00328 TIME step, epoch, blocking;
00329 TIME series_low, series_high, low, high;
00330 char in[DRMS_MAXQUERYLEN];
00331 char *inbracket;
00332 const char *ds = cmdparams_get_str (&cmdparams, "ds", NULL);
00333 const char *report = cmdparams_get_str (&cmdparams, "coverage", NULL);
00334 const char *blockstr = cmdparams_get_str (&cmdparams, "block", NULL);
00335 const char *lowstr = cmdparams_get_str (&cmdparams, "low", NULL);
00336 const char *highstr = cmdparams_get_str (&cmdparams, "high", NULL);
00337 const char *skeyname = cmdparams_get_str (&cmdparams, "key", NULL);
00338 char *other = strdup((char *)cmdparams_get_str (&cmdparams, "other", NULL));
00339 int verify = cmdparams_get_int (&cmdparams, "o", NULL) != 0;
00340 int quiet = cmdparams_get_int (&cmdparams, "q", NULL) != 0;
00341 int verbose = cmdparams_get_int (&cmdparams, "v", NULL) != 0;
00342 int want_summary = cmdparams_get_int (&cmdparams, "s", NULL) != 0;
00343 int want_times = cmdparams_get_int (&cmdparams, "t", NULL) != 0;
00344 int no_miss = cmdparams_get_int (&cmdparams, "m", NULL) != 0;
00345 int no_gone = cmdparams_get_int (&cmdparams, "g", NULL) != 0;
00346 int useindex = cmdparams_get_int (&cmdparams, "i", NULL) != 0;
00347 long long chunksize = cmdparams_get_int (&cmdparams, "chunk", NULL);
00348 uint32_t mask = (uint32_t)cmdparams_get_int64 (&cmdparams, "mask", NULL);
00349 uint32_t ignore = (uint32_t)cmdparams_get_int64 (&cmdparams, "ignore", NULL);
00350 char *map;
00351 long long islot, jslot, nslots, blockstep;
00352 int total_ok=0, total_miss=0, total_unk=0, total_gone=0;
00353 char *qualkey;
00354 int qualkind;
00355 int ikey;
00356
00357 if (nice_intro()) return(0);
00358
00359
00360
00361 if (strcmp(ds, NOT_SPECIFIED) == 0 )
00362 {
00363
00364 if (cmdparams_numargs(&cmdparams) < 1 || !(ds=cmdparams_getarg (&cmdparams, 1)))
00365 DIE("### show_coverage: ds=<seriesname> parameter is required, must quit");
00366 }
00367
00368
00369 out = stdout;
00370
00371
00372 if (strcmp(other, NOT_SPECIFIED) == 0)
00373 other[0] = '\0';
00374
00375
00376
00377 strcpy(in,ds);
00378 inbracket = index(in, '[');
00379 if (inbracket)
00380 *inbracket = '\0';
00381 else
00382 inbracket = in + strlen(in);
00383 template = drms_template_record (drms_env, in, &status);
00384 if (!template || status)
00385 DIE("Series not found or empty");
00386
00387 npkeys = template->seriesinfo->pidx_num;
00388 if (npkeys < 1)
00389 DIE("Series has no prime keys");
00390 if (strcmp(skeyname, NOT_SPECIFIED) != 0)
00391 {
00392 for (ikey=0; ikey < npkeys; ikey++)
00393 {
00394 pkey = template->seriesinfo->pidx_keywords[ikey];
00395 if (pkey->info->recscope > 1)
00396 {
00397 skey = drms_keyword_slotfromindex(pkey);
00398 if (strcasecmp(skeyname, skey->info->name) == 0)
00399 break;
00400 }
00401 else
00402 if (strcasecmp(skeyname, pkey->info->name) == 0)
00403 {
00404 skey = pkey;
00405 break;
00406 }
00407 }
00408 if (ikey == npkeys)
00409 DIE("name in key command line arg is not a prime key of this series");
00410 }
00411 else
00412 {
00413 skey = pkey = template->seriesinfo->pidx_keywords[0];
00414 }
00415 if (pkey->info->recscope > 1)
00416 {
00417 skey = drms_keyword_slotfromindex(pkey);
00418 slotted = 1;
00419 }
00420 else
00421 slotted = 0;
00422
00423 ptype = skey->info->type;
00424 pname = strdup(skey->info->name);
00425 punit = strdup(skey->info->unit);
00426 pformat = strdup(skey->info->format);
00427 piname = strdup(pkey->info->name);
00428 seriesname = strdup(template->seriesinfo->seriesname);
00429
00430
00431 if (drms_keyword_lookup(template, "QUALITY", 1))
00432 {
00433 qualkey = "QUALITY";
00434 qualkind = 1;
00435 if (mask != 0)
00436 {
00437 qualkind = 3;
00438 }
00439 }
00440 else if (drms_keyword_lookup(template, "DATAVALS", 1))
00441 {
00442 qualkey = "DATAVALS";
00443 qualkind = 2;
00444 }
00445 else
00446 {
00447 qualkey = NULL;
00448 qualkind = 0;
00449 }
00450
00451 if (slotted == 0 && ( ptype != DRMS_TYPE_SHORT && ptype != DRMS_TYPE_INT && ptype != DRMS_TYPE_LONGLONG))
00452 DIE("Must be slotted or integer type first prime key");
00453 if (ptype == DRMS_TYPE_TIME)
00454 {
00455 strcpy(name, pname);
00456 strcat(name, "_epoch");
00457 epoch = drms_getkey_time(template, name, &status);
00458 strcpy(name, pname);
00459 strcat(name, "_step");
00460 step = drms_getkey_double(template, name, &status);
00461 }
00462 else if (slotted)
00463 {
00464 strcpy(name, pname);
00465 strcat(name, "_base");
00466 epoch = (TIME)drms_getkey_double(template, name, &status);
00467 strcpy(name, pname);
00468 strcat(name, "_step");
00469 step = (TIME)drms_getkey_double(template, name, &status);
00470 }
00471 else
00472 {
00473 epoch = (TIME)0.0;
00474 step = (TIME)1.0;
00475 }
00476
00477
00478
00479
00480
00481 if (strncmp(seriesname,"hmi.lev1",8) == 0 && strcasecmp(pname, "fsn") == 0)
00482 {
00483 sprintf(in, "%s[? T_OBS_index>0 ?]", seriesname);
00484 rs = drms_open_nrecords (drms_env, in, 1, &status);
00485 }
00486 else if (strncmp(seriesname, "aia.lev1", 8) == 0 && strcasecmp(pname, "fsn") == 0)
00487 {
00488 sprintf(in, "%s[? T_REC_index>0 ?]", seriesname);
00489 rs = drms_open_nrecords (drms_env, in, 1, &status);
00490 }
00491 else if (slotted)
00492 {
00493 sprintf(in, "%s[? %s_index>0 ?]", seriesname, pname);
00494 rs = drms_open_nrecords (drms_env, in, 1, &status);
00495 }
00496 else
00497 {
00498 sprintf(in, "%s[%s=^]", seriesname, pname);
00499 rs = drms_open_records (drms_env, in, &status);
00500 }
00501 if (status || !rs || rs->n == 0)
00502 DIE("Series is empty");
00503 rec = rs->records[0];
00504 if (ptype == DRMS_TYPE_TIME)
00505 series_low = drms_getkey_time(rec, pname, &status);
00506 else if (slotted)
00507 series_low = (TIME)drms_getkey_double(rec, pname, &status);
00508 else
00509 series_low = (TIME)drms_getkey_longlong(rec, pname, &status);
00510 if (slotted)
00511 serieslowslot = drms_getkey_longlong(rec, piname, &status);
00512 else
00513 serieslowslot = series_low;
00514 drms_close_records(rs, DRMS_FREE_RECORD);
00515
00516 if (strcmp(lowstr, NOT_SPECIFIED) == 0)
00517 low = series_low;
00518 else
00519 {
00520 if (ptype == DRMS_TYPE_TIME)
00521 low = sscan_time((char *)lowstr);
00522 else
00523 {
00524
00525
00526
00527 char *tp, *index();
00528 tp = index(lowstr,'.');
00529 if (index(lowstr, '_') || index(lowstr,':') || (tp && index(tp+1,'.')))
00530 {
00531 int is_sdo = 0;
00532 char fsn_in[DRMS_MAXQUERYLEN];
00533 char fsn_seriesname[DRMS_MAXSERIESNAMELEN];
00534 char *fsn_keyname;
00535 TIME tmplow = sscan_time((char *)lowstr);
00536 if (strncmp(seriesname,"hmi.",4) == 0)
00537 {
00538 sprintf(fsn_in, "hmi.lev1[? T_OBS_index >= %.0f ?]", tmplow);
00539 is_sdo = 1;
00540 }
00541 else if (strncmp(seriesname, "aia.", 4) == 0)
00542 {
00543 sprintf(fsn_in, "aia.lev1[? T_REC_index >= %.0f ?]", tmplow);
00544 is_sdo = 1;
00545 }
00546 else
00547 {
00548 sprintf(fsn_in, "%s[? %s >= %f ?]", seriesname, pname, tmplow);
00549 }
00550 if (slotted || is_sdo)
00551 {
00552 rs = drms_open_nrecords (drms_env, fsn_in, 1, &status);
00553 if (status || !rs || rs->n == 0)
00554 DIE("Series is empty");
00555 rec = rs->records[0];
00556 low = drms_getkey_time(rec, pname, &status);
00557 drms_close_records(rs, DRMS_FREE_RECORD);
00558 }
00559 else
00560 {
00561
00562 DRMS_Type_t tobstype;
00563 drms_getkey(template, "T_OBS", &tobstype, &status);
00564 if (status)
00565 DIE("low given as time, series is not slotted and does not contain T_OBS, giveup.");
00566 drms_getkey(template, "FSN", &tobstype, &status);
00567 if (status)
00568 DIE("low given as time, series is not slotted and does not contain FSN, giveup.");
00569 sprintf(in, "%s[? T_OBS >= %f ?]", fsn_seriesname, low);
00570
00571 rs = drms_open_nrecords (drms_env, in, 1, &status);
00572 if (status || !rs || rs->n == 0)
00573 DIE("Series is empty");
00574 rec = rs->records[0];
00575 low = drms_getkey_time(rec, "FSN", &status);
00576
00577 drms_close_records(rs, DRMS_FREE_RECORD);
00578 }
00579 }
00580 else
00581 low = (TIME)atof(lowstr);
00582 }
00583 }
00584
00585
00586
00587
00588 if ((strncmp(seriesname,"hmi.lev",7) == 0 || strncmp(seriesname, "aia.lev",7) == 0) && strcasecmp(pname, "fsn") == 0)
00589 {
00590 sprintf(in, "%s[? FSN < CAST(x'1c000000' AS int) ?]", seriesname);
00591 rs = drms_open_nrecords (drms_env, in, -1, &status);
00592 }
00593 else
00594 {
00595 sprintf(in, "%s[%s=$]", seriesname, pname);
00596 rs = drms_open_records (drms_env, in, &status);
00597 }
00598 rec = rs->records[0];
00599 if (ptype == DRMS_TYPE_TIME)
00600 series_high = drms_getkey_time(rec, pname, &status);
00601 else if (slotted)
00602 series_high = (TIME)drms_getkey_double(rec, pname, &status);
00603 else
00604 series_high = (TIME)drms_getkey_longlong(rec, pname, &status);
00605 if (slotted)
00606 serieshighslot = drms_getkey_longlong(rec, piname, &status);
00607 else
00608 serieshighslot = series_high;
00609 drms_close_records(rs, DRMS_FREE_RECORD);
00610
00611
00612 if (strcmp(highstr, NOT_SPECIFIED) == 0)
00613 high = series_high;
00614 else
00615 {
00616 if (ptype == DRMS_TYPE_TIME)
00617 high = sscan_time((char *)highstr);
00618 else
00619 {
00620
00621
00622
00623 char *tp, *index();
00624 tp = index(highstr,'.');
00625 if (index(highstr, '_') || index(highstr,':') || (tp && index(tp+1,'.')))
00626 {
00627 int is_sdo = 0;
00628 char fsn_seriesname[DRMS_MAXSERIESNAMELEN];
00629 char *fsn_keyname;
00630 TIME tmphigh = sscan_time((char *)highstr);
00631 if (strncmp(seriesname,"hmi.",4) == 0)
00632 {
00633 strcpy(fsn_seriesname, "hmi.lev1");
00634 fsn_keyname = "T_OBS_index";
00635 is_sdo = 1;
00636 }
00637 else if (strncmp(seriesname, "aia.", 4) == 0)
00638 {
00639 strcpy(fsn_seriesname, "aia.lev1");
00640 fsn_keyname = "T_REC_index";
00641 is_sdo = 1;
00642 }
00643 else
00644 {
00645 strcpy(fsn_seriesname, seriesname);
00646 fsn_keyname = pname;
00647 }
00648 if (slotted || is_sdo)
00649 {
00650 high = sscan_time((char *)highstr);
00651 sprintf(in, "%s[? %s > 0 AND %s <= %.0f ?]", fsn_seriesname, fsn_keyname, fsn_keyname, high);
00652 rs = drms_open_nrecords (drms_env, in, -1, &status);
00653 if (status || !rs || rs->n == 0)
00654 DIE("Series is empty");
00655 rec = rs->records[0];
00656 high = drms_getkey_time(rec, pname, &status);
00657 drms_close_records(rs, DRMS_FREE_RECORD);
00658 }
00659 else
00660 {
00661 high = sscan_time((char *)highstr);
00662 fprintf(stderr,"doing high=timestring case for integer not slotted case\n");
00663 DRMS_Type_t tobstype;
00664 drms_getkey(template, "T_OBS", &tobstype, &status);
00665 if (status)
00666 DIE("high given as time, series is not slotted and does not contain T_OBS, giveup.");
00667 drms_getkey(template, "FSN", &tobstype, &status);
00668 if (status)
00669 DIE("high given as time, series is not slotted and does not contain FSN, giveup.");
00670 sprintf(in, "%s[? T_OBS > 0 AND T_OBS <= %f ?]", fsn_seriesname, high);
00671
00672 fprintf(stderr,"query will be %s\n",in);
00673 rs = drms_open_nrecords (drms_env, in, -1, &status);
00674 if (status || !rs || rs->n == 0)
00675 DIE("Series is empty");
00676 rec = rs->records[0];
00677 high = drms_getkey_time(rec, "FSN", &status);
00678 fprintf(stderr,"got %f\n",high);
00679 drms_close_records(rs, DRMS_FREE_RECORD);
00680 }
00681 }
00682 else
00683 high = (TIME)atof(highstr);
00684 }
00685 }
00686
00687
00688 if (slotted)
00689 {
00690 DRMS_Value_t indexval;
00691 DRMS_Value_t inval;
00692 inval.value.double_val = low;
00693 inval.type = skey->info->type;
00694 drms_keyword_slotval2indexval(skey, &inval, &indexval, NULL);
00695 lowslot = indexval.value.longlong_val;
00696
00697 inval.value.double_val = high;
00698 inval.type = pkey->info->type;
00699 drms_keyword_slotval2indexval(skey, &inval, &indexval, NULL);
00700 highslot = indexval.value.longlong_val;
00701 }
00702 else
00703 {
00704 lowslot = low;
00705 highslot = high;
00706 }
00707 blocked = strcmp(blockstr, NOT_SPECIFIED) != 0;
00708 if (blocked)
00709 {
00710 if (ptype == DRMS_TYPE_TIME)
00711 {
00712 char blocktemp[1024];
00713 strncpy(blocktemp, blockstr, 1020);
00714 if (isdigit(blocktemp[strlen(blocktemp)-1]))
00715 strcat(blocktemp, "s");
00716 blocking = (TIME)atoinc(blocktemp);
00717 }
00718 else
00719 blocking = (TIME)atof(blockstr);
00720 }
00721 else
00722 blocking = 0.0;
00723 blockstep = round(blocking / step);
00724
00725
00726 nslots = highslot - lowslot + 1;
00727 if (nslots <= 0)
00728 {
00729 fprintf(stderr,"Found lowslot=%lld, highslot=%lld\n", lowslot, highslot);
00730 DIE("Error in low or high, found high < low");
00731 }
00732 map = (char *)malloc(sizeof(char) * nslots);
00733 if (!map)
00734 {
00735 fprintf(stderr,"lowslot=%lld, highslot=%lld nslots=%lld\n",lowslot,highslot,nslots);
00736 DIE("malloc failed");
00737 }
00738 for (islot=0; islot<nslots; islot++)
00739 map[islot] = (no_gone ? DATA_MISS : DATA_UNK);
00740 islot = 0;
00741 while (islot < nslots)
00742 {
00743 DRMS_Array_t *data;
00744 int nrecs, irec;
00745 char query[DRMS_MAXQUERYLEN];
00746 char keylist[DRMS_MAXQUERYLEN];
00747 int qualindex=0, verifyindex=0;
00748 char *online = NULL;
00749 jslot = islot + chunksize;
00750 if (jslot >= nslots) jslot = nslots - 1;
00751 sprintf(query, "%s[%s=#%lld-#%lld]%s", seriesname, pname, lowslot+islot, lowslot+jslot, other);
00752 strcpy(keylist, piname);
00753 if (qualkind)
00754 {
00755 strcat(keylist, ",");
00756 strcat(keylist, qualkey);
00757 qualindex = 1;
00758 }
00759 if (verify)
00760 {
00761 strcat(keylist, ",");
00762 strcat(keylist, "sunum");
00763 verifyindex = qualindex + 1;
00764 }
00765 if (verbose)
00766 {
00767 printf("# Starting query %s\n", query);
00768 fflush(stdout);
00769 }
00770 data = drms_record_getvector(drms_env, query, keylist, DRMS_TYPE_LONGLONG, 0, &status);
00771 if (!data || status)
00772 {
00773 fprintf(stderr, "getkey_vector failed status=%d\n", status);
00774 DIE("getkey_vector failure");
00775 }
00776 nrecs = data->axis[1];
00777 if (verify)
00778 {
00779 int irec;
00780 long long *data_sunums = (long long *)data->data + verifyindex*nrecs;
00781 SUM_info_t **infostructs = (SUM_info_t **)malloc(sizeof(SUM_info_t *) * nrecs);
00782 int infostatus;
00783 online = (char *)malloc(sizeof(char) * nrecs);
00784 infostatus = drms_getsuinfo(drms_env, data_sunums, nrecs, infostructs);
00785 if (infostatus)
00786 {
00787 fprintf(stderr,"drms_getsuinfo failed. Status=%d\n", infostatus);
00788 return(infostatus);
00789 }
00790 for (irec=0; irec<nrecs; irec++)
00791 {
00792 SUM_info_t *sinfo = infostructs[irec];
00793 int is_online = (sinfo && sinfo->sunum > 0);
00794 if (is_online) is_online = strcmp(sinfo->online_status,"Y") == 0;
00795 online[irec] = is_online;
00796 free(infostructs[irec]);
00797 }
00798 free(infostructs);
00799 }
00800 for (irec = 0; irec < nrecs; irec++)
00801 {
00802 long long thisslot = *((long long *)data->data + irec);
00803 uint32_t qualval;
00804 long long sunum;
00805 char val = DATA_OK;
00806 total_ok++;
00807 if (qualkind)
00808 {
00809 qualval = (uint32_t)(0xFFFFFFFF & *((long long *)data->data + qualindex*nrecs + irec));
00810 if ((qualkind == 1 && (qualval & 0x80000000) ) ||
00811 (qualkind == 2 && qualval == 0) ||
00812 (qualkind == 3 && (qualval & ignore)==0 && (qualval & mask)!=0 ))
00813 {
00814 total_ok--;
00815 if (no_miss)
00816 val = DATA_UNK;
00817 else
00818 {
00819 val = DATA_MISS;
00820 total_miss++;
00821 }
00822 }
00823 else if (verify && !online[irec])
00824 {
00825 val = (no_gone ? DATA_UNK : DATA_GONE);
00826 total_ok--;
00827 total_gone++;
00828 }
00829 }
00830 else if (verify && !online[irec])
00831 {
00832 val = (no_gone ? DATA_UNK : DATA_GONE);
00833 total_ok--;
00834 total_gone++;
00835 }
00836 map[thisslot - lowslot] = val;
00837 }
00838 islot = jslot + 1;
00839 drms_free_array(data);
00840 if (verify && online)
00841 free(online);
00842 }
00843 total_unk = nslots - total_ok - total_miss - total_gone;
00844
00845
00846
00847 if (!quiet)
00848 {
00849 fprintf(out, "series=%s\n", seriesname);
00850 fprintf(out, "key=%s\n", pname);
00851 fprintf(out, "type=%s\n", drms_type2str(ptype));
00852 fprintf(out, "slotted=%s\n", (slotted ? "T" : "F"));
00853 fprintf(out, "epoch="); printprime(out, epoch, ptype, punit, pformat); fprintf(out, "\n");
00854 fprintf(out, "step=%f\n", step);
00855 fprintf(out, "low="); printprime(out, low, ptype, punit, pformat); fprintf(out, "\n");
00856 fprintf(out, "high="); printprime(out, high, ptype, punit, pformat); fprintf(out, "\n");
00857 fprintf(out, "block="); fprint_inc(out,blocking); fprintf(out, "\n");
00858 fprintf(out, "series_low="); printprime(out, series_low, ptype, punit, pformat); fprintf(out, "\n");
00859 fprintf(out, "series_high="); printprime(out, series_high, ptype, punit, pformat); fprintf(out, "\n");
00860 fprintf(out, "qualkey=%s\n", qualkey);
00861 if (qualkind == 3) fprintf(out, "mask=%#08x\nignore=%#08x\n", mask, ignore);
00862 if (*other) fprintf(out, "other=%s\n", other);
00863 }
00864 if (want_summary)
00865 {
00866 fprintf(out, "total_ok=%d\n", total_ok);
00867 fprintf(out, "total_miss=%d\n", total_miss);
00868 fprintf(out, "total_unk=%d\n", total_unk);
00869 fprintf(out, "total_gone=%d\n", total_gone);
00870 }
00871
00872
00873 if (blocked)
00874 {
00875 int iblock;
00876 int nblocks = (nslots + blockstep - 1)/blockstep;
00877 if (!quiet) fprintf(out, "%*s n_OK n_MISS n_UNK%s\n",
00878 (ptype == DRMS_TYPE_TIME ? 23 : 15 ),"primeval", (verify ? " n_GONE" : ""));
00879 for (iblock = 0; iblock < nblocks; iblock++)
00880 {
00881 char pval[DRMS_MAXQUERYLEN];
00882 int nOK, nMISS, nUNK, nGONE;
00883 nOK = nMISS = nUNK = nGONE = 0;
00884 if (useindex)
00885 sprintf(pval, "%lld", lowslot + iblock*blockstep);
00886 else
00887 sprintf(pval, "%s",
00888 primevalstr(epoch + (lowslot + iblock*blockstep) * step, ptype, punit, pformat));
00889 for (islot = iblock*blockstep; islot < nslots && islot < (iblock+1)*blockstep; islot++)
00890 {
00891 if (map[islot] == DATA_OK) nOK++;
00892 if (map[islot] == DATA_MISS) nMISS++;
00893 if (map[islot] == DATA_UNK) nUNK++;
00894 if (map[islot] == DATA_GONE) nGONE++;
00895 }
00896 fprintf(out, "%*s %8d %8d %8d",
00897 (ptype == DRMS_TYPE_TIME ? 22 : 15 ), pval, nOK, nMISS, nUNK);
00898 if (verify)
00899 fprintf(out, " %8d\n", nGONE);
00900 else
00901 fprintf(out, "\n");
00902 }
00903 }
00904 else
00905 {
00906 islot = 0;
00907 while (islot < nslots)
00908 {
00909 char pval[DRMS_MAXQUERYLEN];
00910 char endval[DRMS_MAXQUERYLEN];
00911 int nsame = 1;
00912
00913 if (useindex)
00914 sprintf(pval, "%lld", lowslot + islot);
00915 else
00916 sprintf(pval, "%s",
00917 primevalstr(epoch + (lowslot + islot) * step, ptype, punit, pformat));
00918 char thisval = map[islot], nval = 0;
00919
00920 for (islot += 1; islot < nslots && map[islot] == thisval; islot++)
00921 nsame += 1;
00922
00923 if (want_times)
00924 {
00925
00926
00927 if (useindex)
00928 sprintf(endval, "%lld", lowslot + islot - 1);
00929 else
00930 sprintf(endval, "%s",
00931 primevalstr(epoch + (lowslot + islot - 1) * step, ptype, punit, pformat));
00932 fprintf(out, "%4s %s %s %d\n",
00933 (thisval == DATA_OK ? "OK" :
00934 (thisval == DATA_MISS ? "MISS" :
00935 (thisval == DATA_GONE ? "GONE" : "UNK"))),
00936 pval, endval, nsame );
00937 }
00938 else
00939 {
00940
00941 fprintf(out, "%4s %s %d\n",
00942 (thisval == DATA_OK ? "OK" :
00943 (thisval == DATA_MISS ? "MISS" :
00944 (thisval == DATA_GONE ? "GONE" : "UNK"))),
00945 pval, nsame );
00946 }
00947 }
00948 }
00949 return(0);
00950 }
00951
00952