Project

General

Profile

« Previous | Next » 

Revision 2424

Added by sgarg almost 20 years ago

Added code such that an offset can be specified in metacat.properties for entering records into xml_queryresult table. The value of xml_returnfield.usage_count should be more than the value specified in metacat.properties for records to be entered into xml_queryresult. so if you want results for any combination of returnfields should be stored in xml_queryresult only after that combination has been requested 50 times, set this value to 50

View differences:

lib/metacat.properties
142 142
# the limit is 4000 for oracle
143 143
queryresult_string_length=4000
144 144

  
145
# the value of xml_returnfield.usage_count should be more than this value
146
# for records to be entered into xml_queryresult. so if you want results for
147
# any combination of returnfields to be stored in xml_queryresult only when
148
# that combination has been requested 50 times, set this value to 50
149
xml_returnfield_count=0
150

  
145 151
# Harvester properties
146 152
connectToMetacat=true
147 153

  
src/edu/ucsb/nceas/metacat/DBQuery.java
39 39
import java.io.IOException;
40 40
import java.io.InputStream;
41 41
import java.io.PrintWriter;
42
import java.io.Reader;
43 42
import java.io.StringReader;
44 43
import java.io.StringWriter;
45 44
import java.sql.PreparedStatement;
......
616 615
                                       throws Exception
617 616
   {
618 617

  
619
     // get the return field and check if there is a record in xml_returnfield
620
     int returnfield_id = getXmlReturnfieldsTableId(qspec, dbconn);
618
     // check if there is a record in xml_returnfield
619
     // and get the returnfield_id and usage count
620
     int usage_count = getXmlReturnfieldsTableId(qspec, dbconn);
621
     boolean enterRecords = false;
622

  
623
     // get value of xml_returnfield_count
624
     int count = (new Integer(MetaCatUtil
625
                            .getOption("xml_returnfield_count")))
626
                            .intValue();
627
     if(usage_count > count){
628
         enterRecords = true;
629
     }
630

  
621 631
     if(returnfield_id < 0){
622 632
         MetaCatUtil.debugMessage("Error in getting returnfield id from"
623 633
                                  + "xml_returnfield table", 20);
624 634
     }
625 635

  
636

  
637

  
626 638
     // get the hashtable containing the docids that already in the
627 639
     // xml_queryresult table
628 640
     MetaCatUtil.debugMessage("size of partOfDoclist before"
......
659 671
         key = (String) keys.nextElement();
660 672
         element = (String)partOfDoclist.get(key);
661 673

  
662
         if(element != null && element.length() < offset){
674
         if(enterRecords && element != null && element.length() < offset){
663 675
             query = "INSERT INTO xml_queryresult (returnfield_id, docid, "
664 676
                 + "queryresult_string) VALUES ('" + returnfield_id
665 677
                 + "', '" + key + "', '" + element + "')";
......
771 783
    * Method to get id from xml_returnfield table
772 784
    * for a given query specification
773 785
    */
786
   private int returnfield_id;
774 787
   private int getXmlReturnfieldsTableId(QuerySpecification qspec,
775 788
                                           DBConnection dbconn){
776 789
       int id = -1;
790
       int count = 1;
777 791
       PreparedStatement pstmt = null;
778 792
       ResultSet rs = null;
779 793
       String returnfield = qspec.getSortedReturnFieldString();
......
796 810
           if(tableHasRows){
797 811
               // get the id
798 812
               id = rs.getInt(1);
799
               int count = rs.getInt(2) + 1;
813
               count = rs.getInt(2) + 1;
800 814
               rs.close();
801 815
               pstmt.close();
802 816

  
......
847 861
                                     + e.getMessage(), 20);
848 862
           id = -1;
849 863
       }
850
       return id;
864

  
865
       returnfield_id = id;
866
       return count;
851 867
   }
852 868

  
853 869

  

Also available in: Unified diff