Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #134 from wolfgangmm/develop

Fix for XQuery Update/XUpdate performance issues
  • Loading branch information...
commit 00db4c3d9538337b705f7f30c98ba4a54bf05227 2 parents eecd931 + 6369bf5
@shabanovd shabanovd authored
View
2  conf.xml.tmpl
@@ -912,6 +912,6 @@
containing valid nodes.
-->
- <xupdate allowed-fragmentation="100" enable-consistency-checks="no"/>
+ <xupdate allowed-fragmentation="10000" enable-consistency-checks="no"/>
</exist>
View
1  extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java
@@ -349,6 +349,7 @@ protected void removeNodes() {
LOG.warn("Error while deleting lucene index entries: " + e.getMessage(), e);
} finally {
index.releaseWriter(writer);
+ nodesToRemove = null;
}
}
View
5 extensions/indexes/range/src/org/exist/indexing/range/RangeIndexWorker.java
@@ -255,8 +255,8 @@ public int getMode() {
@Override
public StoredNode getReindexRoot(StoredNode node, NodePath path, boolean includeSelf) {
- if (node.getNodeType() == Node.ATTRIBUTE_NODE)
- return null;
+// if (node.getNodeType() == Node.ATTRIBUTE_NODE)
+// return null;
if (config == null)
return null;
NodePath p = new NodePath(path);
@@ -387,6 +387,7 @@ protected void removeNodes() {
} catch (IOException e) {
LOG.warn("Error while deleting lucene index entries: " + e.getMessage(), e);
} finally {
+ nodesToRemove = null;
index.releaseWriter(writer);
}
}
View
8 extensions/indexes/range/test/src/xquery/suite-updates.xql
@@ -0,0 +1,8 @@
+xquery version "3.0";
+
+import module namespace test="http://exist-db.org/xquery/xqsuite"
+at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";
+
+import module namespace rtt="http://exist-db.org/xquery/range/test/updates" at "file:extensions/indexes/range/test/src/xquery/updates.xql";
+
+test:suite(util:list-functions(xs:anyURI("http://exist-db.org/xquery/range/test/updates")))
View
232 extensions/indexes/range/test/src/xquery/updates.xql
@@ -0,0 +1,232 @@
+xquery version "3.0";
+
+module namespace rt="http://exist-db.org/xquery/range/test/updates";
+
+import module namespace test="http://exist-db.org/xquery/xqsuite" at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";
+
+declare namespace mods="http://www.loc.gov/mods/v3";
+
+declare variable $rt:COLLECTION := "/db/rangetest";
+
+declare variable $rt:COLLECTION_CONFIG :=
+ <collection xmlns="http://exist-db.org/collection-config/1.0">
+ <index xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:vra="http://www.vraweb.org/vracore4.htm" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mods="http://www.loc.gov/mods/v3">
+ <fulltext default="none" attributes="false"/>
+ <lucene>
+ <analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
+
+ <!--MODS-->
+ <text qname="mods:title"/>
+ </lucene>
+ <range>
+ <create qname="mods:name">
+ <field name="name-type" match="@type" type="xs:string"/>
+ <field name="name-part" match="mods:namePart" type="xs:string" case="yes"/>
+ </create>
+ <create qname="mods:mods">
+ <field name="mods-dateIssued" match="mods:originInfo/mods:dateIssued" type="xs:string"/>
+ <field name="mods-id" match="@ID" type="xs:string"/>
+ <field name="mods-authority" match="@authority" type="xs:string"/>
+ <field name="mods-lang" match="@lang" type="xs:string"/>
+ </create>
+ </range>
+ </index>
+ </collection>;
+
+declare variable $rt:DATA :=
+ <mods:modsCollection>
+ <mods:mods ID="books/aw/Knuth86a">
+ <mods:titleInfo>
+ <mods:title>TeX: The Program</mods:title>
+ </mods:titleInfo>
+ <mods:name type="personal">
+ <mods:namePart>Donald E. Knuth</mods:namePart>
+ </mods:name>
+ <mods:originInfo>
+ <mods:dateIssued>1986</mods:dateIssued>
+ <mods:publisher>Addison-Wesley</mods:publisher>
+ </mods:originInfo>
+ <mods:identifier type="isbn">0-201-13437-3</mods:identifier>
+ </mods:mods>
+ <mods:mods ID="books/aw/Lamport86">
+ <mods:titleInfo>
+ <mods:title>LaTeX: User's Guide &amp; Reference Manual</mods:title>
+ </mods:titleInfo>
+ <mods:name type="personal">
+ <mods:namePart>Leslie Lamport</mods:namePart>
+ </mods:name>
+ <mods:originInfo>
+ <mods:dateIssued>1986</mods:dateIssued>
+ <mods:publisher>Addison-Wesley</mods:publisher>
+ </mods:originInfo>
+ <mods:identifier type="isbn">0-201-15790-X</mods:identifier>
+ </mods:mods>
+ </mods:modsCollection>
+;
+
+declare
+ %test:setUp
+function rt:setup() {
+ xmldb:create-collection("/db/system/config/db", "rangetest"),
+ xmldb:store("/db/system/config/db/rangetest", "collection.xconf", $rt:COLLECTION_CONFIG),
+ xmldb:create-collection("/db", "rangetest"),
+ xmldb:store($rt:COLLECTION, "test.xml", $rt:DATA)
+};
+
+(:declare
+ %test:tearDown
+function rt:cleanup() {
+ xmldb:remove($rt:COLLECTION, "test.xml"),
+ xmldb:remove($rt:COLLECTION),
+ xmldb:remove("/db/system/config/db/rangetest")
+};:)
+
+declare
+ %test:assertEquals(1)
+function rt:t00_query() {
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Leslie Lamport")])
+};
+
+declare
+ %test:assertEquals(1, 1)
+function rt:t01_replaceTitle() {
+ update replace
+ collection($rt:COLLECTION)//mods:mods[ft:query(mods:titleInfo/mods:title, "latex")]
+ /mods:titleInfo/mods:title
+ with
+ <mods:title>The best text processor ever</mods:title>,
+ count(collection($rt:COLLECTION)//mods:mods[ft:query(mods:titleInfo/mods:title, "'text processor'")]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Leslie Lamport")])
+};
+
+declare
+ %test:assertEquals(1, 1, 1)
+function rt:t02_insertName() {
+ update insert
+ <mods:name type="personal">
+ <mods:namePart>Hansi Reiher</mods:namePart>
+ </mods:name>
+ into
+ collection($rt:COLLECTION)//mods:mods[ft:query(mods:titleInfo/mods:title, "program")],
+ count(collection($rt:COLLECTION)//mods:mods[ft:query(mods:titleInfo/mods:title, "program")]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Hansi Reiher")]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Donald E. Knuth")])
+};
+
+declare
+ %test:assertEquals(1, 1, 1, 1)
+function rt:t03_insertAfter() {
+ update insert
+ <mods:name type="personal">
+ <mods:namePart>Gerda Schwan</mods:namePart>
+ </mods:name>
+ following
+ collection($rt:COLLECTION)//mods:mods/range:field-eq("name-part", "Donald E. Knuth"),
+ count(collection($rt:COLLECTION)//mods:mods[ft:query(mods:titleInfo/mods:title, "program")]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Hansi Reiher")]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Donald E. Knuth")]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Gerda Schwan")])
+};
+
+declare
+ %test:assertEquals(1, 1, 1, 1, 1)
+function rt:t04_insertBefore() {
+ update insert
+ <mods:name type="personal">
+ <mods:namePart>Susi Spatz</mods:namePart>
+ </mods:name>
+ preceding
+ collection($rt:COLLECTION)//mods:mods/range:field-eq("name-part", "Donald E. Knuth"),
+ count(collection($rt:COLLECTION)//mods:mods[ft:query(mods:titleInfo/mods:title, "program")]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Hansi Reiher")]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Donald E. Knuth")]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Gerda Schwan")]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Susi Spatz")])
+};
+
+declare
+ %test:assertEquals(1, 0, 1)
+function rt:t05_replaceName() {
+ update replace
+ collection($rt:COLLECTION)//mods:mods/range:field-eq("name-part", "Susi Spatz")
+ with
+ <mods:name>
+ <mods:namePart>Manfred Specht</mods:namePart>
+ </mods:name>,
+ count(collection($rt:COLLECTION)//mods:mods[ft:query(mods:titleInfo/mods:title, "program")]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Susi Spatz")]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Manfred Specht")])
+};
+
+declare
+ %test:assertEquals(1, 1, 0)
+function rt:t06_replaceName() {
+ update replace
+ collection($rt:COLLECTION)//mods:mods/mods:name[mods:namePart = "Manfred Specht"]/mods:namePart
+ with
+ <mods:namePart>Doris Drossel</mods:namePart>,
+ count(collection($rt:COLLECTION)//mods:mods[ft:query(mods:titleInfo/mods:title, "program")]),
+ count(collection($rt:COLLECTION)//mods:mods[mods:name[mods:namePart = "Doris Drossel"]]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Manfred Specht")])
+};
+
+declare
+ %test:assertEquals(1, 1, 0)
+function rt:t07_updateName() {
+ update value
+ collection($rt:COLLECTION)//mods:mods/mods:name[mods:namePart = "Doris Drossel"]/mods:namePart
+ with
+ "Adolf Adler",
+ count(collection($rt:COLLECTION)//mods:mods[ft:query(mods:titleInfo/mods:title, "program")]),
+ count(collection($rt:COLLECTION)//mods:mods[mods:name[mods:namePart = "Adolf Adler"]]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Doris Drossel")])
+};
+
+declare
+ %test:assertEquals(1, 1, 1, 0)
+function rt:t08_updateIDAttrib() {
+ update value
+ collection($rt:COLLECTION)//mods:mods[@ID = "books/aw/Lamport86"]/@ID
+ with
+ "CHANGED_ID",
+ count(collection($rt:COLLECTION)//mods:mods[ft:query(mods:titleInfo/mods:title, "'text processor'")]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Leslie Lamport")]),
+ count(collection($rt:COLLECTION)//mods:mods[@ID = "CHANGED_ID"]),
+ count(collection($rt:COLLECTION)//mods:mods[@ID = "books/aw/Lamport86"])
+};
+
+declare
+ %test:assertEquals(1, 1, 1, 0)
+function rt:t09_replaceIDAttrib() {
+ update replace
+ collection($rt:COLLECTION)//mods:mods[@ID = "CHANGED_ID"]/@ID
+ with
+ attribute ID { "CHANGED_2" },
+ count(collection($rt:COLLECTION)//mods:mods[ft:query(mods:titleInfo/mods:title, "'text processor'")]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Leslie Lamport")]),
+ count(collection($rt:COLLECTION)//mods:mods[@ID = "CHANGED_2"]),
+ count(collection($rt:COLLECTION)//mods:mods[@ID = "CHANGED_ID"])
+};
+
+declare
+ %test:assertEquals(1, 1, 1, 0)
+function rt:t10_updateYear() {
+ update replace
+ collection($rt:COLLECTION)//mods:mods[@ID = "CHANGED_2"]/mods:originInfo/mods:dateIssued
+ with
+ <mods:dateIssued>2014</mods:dateIssued>,
+ count(collection($rt:COLLECTION)//mods:mods[ft:query(mods:titleInfo/mods:title, "'text processor'")]),
+ count(collection($rt:COLLECTION)//mods:mods[@ID = "CHANGED_2"][range:field-eq("name-part", "Leslie Lamport")]),
+ count(collection($rt:COLLECTION)//mods:mods[@ID = "CHANGED_2"][mods:originInfo/mods:dateIssued = "2014"]),
+ count(collection($rt:COLLECTION)//mods:mods[@ID = "CHANGED_2"][mods:originInfo/mods:dateIssued = "1986"])
+};
+
+declare
+ %test:assertEquals(1, 1, 0)
+function rt:t11_deleteName() {
+ update delete
+ collection($rt:COLLECTION)//mods:mods/mods:name[mods:namePart = "Donald E. Knuth"],
+ count(collection($rt:COLLECTION)//mods:mods[ft:query(mods:titleInfo/mods:title, "program")]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Hansi Reiher")]),
+ count(collection($rt:COLLECTION)//mods:mods[range:field-eq("name-part", "Donald E. Knuth")])
+};
View
6 src/org/exist/dom/ElementImpl.java
@@ -479,8 +479,6 @@ public void appendChildren(Txn transaction, NodeList nodes, int child) throws DO
broker.getIndexController().setMode(StreamListener.STORE);
if (reindexRoot == null) {
listener = broker.getIndexController().getStreamListener();
- } else {
- broker.getIndexController().reindex(transaction, reindexRoot, StreamListener.STORE);
}
if (children == 0) {
// no children: append a new child
@@ -1228,8 +1226,6 @@ public void insertBefore(Txn transaction, NodeList nodes, Node refChild) throws
broker.getIndexController().setMode(StreamListener.STORE);
if (reindexRoot == null) {
listener = broker.getIndexController().getStreamListener();
- } else {
- broker.getIndexController().reindex(transaction, reindexRoot, StreamListener.STORE);
}
final StoredNode following = (StoredNode) refChild;
final StoredNode previous = (StoredNode) following.getPreviousSibling();
@@ -1280,8 +1276,6 @@ public void insertAfter(Txn transaction, NodeList nodes, Node refChild) throws D
broker.getIndexController().setMode(StreamListener.STORE);
if (reindexRoot == null) {
listener = broker.getIndexController().getStreamListener();
- } else {
- broker.getIndexController().reindex(transaction, reindexRoot, StreamListener.STORE);
}
final StoredNode previous = (StoredNode) refChild;
final StoredNode following = (StoredNode) previous.getNextSibling();
View
15 src/org/exist/xquery/update/Modification.java
@@ -46,12 +46,7 @@
import org.exist.storage.txn.Txn;
import org.exist.util.LockException;
import org.exist.util.hashtable.Int2ObjectHashMap;
-import org.exist.xquery.AbstractExpression;
-import org.exist.xquery.AnalyzeContextInfo;
-import org.exist.xquery.Cardinality;
-import org.exist.xquery.Expression;
-import org.exist.xquery.XPathException;
-import org.exist.xquery.XQueryContext;
+import org.exist.xquery.*;
import org.exist.xquery.value.Item;
import org.exist.xquery.value.NodeValue;
import org.exist.xquery.value.Sequence;
@@ -110,6 +105,14 @@ public void resetState(boolean postOptimization) {
{value.resetState(postOptimization);}
}
+ @Override
+ public void accept(ExpressionVisitor visitor) {
+ select.accept(visitor);
+ if (value != null) {
+ value.accept(visitor);
+ }
+ }
+
/* (non-Javadoc)
* @see org.exist.xquery.Expression#analyze(org.exist.xquery.Expression, int)
*/
Please sign in to comment.
Something went wrong with that request. Please try again.