Changeset 32160 for main/trunk


Ignore:
Timestamp:
03/15/18 01:07:14 (3 years ago)
Author:
Georgiy Litvinov
Message:

Cache last document to speed up multisection documents load.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2LuceneRetrieve.java

    r28966 r32160  
    5959
    6060    private boolean text_available = true;
     61    protected Element lastXMLDocumentElement = null;
     62    protected File lastXMLDocumentFile = null;
     63
    6164
    6265    public GS2LuceneRetrieve()
     
    131134                throw new Exception("Doc XML file " + doc_xml_file.getPath() + " does not exist");
    132135            }
    133             Document doc_xml_doc = this.converter.getDOM(doc_xml_file, "utf-8");
    134             if (doc_xml_doc == null)
    135             {
    136                 throw new Exception("Couldn't parse file " + doc_xml_file.getPath());
     136            Element full_document = null;
     137            if (lastXMLDocumentFile != null && lastXMLDocumentFile.equals(doc_xml_file)) {
     138                full_document = lastXMLDocumentElement;
     139            } else {
     140                Document doc_xml_doc = this.converter.getDOM(doc_xml_file, "utf-8");
     141                if (doc_xml_doc == null)
     142                {
     143                    throw new Exception("Couldn't parse file " + doc_xml_file.getPath());
     144                }
     145                full_document = doc_xml_doc.getDocumentElement();
     146                if (full_document == null)
     147                {
     148                    throw new Exception("Couldn't parse file " + doc_xml_file.getPath());
     149                }
    137150            }
    138             Element full_document = doc_xml_doc.getDocumentElement();
    139             if (full_document == null)
    140             {
    141                 throw new Exception("Couldn't parse file " + doc_xml_file.getPath());
    142             }
     151            lastXMLDocumentElement = full_document;
     152            lastXMLDocumentFile = doc_xml_file;
     153           
    143154            Element current_section = null;
    144155            if (default_level.equals(DOC_LEVEL))
Note: See TracChangeset for help on using the changeset viewer.