Exemple #1
0
QuillErrCode
HistorySnapshot::printResults(SQLQuery *queryhor, 
							  SQLQuery *queryver, 
							  bool longformat, bool fileformat,
							  bool custForm, 
							AttrListPrintMask *pmask,
							const char *constraint /* = "" */) {
  AttrList *ad = 0;
  QuillErrCode st = QUILL_SUCCESS;

  // initialize index variables
   
  off_t offset = 0, last_line = 0;

  cur_historyads_hor_index = 0;  	
  cur_historyads_ver_index = 0;

  if (!longformat && !custForm) {
	  short_header();
  }

	ExprTree *tree = NULL;

	if (constraint) {
		 ParseClassAdRvalExpr(constraint, tree);
	}

  while(1) {
	  st = getNextAd_Hor(ad, queryhor);

	  if(st != QUILL_SUCCESS) 
		  break;
	  
	  if (longformat || constraint) { 
		  st = getNextAd_Ver(ad, queryver);

		
		  if (constraint && EvalBool(ad, tree) == FALSE) {
			continue;
		  }
		  // in the case of vertical, we dont want to quit if we run
		  // out of tuples because 1) we want to display whats in the ad
		  // and 2) the horizontal cursor will correctly determine when
		  // to stop - this is because in all cases, we only pull out those
          // tuples from vertical which join with a horizontal tuple
		  if(st != QUILL_SUCCESS && st != DONE_HISTORY_VER_CURSOR) 
			  break;
		  if (fileformat) { // Print out the job ads in history file format, i.e., print the *** delimiters
			  MyString owner, ad_str, temp;
			  int compl_date;

			  ad->sPrint(ad_str);
                       if (!ad->LookupString(ATTR_OWNER, owner))
                                 owner = "NULL";
                         if (!ad->LookupInteger(ATTR_COMPLETION_DATE, compl_date))
                                 compl_date = 0;
                         temp.formatstr("*** Offset = %ld ClusterId = %d ProcId = %d Owner = \"%s\" CompletionDate = %d\n",
                                        offset - last_line, curClusterId_hor, curProcId_hor, owner.Value(), compl_date);

                         offset += ad_str.Length() + temp.Length();
                         last_line = temp.Length();
                         fprintf(stdout, "%s", ad_str.Value());
                         fprintf(stdout, "%s", temp.Value());
                 }     else if (longformat) {
                         ad->fPrint(stdout);
                         printf("\n");
                 }

	  } 
	  if (!longformat) {
	  	if (custForm == true) {
			ASSERT(pmask != NULL);
			pmask->display(stdout, ad);
		} else {
			displayJobShort(ad);
		}
	  }
  }

  if(ad != NULL) {
	  delete ad;
	  ad = NULL;
  }

  if(st == FAILURE_QUERY_HISTORYADS_HOR || st == FAILURE_QUERY_HISTORYADS_VER)
	  return st;

  return QUILL_SUCCESS;
}