Changeset 19771 for trunk/ippTools/src/dettool.c
- Timestamp:
- Sep 27, 2008, 11:49:07 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/dettool.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/dettool.c
r19621 r19771 722 722 723 723 // XXX this mode is not well-tested: probably need to specify iteration here 724 // XXX pass the supplied det_id and iteration as ref_det_id, or get from command line?725 724 PXOPT_LOOKUP_S64(det_id, config->args, "-det_id", true, false); // required 726 725 PXOPT_LOOKUP_STR(det_type, config->args, "-set_det_type", false, false); // optional 726 727 727 PXOPT_LOOKUP_STR(mode, config->args, "-set_mode", false, false); // optional 728 if (!isValidMode(config, mode)) { 729 psError(PS_ERR_UNKNOWN, false, "invalid mode"); 730 return false; 731 } 732 733 // get -ref_det_id and -ref_iter : required for 'verify' mode / disallowed otherwise 734 PXOPT_LOOKUP_S64(ref_det_id, config->args, "-ref_det_id", false, false); 735 PXOPT_LOOKUP_S32(ref_iter, config->args, "-ref_iter", false, false); 736 if (!strncmp(mode, "verify", 7) && ((ref_det_id == 0) || (ref_iter == -1))) { 737 psError(PS_ERR_UNKNOWN, false, "verify mode requires both -ref_det_id and -ref_iter"); 738 return false; 739 } 740 if (strncmp(mode, "verify", 7) && ((ref_det_id != 0) || (ref_iter != -1))) { 741 psError(PS_ERR_UNKNOWN, false, "master mode cannot have -ref_det_id or -ref_iter set"); 742 return false; 743 } 744 745 // the new detRun may have different values for these limits: 728 746 PXOPT_LOOKUP_STR(exp_type, config->args, "-set_exp_type", false, false); 729 747 PXOPT_LOOKUP_STR(filelevel, config->args, "-set_filelevel", false, false); … … 742 760 PXOPT_LOOKUP_TIME(registered, config->args, "-set_registered", false, false); 743 761 PXOPT_LOOKUP_TIME(time_begin, config->args, "-set_time_begin", false, false); 744 PXOPT_LOOKUP_TIME(time_end, config->args, "-set_ end", false, false);745 PXOPT_LOOKUP_TIME(use_begin, config->args, "- use_begin", false, false);746 PXOPT_LOOKUP_TIME(use_end, config->args, "- use_end", false, false);762 PXOPT_LOOKUP_TIME(time_end, config->args, "-set_time_end", false, false); 763 PXOPT_LOOKUP_TIME(use_begin, config->args, "-set_use_begin", false, false); 764 PXOPT_LOOKUP_TIME(use_end, config->args, "-set_use_end", false, false); 747 765 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 748 766 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 749 767 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); // optional 750 768 751 // check mode 752 if (mode && !isValidMode(config, mode)) { 753 psError(PS_ERR_UNKNOWN, false, "invalud mode"); 754 return false; 755 } 769 // reference iteration to use (otherwise last iteration) 770 PXOPT_LOOKUP_S32(iteration, config->args, "-iteration", false, false); // for specifying input exp restrictions 756 771 757 772 // lookup the detRun that we will be basing this one on … … 764 779 } 765 780 if (!detRuns) { 766 psError(PS_ERR_UNKNOWN, false, "database error"); 767 return false; 768 } 781 psError(PS_ERR_UNKNOWN, false, "database error: no matching det_id found"); 782 return false; 783 } 784 769 785 // sanity check the result... we should have only found one det_id 770 786 if (psArrayLength(detRuns) != 1) { 771 787 psAbort("found more then one detRun matching det_id %" PRId64 " (this should not happen)", det_id); 772 return false; // unreachable773 788 } 774 789 775 790 // pull the detRun object out the result array 776 // XXX need to assign or re-assign the ref_det_id and ref_iter values777 791 detRunRow *detRun = psMemIncrRefCounter(detRuns->data[0]); 778 792 … … 780 794 psFree(detRuns); 781 795 782 // set the det_id to 0/NULL so the database can assign it 783 detRun->det_id = 0; 784 785 // reset the iteration to 0 786 detRun->iteration = 0; 796 if (iteration < 0) { 797 iteration = detRun->iteration; 798 } 799 800 detRun->det_id = 0; // set the det_id to 0/NULL so the database can assign it 801 detRun->iteration = 0; // reset the iteration to 0 802 803 detRun->ref_det_id = ref_det_id; // not inherited: may only be set for 'verify' run 804 detRun->ref_iter = ref_iter; // not inherited: may only be set for 'verify' run 787 805 788 806 // reset the state to "run" … … 790 808 detRun->state = psStringCopy("run"); 791 809 792 // walk through the optional values and update the detRun as required 810 // walk through the optional values and update the detRun as required. Otherwise, these 811 // value are inherited from the specified detRun 793 812 if (det_type) { 794 813 psFree(detRun->det_type); … … 898 917 // create a metadata to restrict detInputExp's be in in the specified range 899 918 900 psMetadata *time_filter = psMetadataAlloc(); 901 902 // XXX: possible mem leak: PXOPT_COPY* will free time_filter but NOTHING 903 // that has previously been allocated 904 PXOPT_COPY_TIME(config->args, time_filter, "-set_input_begin", "dateobs", ">="); 905 PXOPT_COPY_TIME(config->args, time_filter, "-set_input_end", "dateobs", "<"); 919 psMetadata *input_filter = psMetadataAlloc(); 920 921 // additional restriction on the detInputExp's to be selected 922 PXOPT_COPY_TIME(config->args, input_filter, "-set_input_begin", "dateobs", ">="); 923 PXOPT_COPY_TIME(config->args, input_filter, "-set_input_end", "dateobs", "<"); 924 925 PXOPT_LOOKUP_BOOL(only_accepted, config->args, "-only_accepted", false); // optional 906 926 907 927 // start a transaction so we don't end up with childlessed det_ids 908 928 if (!psDBTransaction(config->dbh)) { 909 929 psError(PS_ERR_UNKNOWN, false, "database error"); 910 psFree( time_filter);930 psFree(input_filter); 911 931 psFree(detRun); 912 932 return false; … … 919 939 psError(PS_ERR_UNKNOWN, false, "database error"); 920 940 } 921 psFree( time_filter);941 psFree(input_filter); 922 942 psFree(detRun); 923 943 return false; … … 934 954 } 935 955 936 if ( time_filter->list->n) {937 psString whereClause = psDBGenerateWhereConditionSQL( time_filter, "rawExp");956 if (input_filter->list->n) { 957 psString whereClause = psDBGenerateWhereConditionSQL(input_filter, "rawExp"); 938 958 psStringAppend(&query, " AND %s", whereClause); 939 959 psFree(whereClause); 940 960 } 941 psFree(time_filter); 942 943 if (!p_psDBRunQuery(config->dbh, query, (long long) newDet_id, (long long) det_id)) { 961 psFree(input_filter); 962 963 if (only_accepted) { 964 psString whereClause = NULL; 965 psStringAppend(&whereClause, " AND accept = 1"); 966 psStringAppend(&query, " AND %s", whereClause); 967 psFree(whereClause); 968 } 969 970 if (!p_psDBRunQuery(config->dbh, query, (long long) newDet_id, (long long) det_id, iteration)) { 944 971 psError(PS_ERR_UNKNOWN, false, "database error"); 945 972 psFree(query);
Note:
See TracChangeset
for help on using the changeset viewer.
