Changeset 17712 for trunk/ippTools/src/difftool.c
- Timestamp:
- May 16, 2008, 9:51:26 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/difftool.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/difftool.c
r17611 r17712 40 40 static bool revertdiffskyfileMode(pxConfig *config); 41 41 static bool definepoprunMode(pxConfig *config); 42 static bool queueMode(pxConfig *config); 42 43 43 44 static bool setdiffRunState(pxConfig *config, const char *diff_id, const char *state); … … 70 71 MODECASE(DIFFTOOL_MODE_REVERTDIFFSKYFILE, revertdiffskyfileMode); 71 72 MODECASE(DIFFTOOL_MODE_DEFINEPOPRUN, definepoprunMode); 73 MODECASE(DIFFTOOL_MODE_QUEUE, queueMode); 72 74 default: 73 75 psAbort("invalid option (this should not happen)"); … … 460 462 461 463 if (!diffSkyfileInsert(config->dbh, 462 (psS64)atoll(diff_id),463 uri,464 path_base,465 bg,466 bg_stdev,467 dtime_diff,468 hostname,469 good_frac,470 code471 )) {464 (psS64)atoll(diff_id), 465 uri, 466 path_base, 467 bg, 468 bg_stdev, 469 dtime_diff, 470 hostname, 471 good_frac, 472 code 473 )) { 472 474 if (!psDBRollback(config->dbh)) { 473 475 psError(PS_ERR_UNKNOWN, false, "database error"); … … 628 630 } 629 631 630 631 static bool definepoprunMode(pxConfig *config) 632 { 633 PS_ASSERT_PTR_NON_NULL(config, false); 634 635 // required options 636 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 637 PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false); 638 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false); 639 640 // optional 641 PXOPT_LOOKUP_STR(template_stack_id, config->args, "-template_stack_id", false, false); 642 PXOPT_LOOKUP_STR(template_warp_id, config->args, "-template_warp_id", false, false); 643 644 if (template_stack_id && template_warp_id) { 645 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Only one template can be defined."); 646 return false; 647 } 648 if (!template_stack_id && !template_warp_id) { 649 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 650 "No template has been defined (-template_stack_id or -template_warp_id)"); 651 return false; 652 } 653 654 PXOPT_LOOKUP_STR(input_stack_id, config->args, "-input_stack_id", false, false); 655 PXOPT_LOOKUP_STR(input_warp_id, config->args, "-input_warp_id", false, false); 656 if (input_stack_id && input_warp_id) { 657 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Only one input can be defined."); 658 return false; 659 } 660 if (!input_stack_id && !input_warp_id) { 661 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 662 "No input has been defined (-input_stack_id or -input_warp_id)"); 632 // Generate a single populated run 633 static bool populatedrun(const char *workdir, // Working directory 634 const char *skycell_id, // Skycell identifier 635 const char *tess_id, // Tessellation identifier 636 psS64 input_warp_id, // Warp identifier for input image, PS_MAX_S64 for none 637 psS64 input_stack_id, // Stack identifier for input image, PS_MAX_S64 for none 638 psS64 template_warp_id, // Warp identifier for template image, PS_MAX_S64 for none 639 psS64 template_stack_id, // Stack identifier for template image, PS_MAX_S64 for none 640 pxConfig *config // Configuration 641 ) 642 { 643 PS_ASSERT_STRING_NON_EMPTY(workdir, false); 644 PS_ASSERT_STRING_NON_EMPTY(skycell_id, false); 645 PS_ASSERT_STRING_NON_EMPTY(tess_id, false); 646 if ((input_warp_id == PS_MAX_S64 && input_stack_id == PS_MAX_S64) || 647 (input_warp_id != PS_MAX_S64 && input_stack_id != PS_MAX_S64)) { 648 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "One, and only one, input must be defined."); 649 return false; 650 } 651 if ((template_warp_id == PS_MAX_S64 && template_stack_id == PS_MAX_S64) || 652 (template_warp_id != PS_MAX_S64 && template_stack_id != PS_MAX_S64)) { 653 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "One, and only one, template must be defined."); 663 654 return false; 664 655 } … … 683 674 } 684 675 685 686 676 if (!psDBTransaction(config->dbh)) { 687 677 psError(PS_ERR_UNKNOWN, false, "database error"); … … 702 692 run->diff_id, 703 693 true, 704 template_stack_id ? (psS64)atoll(template_stack_id) : PS_MAX_S64, // defined or NULL705 template_warp_id ? (psS64)atoll(template_warp_id) : PS_MAX_S64, // defined or NULL694 template_stack_id, 695 template_warp_id, 706 696 skycell_id, 707 697 tess_id, … … 719 709 run->diff_id, 720 710 false, 721 input_stack_id ? (psS64)atoll(input_stack_id) : PS_MAX_S64, // defined or NULL722 input_warp_id ? (psS64)atoll(input_warp_id) : PS_MAX_S64, // defined or NULL711 input_stack_id, 712 input_warp_id, 723 713 skycell_id, 724 714 tess_id, … … 758 748 return true; 759 749 } 750 751 752 static bool definepoprunMode(pxConfig *config) 753 { 754 PS_ASSERT_PTR_NON_NULL(config, false); 755 756 // required options 757 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 758 PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false); 759 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false); 760 761 // optional 762 PXOPT_LOOKUP_STR(template_stack_id, config->args, "-template_stack_id", false, false); 763 PXOPT_LOOKUP_STR(template_warp_id, config->args, "-template_warp_id", false, false); 764 765 if (template_stack_id && template_warp_id) { 766 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Only one template can be defined."); 767 return false; 768 } 769 if (!template_stack_id && !template_warp_id) { 770 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 771 "No template has been defined (-template_stack_id or -template_warp_id)"); 772 return false; 773 } 774 775 PXOPT_LOOKUP_STR(input_stack_id, config->args, "-input_stack_id", false, false); 776 PXOPT_LOOKUP_STR(input_warp_id, config->args, "-input_warp_id", false, false); 777 if (input_stack_id && input_warp_id) { 778 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Only one input can be defined."); 779 return false; 780 } 781 if (!input_stack_id && !input_warp_id) { 782 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 783 "No input has been defined (-input_stack_id or -input_warp_id)"); 784 return false; 785 } 786 787 return populatedrun(workdir, skycell_id, tess_id, 788 input_warp_id ? (psS64)atoll(input_warp_id) : PS_MAX_S64, 789 input_stack_id ? (psS64)atoll(input_stack_id) : PS_MAX_S64, 790 template_warp_id ? (psS64)atoll(template_warp_id) : PS_MAX_S64, 791 template_stack_id ? (psS64)atoll(template_stack_id) : PS_MAX_S64, 792 config); 793 794 return true; 795 } 796 797 798 static bool queueMode(pxConfig *config) 799 { 800 PS_ASSERT_PTR_NON_NULL(config, false); 801 802 // required options 803 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 804 805 // default 806 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 807 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); 808 809 // find all things to queue 810 psString query = pxDataGet("difftool_queue.sql"); 811 if (!query) { 812 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 813 return false; 814 } 815 816 if (config->where) { 817 psString whereClause = psDBGenerateWhereSQL(config->where, NULL); 818 psStringAppend(&query, " %s", whereClause); 819 psFree(whereClause); 820 } 821 822 if (!p_psDBRunQuery(config->dbh, query)) { 823 psError(PS_ERR_UNKNOWN, false, "database error"); 824 psFree(query); 825 return false; 826 } 827 psFree(query); 828 829 psArray *output = p_psDBFetchResult(config->dbh); 830 if (!output) { 831 psErrorCode err = psErrorCodeLast(); 832 switch (err) { 833 case PS_ERR_DB_CLIENT: 834 psError(PXTOOLS_ERR_SYS, false, "database error"); 835 case PS_ERR_DB_SERVER: 836 psError(PXTOOLS_ERR_PROG, false, "database error"); 837 default: 838 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 839 } 840 841 return false; 842 } 843 if (!psArrayLength(output)) { 844 psTrace("difftool", PS_LOG_INFO, "no rows found"); 845 psFree(output); 846 return true; 847 } 848 849 long numGood = 0; // Number of good rows added 850 for (long i = 0; i < output->n; i++) { 851 psMetadata *row = output->data[i]; // Output row from query 852 853 // Selected parameters 854 bool mdok; // Status of MD lookup 855 const char *skycell_id = psMetadataLookupStr(&mdok, row, "skycell_id"); 856 if (!mdok || !skycell_id) { 857 psWarning("skycell_id not found --- ignoring row %ld", i); 858 continue; 859 } 860 const char *tess_id = psMetadataLookupStr(&mdok, row, "tess_id"); 861 if (!mdok || !tess_id) { 862 psWarning("tess_id not found --- ignoring row %ld", i); 863 continue; 864 } 865 psS64 stack_id = psMetadataLookupS64(&mdok, row, "stack_id"); 866 if (!mdok) { 867 psWarning("stack_id not found --- ignoring row %ld", i); 868 continue; 869 } 870 psS64 warp_id = psMetadataLookupS64(&mdok, row, "warp_id"); 871 if (!mdok) { 872 psWarning("warp_id not found --- ignoring row %ld", i); 873 continue; 874 } 875 876 if (!populatedrun(workdir, skycell_id, tess_id, warp_id, PS_MAX_S64, PS_MAX_S64, stack_id, config)) { 877 psWarning("Unable to add run for %s,%s,%" PRId64 ",%" PRId64, skycell_id, tess_id, 878 warp_id, stack_id); 879 psErrorClear(); 880 continue; 881 } 882 883 numGood++; 884 } 885 886 psLogMsg("difftool", PS_LOG_INFO, "%ld runs added.", numGood); 887 888 psFree(output); 889 890 return true; 891 }
Note:
See TracChangeset
for help on using the changeset viewer.
