Project

General

Profile

« Previous | Next » 

Revision 3258

Added by Jing Tao over 17 years ago

Recovered some overwitten code.

View differences:

src/edu/ucsb/nceas/metacat/DBQuery.java
311 311
        //transfer the xml to html
312 312
        try
313 313
        {
314

  
314
         double startHTMLTransform = System.currentTimeMillis()/1000;
315 315
         DBTransform trans = new DBTransform();
316 316
         response.setContentType("text/html");
317 317

  
......
324 324
         trans.transformXMLDocument(xml.toString(), "-//NCEAS//resultset//EN",
325 325
                                 "-//W3C//HTML//EN", qformat, out, params,
326 326
                                 sessionid);
327

  
327
         double endHTMLTransform = System.currentTimeMillis()/1000;
328
                   logMetacat.warn("The time to transfrom resultset from xml to html format is "
329
                  		                             +(endHTMLTransform -startHTMLTransform));
328 330
        }
329 331
        catch(Exception e)
330 332
        {
......
472 474
      int rev = 0;
473 475
      double startTime = 0;
474 476
      int offset = 1;
475
      
477
      double startSelectionTime = System.currentTimeMillis()/1000;
476 478
      ResultSet rs = null;
477 479
        
478 480
      offset = 1;
......
535 537
      rs = pstmt.executeQuery();
536 538

  
537 539
      double queryExecuteTime = System.currentTimeMillis() / 1000;
538
      logMetacat.warn("Time to execute query: "
540
      logMetacat.warn("Time to execute select docid query is "
539 541
                    + (queryExecuteTime - startTime));
540 542

  
541 543
      boolean tableHasRows = rs.next();
......
592 594
            npstmt.execute();
593 595
            ResultSet btrs = npstmt.getResultSet();
594 596
            boolean hasBtRows = btrs.next();
597
            Hashtable list = new Hashtable();
595 598
            while (hasBtRows)
596 599
            {
597 600
               //there was a backtrackable document found
......
626 629
                if (docid_org == null)
627 630
                {
628 631
                   logMetacat.info("Docid_org was null.");
629
                   //continue;
632
                   hasBtRows = btrs.next();
633
                   continue;
630 634
                }
631 635
                docid = docid_org.trim();
636
                if (list.containsKey(docid))
637
                {
638
                        	logMetacat.info("DocumentResultSet already has docid "+docid+" and skip it");
639
                            hasBtRows = btrs.next();
640
                            continue;
641
                 }
632 642
                docname = xmldoc.getDocname();
633 643
                doctype = xmldoc.getDoctype();
634 644
                createDate = xmldoc.getCreateDate();
......
661 671
                docListResult.addResultDocument(
662 672
                  new ResultDocument(docid, (String) document.toString()));
663 673
                currentIndex++;
674
                list.put(docid, docid);
664 675
                logMetacat.warn("$$$$$$$real result: " + docid);
665 676
                count++;
666 677

  
......
739 750
     
740 751
     rs.close();
741 752
     pstmt.close();
753
     double docListTime = System.currentTimeMillis() / 1000;
754
     logMetacat.warn("======Total time to get docid list is: "
755
                          + (docListTime - startSelectionTime ));
742 756
     //if docListResult is not empty, it need to be sent.
743 757
     if (docListResult.size() != 0)
744 758
     {
745 759
       handleSubsetResult(qspec,resultsetBuffer, out, docListResult,
746 760
                              user, groups,dbconn, useXMLIndex);
747 761
     }
748
     double docListTime = System.currentTimeMillis() / 1000;
749
     logMetacat.warn("prepare docid list time: "
750
                    + (docListTime - queryExecuteTime));
751 762

  
752 763
     return resultsetBuffer;
753 764
    }//findReturnDoclist
......
764 775
                                       DBConnection dbconn, boolean useXMLIndex)
765 776
                                       throws Exception
766 777
   {
767
     
778
     double startReturnField = System.currentTimeMillis()/1000;
768 779
     // check if there is a record in xml_returnfield
769 780
     // and get the returnfield_id and usage count
770 781
     int usage_count = getXmlReturnfieldsTableId(qspec, dbconn);
......
792 803
     logMetacat.info("size of partOfDoclist before"
793 804
                             + " docidsInQueryresultTable(): "
794 805
                             + partOfDoclist.size());
806
     double startGetReturnValueFromQueryresultable = System.currentTimeMillis()/1000;
795 807
     Hashtable queryresultDocList = docidsInQueryresultTable(returnfield_id,
796 808
                                                        partOfDoclist, dbconn);
797 809

  
......
800 812
     while (_keys.hasMoreElements()){
801 813
         partOfDoclist.remove((String)_keys.nextElement());
802 814
     }
803

  
815
     double endGetReturnValueFromQueryresultable = System.currentTimeMillis()/1000;
816
     logMetacat.warn("Time to get return fields from xml_queryresult table is (Part1 in return fields) " +
817
          		               (endGetReturnValueFromQueryresultable-startGetReturnValueFromQueryresultable));
804 818
     // backup the keys-elements in partOfDoclist to check later
805 819
     // if the doc entry is indexed yet
806 820
     Hashtable partOfDoclistBackup = new Hashtable();
......
817 831
     //add return fields for the documents in partOfDoclist
818 832
     partOfDoclist = addReturnfield(partOfDoclist, qspec, user, groups,
819 833
                                        dbconn, useXMLIndex);
834
     double endExtendedQuery = System.currentTimeMillis()/1000;
835
     logMetacat.warn("Time to get return fields through execute extended query (Part2 in return fields) "
836
        		                                          + (endExtendedQuery - endGetReturnValueFromQueryresultable));
820 837
     //add relationship part part docid list for the documents in partOfDocList
821 838
     partOfDoclist = addRelationship(partOfDoclist, qspec, dbconn, useXMLIndex);
822 839

  
823

  
840
     double startStoreReturnField = System.currentTimeMillis()/1000;
824 841
     Iterator keys = partOfDoclist.getDocids();
825 842
     String key = null;
826 843
     String element = null;
......
852 869
             pstmt.execute();
853 870
             pstmt.close();
854 871
         }
855

  
872
         double endStoreReturnField = System.currentTimeMillis()/1000;
873
         logMetacat.warn("Time to store new return fields into xml_queryresult table (Part4 in return fields) "
874
                       + (endStoreReturnField -startStoreReturnField));
856 875
         // A string with element
857 876
         String xmlElement = "  <document>" + element + "</document>";
858 877

  
......
879 898
         }
