|
From: <pm_...@us...> - 2012-02-08 15:43:16
|
Revision: 4528
http://mxquery.svn.sourceforge.net/mxquery/?rev=4528&view=rev
Author: pm_fischer
Date: 2012-02-08 15:43:03 +0000 (Wed, 08 Feb 2012)
Log Message:
-----------
One more attempt to fix build problems and push out all projection work
Modified Paths:
--------------
trunk/MXQuery/midp_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java
trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java
trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java
trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java
trunk/MXQuery/src/ch/ethz/mxquery/iterators/DescendantOrSelfIterator.java
trunk/MXQuery/src/ch/ethz/mxquery/iterators/XMLContent.java
trunk/MXQuery/src/ch/ethz/mxquery/query/PreparedStatement.java
trunk/MXQuery/src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java
trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java
trunk/MXQuery_Testing/ProjectionTests/queries/XMark01.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark02.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark03.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark04.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark05.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark06.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark07.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark08.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark09.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark10.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark11.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark12.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark13.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark14.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark15.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark16.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark17.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark18.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark19.xq
trunk/MXQuery_Testing/ProjectionTests/queries/XMark20.xq
Modified: trunk/MXQuery/midp_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java
===================================================================
--- trunk/MXQuery/midp_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery/midp_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-02-08 15:43:03 UTC (rev 4528)
@@ -181,4 +181,11 @@
ht.put("DOC", paths);
return ht;
}
+
+ public void setProjectionInformation(QName varname,
+ ObjectObjectPair paths) throws StaticException {
+ VariableHolder vh = ctx.getVariable(varname);
+ vh.setProjectionPaths(paths);
+ }
+
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery/src/ch/ethz/mxquery/functions/fn/DataValuesIterator.java 2012-02-08 15:43:03 UTC (rev 4528)
@@ -760,7 +760,7 @@
while (returnedPaths.hasMoreElements()) {
Vector curRetPath = (Vector)returnedPaths.nextElement();
Vector res = new Vector();
- res.addAll(curRetPath);
+ Utils.addToVector(curRetPath,res);
res.addElement(AbstractStep.KEEP_SUBTREE);
used.add(res);
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/AttributeIterator.java 2012-02-08 15:43:03 UTC (rev 4528)
@@ -38,7 +38,9 @@
import ch.ethz.mxquery.util.KXmlSerializer;
import ch.ethz.mxquery.util.ObjectObjectPair;
import ch.ethz.mxquery.util.Set;
+import ch.ethz.mxquery.util.Utils;
+
/**
* Event of an Attribute Declaration in XQuery ('@attributename')
*
@@ -184,7 +186,7 @@
while (pathEnum.hasMoreElements()) {
Vector prev = (Vector) pathEnum.nextElement();
Vector res = new Vector();
- res.addAll(prev);
+ Utils.addToVector(prev,res);
res.addElement(new AbstractStep(AXIS_ATTRIBUTE, stepData));
returned.add(res);
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/ChildIterator.java 2012-02-08 15:43:03 UTC (rev 4528)
@@ -42,6 +42,7 @@
import ch.ethz.mxquery.util.LogLevel;
import ch.ethz.mxquery.util.ObjectObjectPair;
import ch.ethz.mxquery.util.Set;
+import ch.ethz.mxquery.util.Utils;
/**
*
@@ -274,7 +275,7 @@
while (pathEnum.hasMoreElements()) {
Vector res = new Vector();
Vector prev = (Vector) pathEnum.nextElement();
- res.addAll(prev);
+ Utils.addToVector(prev,res);
if (stepData.getXQName() != null)
res.addElement(new AbstractStep(AXIS_CHILD, stepData));
else
Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/DescendantOrSelfIterator.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/iterators/DescendantOrSelfIterator.java 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/DescendantOrSelfIterator.java 2012-02-08 15:43:03 UTC (rev 4528)
@@ -45,6 +45,7 @@
import ch.ethz.mxquery.util.KXmlSerializer;
import ch.ethz.mxquery.util.ObjectObjectPair;
import ch.ethz.mxquery.util.Set;
+import ch.ethz.mxquery.util.Utils;
/**
*
@@ -464,7 +465,7 @@
while (pathEnum.hasMoreElements()) {
Vector prev = (Vector) pathEnum.nextElement();
Vector res = new Vector();
- res.addAll(prev);
+ Utils.addToVector(prev,res);
res.addElement(new AbstractStep(descAxis, stepData));
returned.add(res);
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/iterators/XMLContent.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/iterators/XMLContent.java 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery/src/ch/ethz/mxquery/iterators/XMLContent.java 2012-02-08 15:43:03 UTC (rev 4528)
@@ -48,6 +48,7 @@
import ch.ethz.mxquery.util.KXmlSerializer;
import ch.ethz.mxquery.util.ObjectObjectPair;
import ch.ethz.mxquery.util.Set;
+import ch.ethz.mxquery.util.Utils;
import ch.ethz.mxquery.util.URIUtils;
/**
@@ -621,7 +622,7 @@
while (returnedPaths.hasMoreElements()) {
Vector curRetPath = (Vector)returnedPaths.nextElement();
Vector res = new Vector();
- res.addAll(curRetPath);
+ Utils.addToVector(curRetPath,res);
res.addElement(AbstractStep.KEEP_SUBTREE);
used.add(res);
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/query/PreparedStatement.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/query/PreparedStatement.java 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery/src/ch/ethz/mxquery/query/PreparedStatement.java 2012-02-08 15:43:03 UTC (rev 4528)
@@ -25,6 +25,7 @@
import ch.ethz.mxquery.exceptions.StaticException;
import ch.ethz.mxquery.model.XDMIterator;
import ch.ethz.mxquery.util.Hashtable;
+import ch.ethz.mxquery.util.ObjectObjectPair;
import ch.ethz.mxquery.xdmio.StoreSet;
import ch.ethz.mxquery.xdmio.XDMSerializerSettings;
@@ -152,4 +153,13 @@
*/
public Hashtable getProjectionPaths() throws StaticException;
+ /**
+ * Provide projection path information for external variables
+ * @param varname A QName denoting the variable
+ * @param paths returned/used paths of the input of this variable
+ * @throws StaticException thrown if the variable could not be found
+ */
+ public void setProjectionInformation(QName varname, ObjectObjectPair paths) throws StaticException;
+
+
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery/src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-02-08 15:43:03 UTC (rev 4528)
@@ -190,4 +190,11 @@
ht.put("DOC", paths);
return ht;
}
+
+ public void setProjectionInformation(QName varname,
+ ObjectObjectPair paths) throws StaticException {
+ VariableHolder vh = ctx.getVariable(varname);
+ vh.setProjectionPaths(paths);
+ }
+
}
Modified: trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java
===================================================================
--- trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery/src/ch/ethz/mxquery/xdmio/xmlAdapters/NonValidatingStaxAdapterProjection.java 2012-02-08 15:43:03 UTC (rev 4528)
@@ -88,8 +88,6 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
-import sun.dc.pr.PathStroker;
-
import ch.ethz.mxquery.contextConfig.Context;
import ch.ethz.mxquery.datamodel.QName;
import ch.ethz.mxquery.datamodel.XQName;
@@ -104,27 +102,35 @@
import ch.ethz.mxquery.exceptions.MXQueryException;
import ch.ethz.mxquery.exceptions.QueryLocation;
import ch.ethz.mxquery.model.AbstractStep;
+import ch.ethz.mxquery.model.StepInformation;
import ch.ethz.mxquery.model.XDMIterator;
public class NonValidatingStaxAdapterProjection extends XDMImportAdapter {
private XMLStreamReader reader;
- private LinkedList tokensList;
+ private LinkedList tokensList;
private ArrayList projectionPaths;
- private int [] projPathPos;
+ private HashSet [] projPathPos;
+ // at which position is each projected path: advance when open, go back when close
+ // if there were only child steps, each path has only a single position
+ // once we include descendant steps, each path can be at multiple steps:
+ // finding a matching descendant node means that we both advance (to process the following steps)
+ // and stay at this node (to find nested
- private Stack bufferedPathName;
- private Stack bufferedAttributes;
+ private Stack bufferedPathName; // keep track of the "moved" paths seen so far, only output if a descendant is actually kept
+ private Stack bufferedAttributes; // keep attributes of "kept" elements or "kept" attributes themselves.
+ //attributes of "moved" elements do not be kept if they are not "kept" themselves
- private HashSet activePaths;
+ private HashSet activePaths; // keep track of the paths that are currently active
private int [] lastActiveStep;
- private Stack keptNodes; // level?, pointer to bufferPathName
+ private Stack keptNodes; // nodes that were seen as "keep" while other still moved
+ // needed if the moving paths never go to keep/keep_sub
- private int pathProducedLevel = 0;
+ private int pathProducedLevel = 0; // up to which level did we already produce the "moved" paths
int skipKeepLevel = -1;
@@ -177,8 +183,27 @@
}
tok = new CommentToken(createNextTokenId(Type.COMMENT, null), reader.getText(),curNsScope);
break;
- case XMLStreamConstants.END_DOCUMENT:
- tok = new Token(Type.END_DOCUMENT,null,curNsScope);
+ case XMLStreamConstants.END_DOCUMENT: {
+ java.util.Iterator pathIt = activePaths.iterator();
+ while (pathIt.hasNext()) {
+ int pathPos = ((Integer)pathIt.next()).intValue();
+ java.util.Iterator pathPosIt = projPathPos[pathPos].iterator();
+ HashSet newVals = new HashSet();
+ while (pathPosIt.hasNext()) {
+ int curPos = ((Integer)pathPosIt.next()).intValue();
+ AbstractStep as = ((AbstractStep) ((Vector)projectionPaths.get(pathPos)).elementAt(curPos));
+ if (as == AbstractStep.ROOT_STEP) {
+ pathPosIt.remove();
+ newVals.add(new Integer(--curPos));
+ }
+ }
+ projPathPos[pathPos].addAll(newVals);
+ }
+ // Sanity check: all paths are active again
+ if (activePaths.size() != projectionPaths.size())
+ throw new MXQueryException(ErrorCodes.A0007_EC_IO, "Number of active paths does not match overall paths"+activePaths.size()+" "+projectionPaths.size(), loc);
+ tok = new Token(Type.END_DOCUMENT,null,curNsScope);
+ }
break;
case XMLStreamConstants.END_ELEMENT: {
boolean emitTag = false;
@@ -276,9 +301,23 @@
java.util.Iterator pathIt = activePaths.iterator();
while (pathIt.hasNext()) {
int pathPos = ((Integer)pathIt.next()).intValue();
+ java.util.Iterator pathPosIt = projPathPos[pathPos].iterator();
+ HashSet newVals = new HashSet();
+ while (pathPosIt.hasNext()) {
+ int curPos = ((Integer)pathPosIt.next()).intValue();
+ AbstractStep as = ((AbstractStep) ((Vector)projectionPaths.get(pathPos)).elementAt(curPos));
+ if (as.getDirection() == StepInformation.AXIS_CHILD ||
+ (as.getDirection() == StepInformation.AXIS_DESCENDANT && level < curPos)) {
+ // TODO: More precise "drop" from descendant than literal path position
+ pathPosIt.remove();
+ newVals.add(new Integer(--curPos));
+ }
+ }
+ projPathPos[pathPos].addAll(newVals);
+ }
+
- projPathPos[pathPos]--;
- }
+
restoreDroppedPaths();
bufferedPathName.pop();
} break;
@@ -287,36 +326,24 @@
//decide if keep or move directly, when we came from SKIP
//SKIP->KEEP: reached skipKeepLevel, level above matched
// SKIP->MOVE: reached skipKeepLevel, level above did not match
- //javax.xml.namespace.QName name = reader.getName();
- for (int pathPos=0;pathPos<projectionPaths.size();pathPos++) {
- Vector path = (Vector)projectionPaths.get(pathPos);
-
- if (path.size()==level+1) {
- XQName curPathCheck = ((AbstractStep) (path).elementAt(projPathPos[pathPos])).getNodeTest().getXQName();
- if (equalsQNames(curPathCheck, name))
- activePaths.add(new Integer(pathPos));
- }
-
+ for (int pathPos=0;pathPos<projectionPaths.size();pathPos++) {
+ Vector path = (Vector)projectionPaths.get(pathPos);
+
+ if (path.size()==level+1) {
+ java.util.Iterator pathPosIt = projPathPos[pathPos].iterator();
+ while (pathPosIt.hasNext()) {
+ int curPos = ((Integer)pathPosIt.next()).intValue();
+ AbstractStep as = ((AbstractStep) ((Vector)projectionPaths.get(pathPos)).elementAt(curPos));
+ XQName curPathCheck = as.getNodeTest().getXQName();
+ if (equalsQNames(curPathCheck, name))
+ activePaths.add(new Integer(pathPos));
+ }
+ }
+
}
-// Vector path = (Vector)projectionPaths.get(0);
-
-// if (path.size() == projPathPos[0]+1) {// last element in path, and not a "KEEP"
// really keep
emitTag = true;
-// } else {
-// curProjMode = PROJ_MODE_MOVE;
-// if (bufferedPathName.size() > level && bufferedPathName.get(level).equals(name)) {
-// emitTag = true;
-//
-// }
-// bufferedPathName.pop();
-// projPathPos[0]--;
-// }
-// XQName curPathCheck = ((AbstractStep) (path).elementAt(projPathPos[0])).getNodeTest().getXQName();
-// if (!equalsQNames(curPathCheck,name))
-// throw new MXQueryException(ErrorCodes.A0007_EC_IO, "Inconsistency in projecting, expected "+curPathCheck+" saw "+name, loc);
- //projPathPos[0]--;
curProjMode = PROJ_MODE_MOVE;
pathProducedLevel--;
@@ -364,15 +391,26 @@
}
tok = new ProcessingInstrToken(createNextTokenId(Type.PROCESSING_INSTRUCTION, null), reader.getPIData(), reader.getPITarget(),curNsScope);
break;
- case XMLStreamConstants.START_DOCUMENT:
- AbstractStep as = ((AbstractStep) ((Vector)projectionPaths.get(0)).elementAt(projPathPos[0]));
- if (as == AbstractStep.ROOT_STEP) {
- projPathPos[0]++;
- curProjMode = PROJ_MODE_MOVE;
+ case XMLStreamConstants.START_DOCUMENT: {
+
+ java.util.Iterator pathIt = activePaths.iterator();
+ while (pathIt.hasNext()) {
+ int pathPos = ((Integer)pathIt.next()).intValue();
+ java.util.Iterator pathPosIt = projPathPos[pathPos].iterator();
+ HashSet newVals = new HashSet();
+ while (pathPosIt.hasNext()) {
+ int curPos = ((Integer)pathPosIt.next()).intValue();
+ AbstractStep as = ((AbstractStep) ((Vector)projectionPaths.get(pathPos)).elementAt(curPos));
+ if (as == AbstractStep.ROOT_STEP) {
+ pathPosIt.remove();
+ newVals.add(new Integer(++curPos));
+ }
}
-
- tok = new Token(Type.START_DOCUMENT,createNextTokenId(Type.START_DOCUMENT, null),curNsScope);
- break;
+ projPathPos[pathPos].addAll(newVals);
+ }
+ tok = new Token(Type.START_DOCUMENT,createNextTokenId(Type.START_DOCUMENT, null),curNsScope);
+ }
+ break;
case XMLStreamConstants.START_ELEMENT:
level++;
// "shortcut": if we skip, we do not even have to retrieve names etc
@@ -399,54 +437,64 @@
// check if node name fits with currently active paths
switch (curProjMode) {
- case PROJ_MODE_MOVE:
+ case PROJ_MODE_MOVE: {
boolean bufferNode = false;
java.util.Iterator pathIt = activePaths.iterator();
while (pathIt.hasNext()) {
int pathPos = ((Integer)pathIt.next()).intValue();
- as = ((AbstractStep) ((Vector)projectionPaths.get(pathPos)).elementAt(projPathPos[pathPos]));
- // if any path goes to keep, we need to keep everything below
- if (as == AbstractStep.KEEP_SUBTREE) {
- curProjMode = PROJ_MODE_KEEP_SUB;
- skipKeepLevel = level;
- emitTag = true;
- // no need to cover individual paths any more?
- // break?
- } else {
+ java.util.Iterator pathPosIt = projPathPos[pathPos].iterator();
+ while (pathPosIt.hasNext()) {
+ int curPos = ((Integer)pathPosIt.next()).intValue();
+ AbstractStep as = ((AbstractStep) ((Vector)projectionPaths.get(pathPos)).elementAt(curPos));
+
+ // if any path goes to keep, we need to keep everything below
+ if (as == AbstractStep.KEEP_SUBTREE) {
+ curProjMode = PROJ_MODE_KEEP_SUB;
+ skipKeepLevel = level;
+ emitTag = true;
+ } else {
XQName curPathCheck = as.getNodeTest().getXQName();
+ int dir = as.getDirection();
+ // if child, become inactive if we don't match or reach keep
+ // if descendant, stay moving even if there is no match or we find keep
if (equalsQNames(curPathCheck,name)) {
// possibly relevant path, so buffer the path
bufferNode = true;
- // check name: if true, then either keep or move
+ // check name: if true, then either keep or move
Vector path = ((Vector)projectionPaths.get(pathPos));
- if (path.size() <= projPathPos[pathPos]+1) {
+ if (path.size() <= curPos+1) {
//curProjMode = PROJ_MODE_KEEP;
// mark that we may have to keep this node
keepNode = true;
- lastActiveStep[pathPos] = level;
- activePaths.remove(new Integer(pathPos));
+ if (dir == StepInformation.AXIS_CHILD) {
+ lastActiveStep[pathPos] = level;
+ pathIt.remove();
+ }
}
- else if (path.elementAt(path.size()-1)==AbstractStep.KEEP_SUBTREE && path.size() <= projPathPos[pathPos]+2) {
+ else if (path.elementAt(path.size()-1)==AbstractStep.KEEP_SUBTREE && path.size() <= curPos+2) {
curProjMode = PROJ_MODE_KEEP_SUB;
}
// else stay in MOVE
- } else { // otherwise remove from set of active paths
+ } else {
+ // if no match and child step, remove from set of active paths
// only assign new last active
-// if (lastActiveStep[pathPos]<0)
+ if (dir == StepInformation.AXIS_CHILD) {
lastActiveStep[pathPos] = level;
-// else {
-// lastActiveStep[pathPos] = lastActiveStep[pathPos]; // dummy for debugging
-// }
- activePaths.remove(new Integer(pathPos));
- //curProjMode = PROJ_MODE_SKIP;
+ pathIt.remove();
+ } else if (dir == StepInformation.AXIS_DESCENDANT) {
+ bufferNode = true;
+ }
}
+ }
+
}
+
}
if (bufferNode)
bufferedPathName.push(name);
-
+ }
break;
case PROJ_MODE_KEEP_SUB:
emitTag = true; // no check, just output
@@ -474,15 +522,33 @@
}
- // TODO: set up/sort things out according to state transitions
+ // set up/sort things out according to state transitions
if (oldMode == PROJ_MODE_MOVE && curProjMode == PROJ_MODE_MOVE) {
// advance all active paths
java.util.Iterator pathIt = activePaths.iterator();
while (pathIt.hasNext()) {
int pathPos = ((Integer)pathIt.next()).intValue();
-
- projPathPos[pathPos]++;
+ java.util.Iterator pathPosIt = projPathPos[pathPos].iterator();
+ HashSet newVals = new HashSet();
+ while (pathPosIt.hasNext()) {
+ int curPos = ((Integer)pathPosIt.next()).intValue();
+ AbstractStep as = ((AbstractStep) ((Vector)projectionPaths.get(pathPos)).elementAt(curPos));
+ int dir = as.getDirection();
+ // Child moves down, descandant stays and moves on
+ if (dir == StepInformation.AXIS_CHILD) {
+ pathPosIt.remove();
+ newVals.add(new Integer(++curPos));
+ }
+ else if (dir == StepInformation.AXIS_DESCENDANT) {
+ XQName curPathCheck = as.getNodeTest().getXQName();
+ if (equalsQNames(curPathCheck,name) && curPos < ((Vector)projectionPaths.get(pathPos)).size()-1) {
+ newVals.add(new Integer(++curPos));
+ }
+ }
+
+ }
+ projPathPos[pathPos].addAll(newVals);
}
if (keepNode)
// put this node on the "keep" list
@@ -657,11 +723,12 @@
public void setProjectionPaths(Vector paths) {
projectionPaths = new ArrayList();
projectionPaths.addAll(paths);
- projPathPos = new int[projectionPaths.size()];
+ projPathPos = new HashSet[projectionPaths.size()];
activePaths = new HashSet();
lastActiveStep = new int[projectionPaths.size()];
for (int i=0;i<projPathPos.length;i++) {
- projPathPos[i] = 0;
+ projPathPos[i] = new HashSet();
+ projPathPos[i].add(new Integer(0));
activePaths.add(new Integer(i));
lastActiveStep[i] = -1;
}
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/query/impl/PreparedStatementImpl.java 2012-02-08 15:43:03 UTC (rev 4528)
@@ -184,5 +184,12 @@
Hashtable ht = new Hashtable();
ht.put("DOC", paths);
return ht;
+ }
+
+ public void setProjectionInformation(QName varname,
+ ObjectObjectPair paths) throws StaticException {
+ VariableHolder vh = ctx.getVariable(varname);
+ vh.setProjectionPaths(paths);
}
+
}
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark01.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark01.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark01.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,5 +1,5 @@
-let $auction := doc()
-let $auction := doc("xmark.xml")
+declare variable $input external;
+let $auction := $input
return for $b in $auction/site/people/person
-where $b/@id = 'person0'
+where $b/id = 'person0'
return $b/name/text()
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark02.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark02.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark02.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,3 +1,5 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
for $b in $auction/site/open_auctions/open_auction
return <increase>{$b/bidder[1]/increase/text()}</increase>
\ No newline at end of file
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark03.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark03.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark03.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,4 +1,6 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
for $b in $auction/site/open_auctions/open_auction
where $b/bidder[1]/increase * 2 <= $b/bidder[last()]/increase
return
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark04.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark04.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark04.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,4 +1,6 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
for $b in $auction/site/open_auctions/open_auction
where
some $pr1 in $b/bidder/personref[person = "person20"],
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark05.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark05.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark05.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,4 +1,6 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
count(
for $i in $auction/site/closed_auctions/closed_auction
where $i/price >= 40
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark06.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark06.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark06.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,2 +1,4 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
for $b in $auction//site/regions return count($b//item)
\ No newline at end of file
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark07.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark07.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark07.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,4 +1,6 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
for $p in $auction/site
return
count($p//description) + count($p//annotation) + count($p//emailaddress)
\ No newline at end of file
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark08.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark08.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark08.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,4 +1,6 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
for $p in $auction/site/people/person
let $a :=
for $t in $auction/site/closed_auctions/closed_auction
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark09.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark09.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark09.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,4 +1,6 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
let $ca := $auction/site/closed_auctions/closed_auction return
let
$ei := $auction/site/regions/europe/item
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark10.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark10.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark10.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,4 +1,6 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
for $i in
distinct-values($auction/site/people/person/profile/interest/category)
let $p :=
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark11.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark11.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark11.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,4 +1,6 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
for $p in $auction/site/people/person
let $l :=
for $i in $auction/site/open_auctions/open_auction/initial
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark12.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark12.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark12.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,4 +1,6 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
for $p in $auction/site/people/person
let $l :=
for $i in $auction/site/open_auctions/open_auction/initial
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark13.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark13.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark13.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,3 +1,5 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
for $i in $auction/site/regions/australia/item
return <item name="{$i/name}">{$i/description}</item>
\ No newline at end of file
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark14.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark14.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark14.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,4 +1,6 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
for $i in $auction/site//item
where contains($i/description, "gold")
return $i/name
\ No newline at end of file
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark15.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark15.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark15.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,4 +1,6 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
for $a in
$auction/site/closed_auctions/closed_auction/annotation/description/parlist/
listitem/
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark16.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark16.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark16.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,4 +1,6 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
for $a in $auction/site/closed_auctions/closed_auction
where
not(
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark17.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark17.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark17.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,4 +1,6 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
for $p in $auction/site/people/person
where empty($p/homepage)
return <person name="{$p/name}"/>
\ No newline at end of file
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark18.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark18.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark18.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,9 +1,10 @@
declare namespace local = "http://www.foobar.org";
+declare variable $input external;
declare function local:convert($v as xs:decimal?) as xs:decimal?
{
2.20371 * $v (: convert Dfl to Euro :)
};
-
-let $auction := doc("auction.xml") return
+let $auction := $input
+return
for $i in $auction/site/open_auctions/open_auction
return local:convert($i/reserve)
\ No newline at end of file
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark19.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark19.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark19.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,4 +1,6 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
for $b in $auction/site/regions//item
let $k := $b/name
order by $b/location ascending empty greatest
Modified: trunk/MXQuery_Testing/ProjectionTests/queries/XMark20.xq
===================================================================
--- trunk/MXQuery_Testing/ProjectionTests/queries/XMark20.xq 2012-02-07 09:34:46 UTC (rev 4527)
+++ trunk/MXQuery_Testing/ProjectionTests/queries/XMark20.xq 2012-02-08 15:43:03 UTC (rev 4528)
@@ -1,4 +1,6 @@
-let $auction := doc("auction.xml") return
+declare variable $input external;
+let $auction := $input
+return
<result>
<preferred>
{count($auction/site/people/person/profile[income >= 100000])}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|