880 899
         resultset.append(xmlElement);
881 900
     }//while
882

  
901
     double returnFieldTime = System.currentTimeMillis() / 1000;
902
     logMetacat.warn("======Total time to get return fields is: "
903
                           + (returnFieldTime - startReturnField));
883 904
     return resultset;
884 905
 }
885 906

  
......
1076 1097
        if (doclist.length() > 0)
1077 1098
        {
1078 1099
          Hashtable controlPairs = new Hashtable();
1079
          double extendedQueryStart = System.currentTimeMillis() / 1000;
1080 1100
          doclist.deleteCharAt(doclist.length() - 1); //remove the last comma
1081 1101
          boolean tableHasRows = false;
1082 1102
          // check if user has permission to see the return field data
......
1096 1116
            tableHasRows = rs.next();
1097 1117
          }*/
1098 1118

  
1099
           double extendedAccessQueryEnd = System.currentTimeMillis() / 1000;
1119
           /*double extendedAccessQueryEnd = System.currentTimeMillis() / 1000;
1100 1120
           logMetacat.info( "Time for execute access extended query: "
1101
                          + (extendedAccessQueryEnd - extendedQueryStart));
1121
                          + (extendedAccessQueryEnd - extendedQueryStart));*/
1102 1122

  
1103 1123
           String extendedQuery =
1104 1124
               qspec.printExtendedSQL(doclist.toString(), useXMLIndex);
1105 1125
           logMetacat.info("Extended query: " + extendedQuery);
1106 1126

  
1107 1127
           if(extendedQuery != null){
1128
        	   double extendedQueryStart = System.currentTimeMillis() / 1000;
1108 1129
               pstmt = dbconn.prepareStatement(extendedQuery);
1109 1130
               //increase dbconnection usage count
1110 1131
               dbconn.increaseUsageCount(1);
1111 1132
               pstmt.execute();
1112 1133
               rs = pstmt.getResultSet();
1113 1134
               double extendedQueryEnd = System.currentTimeMillis() / 1000;
1114
               logMetacat.info(
1115
                   "Time for execute extended query: "
1135
               logMetacat.warn(
1136
                   "Time to execute extended query: "
1116 1137
                   + (extendedQueryEnd - extendedQueryStart));
1117 1138
               tableHasRows = rs.next();
1118 1139
               while (tableHasRows) {
......
1186 1207
               } //while
1187 1208
               double docListResultEnd = System.currentTimeMillis() / 1000;
1188 1209
               logMetacat.warn(
1189
                   "Time for prepare doclistresult after"
1210
                   "Time to prepare ResultDocumentSet after"
1190 1211
                   + " execute extended query: "
1191 1212
                   + (docListResultEnd - extendedQueryEnd));
1192 1213
           }
1193 1214

  
1194 1215
           // get attribures return
1216
           double startGetAttribute = System.currentTimeMillis()/1000;
1195 1217
           docListResult = getAttributeValueForReturn(qspec,
1196 1218
                           docListResult, doclist.toString(), useXMLIndex);
1219
           double endGetAttribute = System.currentTimeMillis()/1000;
1220
           logMetacat.warn(
1221
                   "Time to get attribute return value after"
1222
                   + " execute extended query: "
1223
                   + (endGetAttribute - startGetAttribute));
1224
           
1197 1225
       }//if doclist lenght is great than zero
1198 1226

  
1199 1227
     }//if has extended query
......
1265 1293
      pstmt.close();
1266 1294
    }//while
1267 1295
    double endRelation = System.currentTimeMillis() / 1000;
1268
    logMetacat.info("Time for adding relation to docListResult: "
1296
    logMetacat.info("Time to add relationship to return fields (part 3 in return fields): "
1269 1297
                             + (endRelation - startRelation));
1270 1298

  
1271 1299
    return docListResult;

Also available in: Unified diff