zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #01686
[Merge] lp:~paul-lucas/zorba/feature-ft_module into lp:~zorba-coders/zorba/zorba-experimental
Matthias Brantner has proposed merging lp:~paul-lucas/zorba/feature-ft_module into lp:~zorba-coders/zorba/zorba-experimental.
Requested reviews:
Zorba Coders (zorba-coders)
For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/feature-ft_module/+merge/81317
Create experimental sandbox
--
The attached diff has been truncated due to its size.
https://code.launchpad.net/~paul-lucas/zorba/feature-ft_module/+merge/81317
Your team Zorba Coders is requested to review the proposed merge of lp:~paul-lucas/zorba/feature-ft_module into lp:~zorba-coders/zorba/zorba-experimental.
=== modified file 'ChangeLog'
--- ChangeLog 2011-10-20 23:05:55 +0000
+++ ChangeLog 2011-11-04 19:40:32 +0000
@@ -40,6 +40,7 @@
* Fixed bug #863320 (Sentence is incorrectly incremented when token characters end without sentence terminator)
* Fixed bug #863730 (static delete-node* functions don't raise ZDDY0012)
* Implemented the probe-index-range-value for general indexes
+ * Removed ZSTR0005 and ZSTR0006 error codes
* Fixed bug #867662 ("nullptr" warning)
* Fixed bug #868258 (Assertion failure with two delete collection)
* Fixed bug #871623 and #871629 (assertion failures with insertions in dynamic collections)
@@ -49,11 +50,16 @@
* New node-reference module. References can be obtained for any node, and
different nodes cannot have the same identifier.
* Fixed bug #872697 (segmentation fault with validation of NMTOKENS)
+ * General index cannot be declared as unique if the type of its key is
+ xs:anyAtomicType or xs:untypedAtomic.
* Added undo for node revalidation
* Optimization for count(collection()) expressions
* Fixed bug #872796 (validate-in-place can interfere with other update primitives)
* Fixed bug #872799 (validate-in-place can set incorrect types)
* Fixed bug #855715 (Invalid escaped characters in regex not caught)
+ * New node-position module. This module allows to obtain a representation of a node position, which
+ can be used to assess structural relationships with other nodes.
+ * Fixed bug #872502 (validation of the JSON module xqdoc fails)
version 2.0.1
=== modified file 'bin/CMakeLists.txt'
--- bin/CMakeLists.txt 2011-08-05 02:21:55 +0000
+++ bin/CMakeLists.txt 2011-11-04 19:40:32 +0000
@@ -84,3 +84,7 @@
# test the --option option to set an option in the static context
ZORBA_ADD_TEST(bin/zorba_option zorbacmd -q "${CMAKE_CURRENT_SOURCE_DIR}/test/option.xq" -f --option "{http://www.zorba-xquery.com}option=value")
ZORBA_SET_TEST_PROPERTY(bin/zorba_option PASS_REGULAR_EXPRESSION "value")
+
+# test compilation of the perf script
+ZORBA_ADD_TEST(bin/zorba_compilechk4 zorbacmd -q "${CMAKE_CURRENT_SOURCE_DIR}/../test/zperf/src/start.xq" -f --compile-only)
+
=== modified file 'doc/zorba/xqddf.dox'
--- doc/zorba/xqddf.dox 2011-10-05 17:49:48 +0000
+++ doc/zorba/xqddf.dox 2011-11-04 19:40:32 +0000
@@ -1375,6 +1375,14 @@
AtomicType ::= QName
IndexKeyCollation ::= 'collation' UriLiteral
+
+ Note: the following annotations are accepted within the context of an index declaration:
+
+ %ann:unique, %ann:nonunique,
+ %ann:value-range, %ann:value-equality,
+ %ann:general-range, %ann:general-equality,
+ %ann:manual or %ann:automatic
+
\endcode
Syntactically, each index is defined by an <a href="#index_declaration">
@@ -1385,8 +1393,8 @@
value indexes and general indexes. Whether an index is a value or a general
index is determined by the value of the usage property, which is explained below.
-Index declarations (for both value and general indexes) must be placed inside module prologs.
-The Prolog syntax is extended accordingly, as shown above.
+Index declarations (for both value and general indexes) must be placed inside
+module prologs. The Prolog syntax is extended accordingly, as shown above.
An additional constraint (not expressible syntactically) is that only library
modules may contain index declarations [<a href="#ERRZDST0023">zerr:ZDST0023</a>].
The reasons for this rule are the same as those for collections (see \ref
@@ -1424,7 +1432,10 @@
(or key tuple in the case of value indexs) with exactly one domain node.
Otherwise, if the index is '%ann:nonunique', multiple domain nodes may have the
same key value, and as a result, each index entry associates a key with a
-set of domain nodes.
+set of domain nodes. In the current implementation, it is not allowed to declare
+an index as unique if it is a general index whose IndexKeyTypeDecl is either absent
+or specifies xs:anyAtomicType or xs:untypedAtomic as its atomic type
+[<a href="#ERRZDST0025">zerr:ZDST0025</a>].
The usage property specifies the kind of the index based on the query expressions
that may be optimized by using the index. A <strong>value equality index</strong>
@@ -1529,16 +1540,17 @@
\subsection index_creation Index Creation
-As explained already, indexes are just sets of index entries, mapping key items
-or key tuples to domain nodes. In terms of the XQuery language, these sets
-"live" in the dynamic context. In particular, XQDDF extends the dynamic context
-with a component called the <strong>available indexes</strong>. This is a map
-whose entries associate the expanded QName of an index with the entry set of the
-index. If an entry for an index appears in the available indexes of a module,
-the index is said to be available to that module.
+As explained already, indexes are just sets of index entries, where an index
+entry maps a key item or a key tuple to a set of domain nodes (to be more
+precise, an index entry contains some kind of "pointers" to nodes, not the
+nodes themselves). In terms of the XQuery language, indexes "live" in the
+dynamic context. In particular, XQDDF extends the dynamic context with a
+component called the <strong>available indexes</strong>. This is a map whose
+entries associate the expanded QName of an index with the entry set for that
+index.
In practice, the available indexes component is implemented by Zorba's storage
-system. To begin with, each index entry set is implemented by some appropriate
+system. To begin with, each index is implemented by some appropriate
data structure that acts as an index entry container. The description of
potential data structures is beyond the scope of this document, but the typical
choices are either some sort of hash table(s) (for equality indexes) or some kind
@@ -1595,9 +1607,7 @@
indexes, an error is raised [<a href="#ERRZDDY0028">zerr:ZDDY0028</a>]. The result
of the domain expression after duplicate elimination is called the <strong>domain
sequence</strong>. If the domain sequence contains a node that does not belong to
-a collection, an error is raised [<a href="#ERRZDDY0020">zerr:ZDDY0020</a>] (the
-purpose of this rule is to prevent nodes constructed by node construction
-expression to appear as domain nodes).</li>
+a collection, an error is raised [<a href="#ERRZDDY0020">zerr:ZDDY0020</a>].</li>
<li>
For each node D in the domain sequence, the IndexKeySpecs are evaluated in some
@@ -1619,8 +1629,8 @@
</li>
<li>
- Duplicate values, which may arise in the case of general indexes only, are
- eliminated from the key sequence.
+ Duplicate values (which may arise in the case of general indexes only) are
+ eliminated from the atomized sequence.
</li>
</ul>
@@ -1630,12 +1640,12 @@
<ul>
<li>
- The result of each IndexKeySpec is a single atomic item. We call this
- item a <strong>key item</strong>.
+ The result of each IndexKeySpec is a single atomic item or the empty sequence.
+ We call this result a <strong>key value</strong>.
</li>
<li>
- Let D<sub>i</sub> be the i-th domain node, and K<sub>ij</sub> be the key item
+ Let D<sub>i</sub> be the i-th domain node, and K<sub>ij</sub> be the key value
computed for D<sub>i</sub> by the j-th IndexKeySpec (where the numbering of
the IndexKeySpecs is done using their order of appearance in the index
declaration). Let K<sub>i</sub> be the tuple [K<sub>i1</sub>, ...,
@@ -1650,16 +1660,14 @@
tuples and domain nodes is one-to-one. In this case, if the index already
contains an entry whose key tuple is equal to K<sub>i</sub>, an error is
raised [<a href="#ERRZDDY0024">zerr:ZDDY0024</a>]. Otherwise, the entry
- [K<sub>i</sub>, D<sub>i</sub>] is inserted in the index container (to be very
- precise, the entry contains a "pointer" to the node, not the node itself).
+ [K<sub>i</sub>, D<sub>i</sub>] is inserted in the index container.
</li>
<li>
- If the index is non-unique, it maps key tuples to sets of domain nodes. In
- this case, if the index already contains an entry whose key is equal to
- K<sub>i</sub>, D<sub>i</sub> is added to the set associated with K<sub>i</sub>.
- Otherwise, the entry [K<sub>i</sub>, { D<sub>i</sub> }] is inserted in the
- index.
+ If the index is non-unique, then if it already contains an entry whose key
+ tuple is equal to K<sub>i</sub>, D<sub>i</sub> is added to the set associated
+ with K<sub>i</sub>. Otherwise, the entry [K<sub>i</sub>, { D<sub>i</sub> }]
+ is inserted in the index.
</li>
</ul>
@@ -1673,7 +1681,7 @@
to value indexes, the result of this IndexKeySpec may be a sequence of any
number of atomic items, and the items may have different data types. We call
this sequence a <strong>key sequence</strong>, and each atomic item in it a
- <strong>key item</strong>.
+ <strong>key item</strong> (the key sequence may also be the empty sequence).
</li>
<li>
@@ -1694,17 +1702,6 @@
into K<sub>i</sub>.
</li>
- <li>
- If any item in the expanded key sequence has a data type that is not a
- primitive builtin type, this data type is changed to the nearest base type
- that is a primitive builtin type. For example, xs:token is changed to
- xs:string, and xs:long is changed to xs:decimal. (Note: this is a conceptual
- description of the index creation process. The actual implementation may
- differ from this description as long as the results of
- <a href="#index_probing">probe functions</a> are always the same as those
- implied by this conceptual description.)
- </li>
-
<li>
The next step is to insert in the index a mapping from K<sub>ij</sub> to
D<sub>i</sub>, for each key item K<sub>ij</sub> in the expanded key sequence
@@ -1714,32 +1711,25 @@
</li>
<li>
- If the index is declared as unique, the relationship between between key
- items and domain nodes is one-to-one. In this case, if the index already
- contains an entry whose key item has the same type as K<sub>ij</sub> and
- its value is equal to K<sub>ij</sub>, an error is raised
+ If the index is declared as unique, the relationship between key items and
+ domain nodes is one-to-one. In this case, if the index already contains an
+ entry whose key item is equal to K<sub>ij</sub>, an error is raised
[<a href="#ERRZDDY0024">zerr:ZDDY0024</a>]. Otherwise, the entry
[K<sub>ij</sub>, D<sub>i</sub>] is inserted in the index container.
- <li>
-
- <li>
- If the index is non-unique, it maps key items to sets of domain nodes. In
- this case, if the index already contains an entry whose key K has the same
- type as K<sub>ij</sub> and its value is equal to K<sub>ij</sub>, D<sub>i</sub>
- is added to the set associated with K. Otherwise, the entry [K<sub>ij</sub>,
- { D<sub>i</sub> }] is inserted into the index.
- </li>
-
- <li>
- In addition to its entry set, each general index entry stores 2 extra flags:
- The <strong>multi-key flag</strong> is set to true if there is any domain
- node whose unexpanded key sequence contained more than 1 items; otherwise the
- flag is false. The <strong>untyped flag</strong> is set to true if during the
- expansion of a key sequence, an untyped key was successfully cast to an item
- with a type other than xs:string or xs:anyURI.; otherwise the flag is false.
- As we will see later, these flags are needed during <a href="#index_probing">
- index probing</a>.
- </li>
+ </li>
+
+ <li>
+ If the index is non-unique, then if it already contains an entry whose key
+ K is equal to K<sub>ij</sub>, D<sub>i</sub> is added to the node set
+ associated with K. Otherwise, the entry [K<sub>ij</sub>, { D<sub>i</sub> }]
+ is inserted into the index.
+ </li>
+
+ <li>
+ The index maintains a "special" entry for all domain nodes whose key sequence
+ is empty. All such nodes are inserted in the node set associated with this entry.
+ </li>
+
</ul>
<li>
@@ -1764,35 +1754,39 @@
The delete function is evaluated as follows:
- <ul>
- <li>If the given expanded QName does not identify an index among the
-statically known indexes in the static context of the invoking module, an error
-is raised [<a href="#ERRZDDY0021">zerr:ZDDY0021</a>].</li>
- <li>If the given expanded QName does not identify an index among the available
+<ul>
+<li>
+If the given expanded QName does not identify an index among the statically
+known indexes in the static context of the invoking module, an error is
+raised [<a href="#ERRZDDY0021">zerr:ZDDY0021</a>].
+</li>
+<li>
+If the given expanded QName does not identify an index among the available
indexes in the dynamic context of the invoking module, an error is raised [<a
-href="#ERRZDDY0023" title="zerr:ZDDY0023">zerr:ZDDY0023</a>].</li>
- <li>The result of the function is an empty XDM instance and a pending update
-list that consists of a single update primitive:
-upd:deleteIndex($indexName).</li>
- </ul>
+href="#ERRZDDY0023">zerr:ZDDY0023</a>].
+</li>
+<li>
+The result of the function is an empty XDM instance and a pending update
+list that consists of a single update primitive: upd:deleteIndex($indexName).
+</li>
+</ul>
The update primitive is applied as follows:
- <ul>
- <li>The index entry container for the index is found via the indexes
-table.</li>
- <li>All entries in the container are destroyed.</li>
- <li>The container itself is destroyed.</li>
- <li>The entry mapping the index name to the index entry container is removed
+<ul>
+<li>The index entry container for the index is found via the indexes table.</li>
+<li>All entries in the container are destroyed.</li>
+<li>The container itself is destroyed.</li>
+<li>The entry mapping the index name to the index entry container is removed
from the indexes table.</li>
- </ul>
+</ul>
\subsection index_probing Index Probing
Probing an index means retrieving the domain nodes associated with a particular
-search condition Probing can be done via the xqddf functions
+search condition. Probing can be done via the xqddf functions
idml:probe-index-point-value, idml:probe-index-point-general,
idml:probe-index-range-value, or idml:probe-index-range-general.
For each of these functions, the first argument is a QName identifying an index.
@@ -1803,72 +1797,97 @@
respectively. All of the functions return their result sorted in document order
and without duplicate nodes.
+
<strong>idml:probe-index-point-value</strong>
+
<a name="probe_index_point_value" id="probe_index_point_value"></a>
\code
idml:probe-index-point-value($indexUri as xs:QName,
- $key1 as xs:anyAtomicType?,
- ...,
- $keyM as xs:anyAtomicType?) as node()*
+ $key1 as xs:anyAtomicType?,
+ ...,
+ $keyM as xs:anyAtomicType?) as node()*
\endcode
-For the probe-index-point-value function, the search condition is specified as a
-number of <strong>search keys</strong> comprising a <strong>search
-tuple</strong>. A search key is either an atomic item or the empty sequence.
-The number of search keys must be equal to the number of IndexKeySpecs found
-in the index declaration [<a href="#ERRZDDY0025"> zerr:ZDDY0025</a>]. (Remember
-that for general indexes, there can be only one IndexKeySpec, and as a result,
-for general indexes, the probe-index-point-value function takes only one search
-value as input). Furthermore, for each search key that is not the empty sequence,
-its type must match the sequence type specified in the corresponding IndexKeyTypeDecl;
-otherwise, a type error is raised [err:XPTY0004].
-
-The result of this function is either an error or the set of domain nodes for which
-the following xquery condition returns true:
+The probe-index-point-value function retrieves the domain nodes associated by
+value equality with a given <strong>search tuple</strong>. The search tuple
+consists of a number of <strong>search keys</strong>, where each search key
+is either an atomic item or the empty sequence. The result of this function
+is either an error or the set of domain nodes for which the following xquery
+expression returns true:
\code
-$key1 eq $node/keyExpr1 and ... and $keyM eq $node/keyExprM
+$key1 eq $node/keyExpr1 and ... and $keyM eq $node/keyExprN
\endcode
-where keyExpr<sub>i</sub> is the expression specified in the i-th keyspec
-of the index. Notice that this definition implies that if any of search keys
-is the empty sequence, the result of the probe is also the empty sequence.
-
-In addition to the error conditions described already, the function raises
-a type error [err:XPTY0004] if the index is general and (a) the multi-key flag
-of the index is true, or (b) the untyped flag of the index is true and the type of
-any non-empty search key is something other than xs:untypedAtomic, xs:string, or
-xs:anyURI (or subtype of these).
+where keyExpr-i is the expression specified in the i<sup>th</sup> keyspec
+of the index and N is the number of keyspecs for the index. Notice that this
+definition implies that if any of search keys is the empty sequence, the
+result of the probe is also the empty sequence.
+
+In addition to the errors that may be raised by the above expression, the
+probe-index-point-value function may raise the following errors:
+
+<ul>
+<li>
+ <a href="#ERRZDDY0021">zerr:ZDDY0021</a> or <a href="#ERRZDDY0023">zerr:ZDDY0023</a>,
+if the index is not among the statically known indexes or the available indexes.
+</li>
+<li>
+[<a href="#ERRZDDY0025">zerr:ZDDY0025</a>], if the number of search keys is not
+equal to the number of keyspecs found in the index declaration.
+</li>
+<li>
+[err:XPTY0004], if a non-empty seach key is given, whose type does not match
+the sequence type specified in the corresponding keyspec.
+</li>
+</ul>
<strong>idml:probe-index-point-general</strong>
+
<a name="probe_index_point_general" id="probe_index_point_general"></a>
\code
idml:probe-index-point-general($indexUri as xs:QName,
- $keys as xs:anyAtomicType*) as node()*
+ $keys as xs:anyAtomicType*) as node()*
\endcode
-This method is supported by general indexes only [<a href="#ERRZDDY0029">
-zerr:ZDDY0029</a>]. The search condition is specified as a <strong>search
-sequence</strong> consisting of an arbitrary number of <strong>search keys
-</strong>, where each search key is an atomic item. If the search sequence
-is non-empty, the type of each search key must match the atomic type specified
-by the IndexKeyTypeDecl of the index; otherwise, a type error is raised [err:XPTY0004].
-
-The result of this function is either an error or the set of domain nodes for which
-the following xquery condition returns true:
+The probe-index-point-general function retrieves the domain nodes associated by
+general equality with a given <strong>search sequence</strong>. The search
+sequence consists of an arbitrary number of <strong>search keys</strong>, where
+each search key is an atomic item. The function is supported by general indexes
+only [<a href="#ERRZDDY0029">zerr:ZDDY0029</a>]. Its result is either an error
+or the set of domain nodes for which the following xquery expression returns true:
\code
$keys = $node/keyExpr
\endcode
-where keyExpr is the expression specified in the keyspec of the index.
+where keyExpr is the expression specified in the keyspec of the index (remember
+that for general indexes, there can be only one keyspec).
+
+In addition to the errors that may be raised by the above expression, the
+probe-index-point-value function may raise the following errors:
+
+<ul>
+<li>
+ <a href="#ERRZDDY0021">zerr:ZDDY0021</a> or <a href="#ERRZDDY0023">zerr:ZDDY0023</a>,
+if the index is not among the statically known indexes or the available indexes.
+</li>
+<li>
+[<a href="#ERRZDDY0029">zerr:ZDDY0029</a>], if the index is not general.
+</li>
+<li>
+[err:XPTY0004], if the search sequence contains a search key, whose type does
+not match the sequence type specified in the keyspec of the index.
+</li>
+</ul>
<strong>idml:probe-index-range-value</strong>
+
<a name="probe_index_range_value" id="probe_index_range_value"></a>
\code
probe-index-range-value($indexUri as xs:QName,
@@ -1887,22 +1906,22 @@
$upperBoundIncludedM as xs:boolean) as node()*
\endcode
-The probe-index-range-value function can be invoked on range indices only
-(value or general) [<a href="#ERRZDDY0026">zerr:ZDDY0026</a>]. The search
-condition is specified as a number M of <strong>rangespecs</strong>, where
-each rangespec consists of six values. The number M must be greater than
-0 and less than or equal to the number N of keyspecs found in the declaration
-of the given index [<a href="#ERRZDDY0025">zerr:ZDDY0025</a>]. If M is less
+The probe-index-range-value function retrieves the domain nodes associated by
+value order-comparison (operators le, lt, ge, gt) with a given <strong>search
+box</strong>. The search box is specified as a number M of <strong>rangespecs
+</strong>, where each rangespec consists of six values. The number M must be
+greater than 0 and less than or equal to the number N of keyspecs found in the
+index declaration [<a href="#ERRZDDY0025">zerr:ZDDY0025</a>]. If M is less
than N, then the "missing" rangespecs are assumed to have the following
value: [(), (), false, false, false, false]. As a result, from now on, we
can assume that M is equal to N (Remember that for general indexes, there
can be only one IndexKeySpec, and as a result, for general indexes, M = N = 1).
The i<sup>th</sup> rangespec corresponds to the i<sup>th</sup> keyspec, and
-specifies a condition on the key values that are produced by evaluating that
-keyspec for every domain node. Specifically, we define the i<sup>th</sup>
+specifies a search condition on the key values that are produced by evaluating
+that keyspec for every domain node. Specifically, we define the i<sup>th</sup>
<strong>rangespec result</strong> as the set of domain nodes for which the
-following xquery condition returns true:
+following xquery expression returns true:
\code
if ($haveLowerBound-i and $haveUpperBound-i) then
@@ -1920,26 +1939,40 @@
$lowerBoundsIncluded-i is true or false, and uop is either the le or the
lt operator depending on whether $upperBoundsIncluded-i is true or false.
-In computing the i<sup>th</sup> rangespec result, a type error [err:XPTY0004]
-is raised in the following cases: (a) $haveLowerBound-i is true and
-$lowerBound-i is an atomic item whose type does not match the atomic
-type specified by i<sup>th</sup> keyspec, or (b) $haveUpperBound-i is
-true and $upperBound-i is an atomic item whose type does not match
-the atomic type specified by i<sup>th</sup> keyspec, or (c) the index is general
-and its multi-key flag is true, or (d) the index is general, its untyped flag
-is true, $haveLowerBound-i is true, and $lowerBound-i is
-an atomic item whose type is something other than xs:untypedAtomic, xs:string,
-or xs:anyURI (or subtype of these), or (e) the index is general, its untyped flag
-is true, $haveUpperBound-i is true, and $upperBound-i is
-an atomic item whose type is something other than xs:untypedAtomic, xs:string,
-or xs:anyURI (or subtype of these).
+The result of the probe-index-range-value function is either an error, or the
+intersection of all the rangespec results. In addition to the errors that may
+be raised by a rangespec expression, the function may raise the following errors:
-The result of the probe-index-range-value is either one of the errors described
-above, or the intersection of all the rangespec results.
+<ul>
+<li>
+ <a href="#ERRZDDY0021">zerr:ZDDY0021</a> or <a href="#ERRZDDY0023">zerr:ZDDY0023</a>,
+if the index is not among the statically known indexes or the available indexes.
+</li>
+<li>
+[<a href="#ERRZDDY0026">zerr:ZDDY0026</a>], if the index is not a range index.
+</li>
+<li>
+[<a href="#ERRZDDY0025">zerr:ZDDY0025</a>], if the number of rangespecs passed
+as arguments is zero or greater than the number of keys declared for the index.
+</li>
+<li>
+[err:XPTY0004], if $haveLowerBound-i is true and $lowerBound-i is an atomic
+item whose type does not match the sequence type specified by the i<sup>th</sup>
+keyspec, or $haveUpperBound-i is true and $upperBound-i is an atomic item
+whose type does not match the sequence type specified by the i<sup>th</sup> keyspec.
+</li>
+<li>
+[<a href="#ERRZDDY0034">zerr:ZDDY0034</a>], if (a) the index is general (in which
+case there is only one rangespac), (b) the index is untyped, (c) there is both a
+lower and an upper bound, and (d) if T1 and T2 are the types of the lower and
+upper bound, neither T1 is a subtype of T2 nor T2 is a subtype of T1.
+</li>
+</ul>
<strong>idml:probe-index-range-general</strong>
+
<a name="probe_index_range_general" id="probe_index_range_general"></a>
\code
probe-index-range-general($indexUri as xs:QName,
@@ -1951,15 +1984,13 @@
$upperBoundIncluded as xs:boolean) as node()*
\endcode
-This method is supported by general range indexes only [<a href="#ERRZDDY0030">
-zerr:ZDDY0030</a>]. The search condition is specified as two sequences of atomic
-search key items and four boolean values. If any of the search sequences is
-non-empty, the type of each atomic item in it must match the atomic type specified
-by the IndexKeyTypeDecl of the index; otherwise, a type error is raised
-[zerr:XPTY0004].
-
-The result of this function is either an error or the set of domain nodes for
-which the following xquery expression returns true:
+The probe-index-range-general function retrieves the domain nodes associated
+by general order-comparison (operators <=, <, >=, >) with one or two
+<strong>search sequences</strong>. Each search sequence consists of an
+arbitrary number of <strong>search keys</strong>, where each search key is
+an atomic item. This method is supported by general range indexes only
+[<a href="#ERRZDDY0030">zerr:ZDDY0030</a>]. Its result is either an error or
+the set of domain nodes for which the following xquery expression returns true:
\code
if ($haveLowerBound and $haveUpperBound) then
@@ -1972,11 +2003,30 @@
fn:true()
\endcode
-where keyExpr is the expression specified in the keySpec of the index,
+where keyExpr is the expression specified in the keyspec of the index,
lop is either the <= or the < operator depending on whether $lowerBoundsIncluded
is true or false, and uop is either the <= or the < operator depending on whether
$upperBoundsIncluded is true or false.
+In addition to the errors that may be raised by the above expression, the
+probe-index-point-value function may raise the following errors:
+
+<ul>
+<li>
+ <a href="#ERRZDDY0021">zerr:ZDDY0021</a> or <a href="#ERRZDDY0023">zerr:ZDDY0023</a>,
+if the index is not among the statically known indexes or the available indexes.
+</li>
+<li>
+[<a href="#ERRZDDY0030">zerr:ZDDY0030</a>], if the index is not a general range index.
+</li>
+<li>
+[err:XPTY0004], if $haveLowerBound is true and $lowerBoundKeys constains an
+atomic item whose type does not match the sequence type specified by the index
+keyspec, or $haveUpperBound is true and $upperBoundKeys contains an atomic item
+whose type does not match the sequence type specified by the index keyspec.
+</li>
+</ul>
+
\subsection index_maintenance Index Maintenance
@@ -2293,8 +2343,8 @@
<a name="ERRZDST0024" id="ERRZDST0024"></a>zerr:ZDST0024, The declaration for
index specifies multiple values for the same property.
- <a name="ERRZDST0025" id="ERRZDST0025"></a>zerr:ZDST0025, The declaration for
-index specifies conflicting property values.
+ <a name="ERRZDST0025" id="ERRZDST0025"></a>zerr:ZDST0025, The index cannot be
+declared as unique.
<a name="ERRZDST0026" id="ERRZDST0026"></a>zerr:ZDST0026, The declaration for
index contains an invalid property value.
@@ -2447,6 +2497,9 @@
<a name="ERRZDDY0033" id="ERRZDDY0033"></a>zerr:ZDDY0033, Conditions for
integrity constraint were not met on collection.
+
+ <a name="ERRZDDY0034" id="ERRZDDY0034"></a>zerr:ZDDY0034, Index range-value
+ probe has search keys with incompatible types
</strong>
*/
=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
--- include/zorba/pregenerated/diagnostic_list.h 2011-10-19 15:28:51 +0000
+++ include/zorba/pregenerated/diagnostic_list.h 2011-11-04 19:40:32 +0000
@@ -624,6 +624,8 @@
extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZDST0024_INDEX_MULTIPLE_PROPERTY_VALUES;
+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZDST0025_INDEX_BAD_UNIQUE_PROPERTY;
+
extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZDST0026_INDEX_INVALID_PROPERTY_VALUE;
extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZDST0027_INDEX_BAD_KEY_TYPE;
@@ -684,10 +686,6 @@
extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZSTR0004_INDEX_PARTIAL_KEY_REMOVE;
-extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZSTR0005_INDEX_PARTIAL_KEY_PROBE;
-
-extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZSTR0006_INDEX_INVALID_BOX_PROBE;
-
extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZSTR0007_INDEX_UNSUPPORTED_PROBE_CONDITION;
extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZSTR0008_COLLECTION_ALREADY_EXISTS;
=== modified file 'include/zorba/thesaurus.h'
--- include/zorba/thesaurus.h 2011-09-07 20:08:18 +0000
+++ include/zorba/thesaurus.h 2011-11-04 19:40:32 +0000
@@ -64,6 +64,7 @@
* @return Returns \c true only if there is a next synonym.
*/
virtual bool next( String *synonym ) = 0;
+
protected:
virtual ~iterator() {}
};
=== modified file 'include/zorba/tokenizer.h'
--- include/zorba/tokenizer.h 2011-08-31 19:27:14 +0000
+++ include/zorba/tokenizer.h 2011-11-04 19:40:32 +0000
@@ -94,6 +94,25 @@
/////////////////////////////////////////////////////////////////////////////
/**
+ * Various properties of this %Tokenizer.
+ */
+ struct Properties {
+ /**
+ * If \c true, XML elements separate tokens.
+ */
+ bool elements_separate_tokens;
+ };
+
+ /**
+ * Gets the Properties of this %Tokenizer.
+ *
+ * @param result The Properties to populate.
+ */
+ virtual void properties( Properties *result ) const = 0;
+
+ /////////////////////////////////////////////////////////////////////////////
+
+ /**
* Destroys this %Tokenizer.
* This function is called by Zorba when the %Tokenizer is no longer needed.
*
=== modified file 'modules/com/zorba-xquery/www/modules/CMakeLists.txt'
--- modules/com/zorba-xquery/www/modules/CMakeLists.txt 2011-09-30 08:08:13 +0000
+++ modules/com/zorba-xquery/www/modules/CMakeLists.txt 2011-11-04 19:40:32 +0000
@@ -46,6 +46,8 @@
URI "http://www.zorba-xquery.com/modules/math")
DECLARE_ZORBA_MODULE(FILE node-reference.xq VERSION 2.0
URI "http://www.zorba-xquery.com/modules/node-reference")
+DECLARE_ZORBA_MODULE(FILE node-position.xq VERSION 2.0
+ URI "http://www.zorba-xquery.com/modules/node-position")
DECLARE_ZORBA_MODULE(FILE node.xq VERSION 2.0
URI "http://www.zorba-xquery.com/modules/node")
DECLARE_ZORBA_MODULE(FILE project_xqdoc.xq VERSION 2.0
@@ -63,6 +65,11 @@
DECLARE_ZORBA_MODULE(FILE xqdoc.xq VERSION 2.0
URI "http://www.zorba-xquery.com/modules/xqdoc")
+IF(NOT ZORBA_NO_FULL_TEXT)
+ DECLARE_ZORBA_MODULE(FILE full-text.xq VERSION 2.0
+ URI "http://www.zorba-xquery.com/modules/full-text")
+ENDIF(NOT ZORBA_NO_FULL_TEXT)
+
# Subdirectories
DECLARE_ZORBA_MODULE(FILE converters/base64.xq VERSION 2.0
URI "http://www.zorba-xquery.com/modules/converters/base64")
=== added file 'modules/com/zorba-xquery/www/modules/full-text.xq'
--- modules/com/zorba-xquery/www/modules/full-text.xq 1970-01-01 00:00:00 +0000
+++ modules/com/zorba-xquery/www/modules/full-text.xq 2011-11-04 19:40:32 +0000
@@ -0,0 +1,205 @@
+xquery version "3.0";
+
+(:
+ : Copyright 2006-2011 The FLWOR Foundation.
+ :
+ : Licensed under the Apache License, Version 2.0 (the "License");
+ : you may not use this file except in compliance with the License.
+ : You may obtain a copy of the License at
+ :
+ : http://www.apache.org/licenses/LICENSE-2.0
+ :
+ : Unless required by applicable law or agreed to in writing, software
+ : distributed under the License is distributed on an "AS IS" BASIS,
+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ : See the License for the specific language governing permissions and
+ : limitations under the License.
+ :)
+
+(:~
+ : This module provides an XQuery API to full-text functions.
+ :)
+module namespace ft = "http://www.zorba-xquery.com/modules/full-text";
+declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
+declare option ver:module-version "2.0";
+
+(:~
+ : Gets the host's default language.
+ :
+ : @return said language.
+ :)
+declare function ft:host-lang()
+ as xs:language external;
+
+(:~
+ : Checks whether the given word is a stop-word.
+ :
+ : @param word The word to check. The word's language is assumed to be the
+ : host machine's current language.
+ : @return \c true only if the \a word is a stop-word.
+ :)
+declare function ft:is-stop-word( $word as xs:string )
+ as xs:boolean external;
+
+(:~
+ : Checks whether the given word is a stop-word.
+ :
+ : @param word The word to check.
+ : @param lang The language of \a word.
+ : @return \c true only if the \a word is a stop-word.
+ :)
+declare function ft:is-stop-word( $word as xs:string, $lang as xs:language )
+ as xs:boolean external;
+
+(:~
+ : Stems the given word.
+ :
+ : @param word The word to stem. The word's language is assumed to be the
+ : host machine's current language.
+ : @return the stem of \a word.
+ :)
+declare function ft:stem( $word as xs:string )
+ as xs:string external;
+
+(:~
+ : Stems the given word.
+ :
+ : @param word The word to stem.
+ : @param lang The language of \a word.
+ : @return the stem of \a word.
+ :)
+declare function ft:stem( $word as xs:string, $lang as xs:language )
+ as xs:string external;
+
+(:~
+ : Strips all diacritical marks from all characters.
+ :
+ : @param string The string to strip diacritical marks from.
+ : @return \a string with diacritical marks stripped.
+ :)
+declare function ft:strip-diacritics( $string as xs:string )
+ as xs:string external;
+
+(:~
+ : Looks-up the given phrase in the default thesaurus.
+ :
+ : @param phrase The phrase to look up. The phrase's language is assumed to be
+ : in the host machine's current language.
+ : @return the related phrases.
+ :)
+declare function ft:thesaurus-lookup( $phrase as xs:string )
+ as xs:string+ external;
+
+(:~
+ : Looks-up the given phrase in a thesaurus.
+ :
+ : @param uri The URI specifying the thesaurus to use.
+ : @param phrase The phrase to look up. The phrase's language is assumed to be
+ : in the host machine's current language.
+ : @return the related phrases.
+ :)
+declare function ft:thesaurus-lookup( $uri as xs:string, $phrase as xs:string )
+ as xs:string+ external;
+
+(:~
+ : Looks-up the given phrase in a thesaurus.
+ :
+ : @param uri The URI specifying the thesaurus to use.
+ : @param phrase The phrase to look up.
+ : @param lang The language of \a phrase.
+ : @return the related phrases.
+ :)
+declare function ft:thesaurus-lookup( $uri as xs:string, $phrase as xs:string,
+ $lang as xs:language )
+ as xs:string+ external;
+
+(:~
+ : Looks-up the given phrase in a thesaurus.
+ :
+ : @param uri The URI specifying the thesaurus to use.
+ : @param phrase The phrase to look up.
+ : @param lang The language of \a phrase.
+ : @param relationship The relationship the results are to have to \a phrase.
+ : @return the related phrases.
+ :)
+declare function ft:thesaurus-lookup( $uri as xs:string, $phrase as xs:string,
+ $lang as xs:language,
+ $relationship as xs:string )
+ as xs:string+ external;
+
+(:~
+ : Looks-up the given phrase in a thesaurus.
+ :
+ : @param uri The URI specifying the thesaurus to use.
+ : @param phrase The phrase to look up.
+ : @param lang The language of \a phrase.
+ : @param relationship The relationship the results are to have to \a phrase.
+ : @param level-least The minimum number of levels within the thesaurus to be
+ : traversed.
+ : @param level-most The maximum number of levels within the thesaurus to be
+ : traversed.
+ : @return the related phrases.
+ :)
+declare function ft:thesaurus-lookup( $uri as xs:string, $phrase as xs:string,
+ $lang as xs:language,
+ $relationship as xs:string,
+ $level-least as xs:integer,
+ $level-most as xs:integer )
+ as xs:string+ external;
+
+(:~
+ : Tokenizes the given document.
+ :
+ : @param doc The XML document to tokenize. The document's default language is
+ : assumed to be the host machine's current language.
+ : @return a (possibly empty) sequence of tokens.
+ :)
+declare function ft:tokenize( $doc as node() )
+ as node()* external;
+
+(:~
+ : Tokenizes the given document.
+ :
+ : @param doc The document to tokenize.
+ : @param lang The default language of \a doc.
+ : @return a (possibly empty) sequence of tokens.
+ :)
+declare function ft:tokenize( $doc as node(), $lang as xs:language )
+ as node()* external;
+
+(:~
+ : Tokenizes the given string.
+ :
+ : @param string The string to tokenize. The string's default language is
+ : assumed to be the host machine's current language.
+ : @return a (possibly empty) sequence of tokens.
+ :)
+declare function ft:tokenize-string( $string as xs:string )
+ as xs:string*
+{
+ () (: TODO :)
+};
+
+(:~
+ : Tokenizes the given string.
+ :
+ : @param string The string to tokenize.
+ : @param lang The default language of \a string.
+ : @return a (possibly empty) sequence of tokens.
+ :)
+declare function ft:tokenize-string( $string as xs:string,
+ $lang as xs:language )
+ as xs:string*
+{
+ () (: TODO :)
+};
+
+(:~
+ : Gets properties of the tokenizer.
+ :
+ : @return said properties.
+ :)
+declare function ft:tokenizer-properties()
+ as node() external;
+
+(: vim:set et sw=2 ts=2: :)
=== added file 'modules/com/zorba-xquery/www/modules/node-position.xq'
--- modules/com/zorba-xquery/www/modules/node-position.xq 1970-01-01 00:00:00 +0000
+++ modules/com/zorba-xquery/www/modules/node-position.xq 2011-11-04 19:40:32 +0000
@@ -0,0 +1,524 @@
+xquery version "1.0";
+(:
+ : Copyright 2006-2011 The FLWOR Foundation.
+ :
+ : Licensed under the Apache License, Version 2.0 (the "License");
+ : you may not use this file except in compliance with the License.
+ : You may obtain a copy of the License at
+ :
+ : http://www.apache.org/licenses/LICENSE-2.0
+ :
+ : Unless required by applicable law or agreed to in writing, software
+ : distributed under the License is distributed on an "AS IS" BASIS,
+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ : See the License for the specific language governing permissions and
+ : limitations under the License.
+ :)
+
+(:~
+ : This module provides a function (np:node-position) that, given a node,
+ : returns positional information about the node in the form of an xs:anyURI
+ : item. The module also defines functions that use such positional information
+ : to determine: (1) positional relationships between two nodes (e.g. if one
+ : is the ancestor of another) and (2) positional properties of a single node
+ : (e.g. its level in the tree).
+ :
+ : Within this module, the term "node position" will be used to refer to an
+ : xs:anyURI item that is returned by the np:node-position function.
+ :
+ : @author Federico Cavalieri, Markos Zaharioudakis
+ :
+ : @project XDM/node
+ :)
+module namespace np = "http://www.zorba-xquery.com/modules/node-position";
+
+declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
+declare option ver:module-version "2.0";
+
+(:~
+ : Return a URI item containing positional information for a given node.
+ :
+ : <p>Within a snapshot, each has a different positional URI. However,
+ : different nodes in different snapshots might have the same URI.</p>
+ :
+ : @param $arg the node for which the positional information URI
+ : should be computed
+ :
+ : @return the opaque positional information URI of the node.
+ :)
+declare function np:node-position(
+ $arg as node()
+) as xs:anyURI external;
+
+(:~
+ : Determines whether the node position given as second argument is
+ : an ancestor of the node position given as first argument.
+ :
+ : If the two positions were obtained within the same snapshot S, then the
+ : result of the function applies to the corresponding nodes as well, that
+ : is, within snapshot S, the second node is an ancestor of the first.
+ : Otherwise, the result of the function does not imply anything about the
+ : positional relationship of the two nodes.
+ :
+ : @param $n-pos1 the potential descendant node position
+ : @param $n-pos2 the potential ancestor node position
+ :
+ : @return true if the node position $n-pos2 is an ancestor of the node position
+ : $n-pos1; false otherwise.
+ :
+ : @error zerr:ZAPI0028 if one of the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:ancestor-of(
+ $pos1 as xs:anyURI,
+ $pos2 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether the node position given as second argument is
+ : a descendant of the node position given as first argument.
+ :
+ : If the two positions were obtained within the same snapshot S, then the
+ : result of the function applies to the corresponding nodes as well, that
+ : is, within snapshot S, the second node is a descendant of the first.
+ : Otherwise, the result of the function does not imply anything about the
+ : positional relationship of the two nodes.
+ :
+ : @param $n-pos1 the potential ancestor node position
+ : @param $n-pos2 the potential descendant node position
+ :
+ : @return true if the node position $n-pos2 is a descendant of the node
+ : position $n-pos1; false otherwise.
+ :
+ : @error zerr:ZAPI0028 if one of the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:descendant-of(
+ $n-pos1 as xs:anyURI,
+ $n-pos2 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether the node position given as second argument belongs
+ : to the subtree rooted at the node position given as first argument.
+ :
+ : If the two positions were obtained within the same snapshot S, then the
+ : result of the function applies to the corresponding nodes as well, that
+ : is, within snapshot S, the second node belongs to the subtree rooted at the
+ : first. Otherwise, the result of the function does not imply anything about
+ : the positional relationship of the two nodes.
+ :
+ : This function differs from np:descendant-of in the way it treats attribute
+ : nodes. np:descendant-of follows the XQuery/XPath specification for the
+ : descendant axis, and as a result, it does not consider attributes as
+ : descendants of any nodes; it will always return false if $n-pos2 was
+ : obtained from an attribute node.In contrast, np:in-subtree-of will return
+ : true if $n-pos2 was obtained from an attribute node that appeared in the
+ : subtree of the node that $n-pos1 was obtained from.
+ :
+ : @param $n-pos1 the potential subtree root node position
+ : @param $n-pos2 the potential node in the subtree node position
+ :
+ : @return true if the node position $n-pos2 belongs to the subtree rooted at
+ : the node position $n-pos1; false otherwise.
+ :
+ : @error zerr:ZAPI0028 if one of the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:in-subtree-of(
+ $n-pos1 as xs:anyURI,
+ $n-pos2 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether the node position given as second argument is
+ : the parent of the node position given as first argument.
+ :
+ : If the two positions were obtained within the same snapshot S, then the
+ : result of the function applies to the corresponding nodes as well, that
+ : is, within snapshot S, the second node is the parent of the first.
+ : Otherwise, the result of the function does not imply anything about the
+ : positional relationship of the two nodes.
+ :
+ : @param $n-pos1 the potential child node position
+ : @param $n-pos2 the potential parent node position
+ :
+ : @return true if the node position $n-pos2 is the parent of the node position
+ : $n-pos1; false otherwise.
+ :
+ : @error zerr:ZAPI0028 if one of the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:parent-of(
+ $n-pos1 as xs:anyURI,
+ $n-pos2 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether the node position given as second argument is
+ : a child of the node position given as first argument.
+ :
+ : If the two positions were obtained within the same snapshot S, then the
+ : result of the function applies to the corresponding nodes as well, that
+ : is, within snapshot S, the second node is a child of the first.
+ : Otherwise, the result of the function does not imply anything about the
+ : positional relationship of the two nodes.
+ :
+ : @param $n-pos1 the potential parent node position
+ : @param $n-pos2 the potential child node position
+ :
+ : @return true if the node position $n-pos2 is a child of the node position
+ : $n-pos1; false otherwise.
+ :
+ : @error zerr:ZAPI0028 if one of the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:child-of(
+ $n-pos1 as xs:anyURI,
+ $n-pos2 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether the node position given as second argument is
+ : an attribute of the node position given as first argument.
+ :
+ : If the two positions were obtained within the same snapshot S, then the
+ : result of the function applies to the corresponding nodes as well, that
+ : is, within snapshot S, the second node is an attribute of the first.
+ : Otherwise, the result of the function does not imply anything about the
+ : positional relationship of the two nodes.
+ :
+ : @param $n-pos1 the potential parent node position
+ : @param $n-pos2 the potential attribute node position
+ :
+ : @return true if the node position $n-pos2 is an attribute of the node
+ : position $n-pos1; false otherwise.
+ :
+ : @error zerr:ZAPI0028 if one of the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:attribute-of(
+ $n-pos1 as xs:anyURI,
+ $n-pos2 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether the node position given as second argument is
+ : a following-sibling of the node position given as first argument.
+ :
+ : If the two positions were obtained within the same snapshot S, then the
+ : result of the function applies to the corresponding nodes as well, that
+ : is, within snapshot S, the second node is a following-sibling of the first.
+ : Otherwise, the result of the function does not imply anything about the
+ : positional relationship of the two nodes.
+ :
+ : @param $n-pos1 the potential preceding-sibling node position
+ : @param $n-pos2 the potential following-sibling node position
+ :
+ : @return true if the node position $n-pos2 is a following-sibling of the node
+ : position $n-pos1; false otherwise.
+ :
+ : @error zerr:ZAPI0028 if one of the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:following-sibling-of(
+ $n-pos1 as xs:anyURI,
+ $n-pos2 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether the node position given as second argument is
+ : a preceding-sibling of the node position given as first argument.
+ :
+ : If the two positions were obtained within the same snapshot S, then the
+ : result of the function applies to the corresponding nodes as well, that
+ : is, within snapshot S, the second node is a preceding-sibling of the first.
+ : Otherwise, the result of the function does not imply anything about the
+ : positional relationship of the two nodes.
+ :
+ : @param $n-pos1 the potential following-sibling node position
+ : @param $n-pos2 the potential preceding-sibling node position
+ :
+ : @return true if the node position $n-pos2 is a preceding-sibling of the node
+ : position $n-pos1; false otherwise.
+ :
+ : @error zerr:ZAPI0028 if one of the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:preceding-sibling-of(
+ $n-pos1 as xs:anyURI,
+ $n-pos2 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether two node positions are siblings.
+ :
+ : If the two positions were obtained within the same snapshot S, then the
+ : result of the function applies to the corresponding nodes as well, that
+ : is, within snapshot S, the second node is a sibling of the first.
+ : Otherwise, the result of the function does not imply anything about the
+ : positional relationship of the two nodes.
+ :
+ : @param $n-pos1 a node position
+ : @param $n-pos2 a node position
+ :
+ : @return true if the two node positions $n-pos1 and $n-pos2 are siblings;
+ : false otherwise.
+ :
+ : @error zerr:ZAPI0028 if one of the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:sibling-of(
+ $n-pos1 as xs:anyURI,
+ $n-pos2 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether the node position given as second argument is
+ : following the node position given as first argument.
+ :
+ : If the two positions were obtained within the same snapshot S, then the
+ : result of the function applies to the corresponding nodes as well, that
+ : is, within snapshot S, the second node is following the first.
+ : Otherwise, the result of the function does not imply anything about the
+ : positional relationship of the two nodes.
+ :
+ : @param $n-pos1 the potential preceding node position
+ : @param $n-pos2 the potential following node position
+ :
+ : @return true if node positions $n-pos1 and $n-pos2 belong to the same XML
+ : tree and $n-pos2 is following the node position $n-pos1; false
+ : otherwise.
+ :
+ : @error zerr:ZAPI0028 if one of the given URI is not a valid node position
+ : computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:following-of(
+ $n-pos1 as xs:anyURI,
+ $n-pos2 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether the node position given as second argument is
+ : following in document order the node position given as first argument.
+ :
+ : If the two positions were obtained within the same snapshot S, then the
+ : result of the function applies to the corresponding nodes as well, that
+ : is, within snapshot S, the second node is following in document order the
+ : first. Otherwise, the result of the function does not imply anything about
+ : the positional relationship of the two nodes.
+ :
+ : @param $n-pos1 the potential preceding node position
+ : @param $n-pos2 the potential following node position
+ :
+ : @return true if the node position $n-pos2 is following in document order the
+ : node position $n-pos1; false otherwise.
+ :
+ : @error zerr:ZAPI0028 if one of the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:following-in-document-order-of(
+ $n-pos1 as xs:anyURI,
+ $n-pos2 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether the node position given as second argument is
+ : preceding the node position given as first argument.
+ :
+ : If the two positions were obtained within the same snapshot S, then the
+ : result of the function applies to the corresponding nodes as well, that
+ : is, within snapshot S, the second node is preceding the first.
+ : Otherwise, the result of the function does not imply anything about the
+ : positional relationship of the two nodes.
+ :
+ : @param $n-pos1 the potential following node position
+ : @param $n-pos2 the potential preceding node position
+ :
+ : @return true if node positions $n-pos1 and $n-pos2 belong to the same XML
+ : tree and $n-pos2 is preceding the node position $n-pos1; false
+ : otherwise.
+ :
+ : @error zerr:ZAPI0028 if one of the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:preceding-of(
+ $n-pos1 as xs:anyURI,
+ $n-pos2 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether the node position given as second argument is
+ : preceding in document order the node position given as first argument.
+ :
+ : If the two positions were obtained within the same snapshot S, then the
+ : result of the function applies to the corresponding nodes as well, that
+ : is, within snapshot S, the second node is preceding in document order the
+ : first. Otherwise, the result of the function does not imply anything about
+ : the positional relationship of the two nodes.
+ :
+ : @param $n-pos1 the potential following node position
+ : @param $n-pos2 the potential preceding node position
+ :
+ : @return true if the node position $n-pos2 is preceding in document order the
+ : node position $n-pos1; false otherwise.
+ :
+ : @error zerr:ZAPI0028 if one of the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:preceding-in-document-order-of(
+ $n-pos1 as xs:anyURI,
+ $n-pos2 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Computes the level of a node position in its tree.
+ :
+ : Note: The root node of a tree is at level one.
+ :
+ : The result of the function applies to the corresponding node as well,
+ : that is, within the snapshot in which the position was computed, the node
+ : level is the returned one.
+ : The result of the function does not imply anything about the
+ : node level in other snapshots.
+ :
+ : @param $n-pos the node position of the node whose level should be
+ : determined.
+ :
+ : @return the level in the tree of the node position $n-pos as xs:integer.
+ :
+ : @error zerr:ZAPI0028 if the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:level(
+ $n-pos as xs:anyURI) as xs:integer external;
+
+(:~
+ : Determines whether a node position corresponds to an attribute node.
+ :
+ : @param $n-pos the potential attribute node position
+ :
+ : @return true if the node position $n-pos corresponds to an attribute;
+ : false otherwise.
+ :
+ : @error zerr:ZAPI0028 if the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:is-attribute(
+ $n-pos1 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether a node position corresponds to a comment node.
+ :
+ : @param $n-pos the potential comment node position
+ :
+ : @return true if the node position $n-pos corresponds to an comment;
+ : false otherwise.
+ :
+ : @error zerr:ZAPI0028 if the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:is-comment(
+ $n-pos1 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether a node position corresponds to a document node.
+ :
+ : @param $n-pos the potential document node position
+ :
+ : @return true if the node position $n-pos corresponds to a document;
+ : false otherwise.
+ :
+ : @error zerr:ZAPI0028 if the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:is-document(
+ $n-pos1 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether a node position corresponds to an element node.
+ :
+ : @param $n-pos the potential element node position
+ :
+ : @return true if the node position $n-pos corresponds to an element;
+ : false otherwise.
+ :
+ : @error zerr:ZAPI0028 if the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:is-element(
+ $n-pos1 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether a node position corresponds to an processing-instruction
+ : node.
+ :
+ : @param $n-pos the potential processing-instruction node position
+ :
+ : @return true if the node position $n-pos corresponds to a processing
+ : instruction; false otherwise.
+ :
+ : @error zerr:ZAPI0028 if the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:is-processing-instruction(
+ $n-pos1 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether a node position corresponds to a text node.
+ :
+ : @param $n-pos the potential text node position
+ :
+ : @return true if the node position $n-pos corresponds to a text;
+ : false otherwise.
+ :
+ : @error zerr:ZAPI0028 if the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:is-text(
+ $n-pos1 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether two node positions belong to the same tree.
+ :
+ : If the two positions were obtained within the same snapshot S, then the
+ : result of the function applies to the corresponding nodes as well, that
+ : is, within snapshot S, the two nodes belong to the same tree.
+ : Otherwise, the result of the function does not imply anything about
+ : the positional relationship of the two nodes.
+ :
+ : @param $n-pos1 a node position
+ : @param $n-pos2 a node position
+ :
+ : @return true if the two nodes whose node positions are $n-pos1
+ : and $n-pos2 belong to the same tree.
+ :
+ : @error zerr:ZAPI0028 if one of the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:in-same-tree-of(
+ $n-pos1 as xs:anyURI,
+ $n-pos2 as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether a node position belongs to a collection.
+ :
+ : @param $n-pos the node position
+ :
+ : @return true if the node position $n-pos
+ : belongs to a collection; false otherwise.
+ :
+ : @error zerr:ZAPI0028 if the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:in-collection(
+ $n-pos as xs:anyURI) as xs:boolean external;
+
+(:~
+ : Determines whether two node positions belong to the same collection.
+ :
+ : If the two positions were obtained within the same snapshot S, then the
+ : result of the function applies to the corresponding nodes as well, that
+ : is, within snapshot S, the two nodes belong to the same collection.
+ : Otherwise, the result of the function does not imply anything about
+ : the positional relationship of the two nodes.
+ :
+ : @param $n-pos1 a node position
+ : @param $n-pos2 a node position
+ :
+ : @return true if the two nodes whose node positions are $n-pos1
+ : and $n-pos2 belong to the same collection.
+ :
+ : @error zerr:ZAPI0028 if one of the given URI is not a valid node
+ : position computed by the <tt>np:node-position</tt> function.
+ :)
+declare function np:in-same-collection-of(
+ $n-pos1 as xs:anyURI,
+ $n-pos2 as xs:anyURI) as xs:boolean external;
=== modified file 'modules/com/zorba-xquery/www/modules/pregenerated/errors.xq'
--- modules/com/zorba-xquery/www/modules/pregenerated/errors.xq 2011-10-19 15:28:51 +0000
+++ modules/com/zorba-xquery/www/modules/pregenerated/errors.xq 2011-11-04 19:40:32 +0000
@@ -549,6 +549,10 @@
(:~
:)
+declare variable $zerr:ZDST0025 as xs:QName := fn:QName($zerr:NS, "zerr:ZDST0025");
+
+(:~
+:)
declare variable $zerr:ZDST0026 as xs:QName := fn:QName($zerr:NS, "zerr:ZDST0026");
(:~
@@ -664,14 +668,6 @@
(:~
:)
-declare variable $zerr:ZSTR0005 as xs:QName := fn:QName($zerr:NS, "zerr:ZSTR0005");
-
-(:~
-:)
-declare variable $zerr:ZSTR0006 as xs:QName := fn:QName($zerr:NS, "zerr:ZSTR0006");
-
-(:~
-:)
declare variable $zerr:ZSTR0007 as xs:QName := fn:QName($zerr:NS, "zerr:ZSTR0007");
(:~
=== modified file 'modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq'
--- modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq 2011-08-26 23:36:24 +0000
+++ modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq 2011-11-04 19:40:32 +0000
@@ -22,7 +22,7 @@
:
: <p>This module is part of <a href="../../html/xqddf.html">Zorba's XQuery Data
: Definition Facility</a>. All the indexes managed by this module
- : have to be pre-declared in the prolog of a module. Please refer to the
+ : have to be pre-declared in the prolog of a library module. Please refer to the
: <a href="../../html/data_lifecycle.html">general documentation</a>
: for more information and examples.</p>
:
@@ -35,7 +35,7 @@
: @see http://www.zorba-xquery.com/modules/store/static/integrity_constraints/dml
: @see <a href="www.zorba-xquery.com_errors.html">http://www.zorba-xquery.com/errors</a>
:
- : @author Nicolae Brinza, Matthias Brantner, David Graf, Till Westmann, Markos Zaharioudakis
+ : @author Zorba Team
:
: @project store/indexes/static
:
@@ -46,29 +46,39 @@
declare namespace ann = "http://www.zorba-xquery.com/annotations";
declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
+
declare option ver:module-version "2.0";
(:~
- : The probe function retrieves the domain nodes associated with a particular
- : search condition, which is presented as a single key tuple. This function
- : is variadic and accepts a variable number of key arguments.
- :
- : The first argument is the QName identifying the index to probe. The remaining
- : arguments specify the search condition, which is given as a number of
- : (optional) atomic items comprising a key tuple. The number of key tuples
- : given must be equal to the number of keys declared for the index.
+ : <p>The probe-index-point-value function retrieves from an index the domain
+ : nodes associated by value equality with a given <strong>search tuple</strong>.
+ : The search tuple consists of a number of <strong>search keys</strong>, where
+ : each search key is either an atomic item or the empty sequence. The number
+ : of search keys given must be equal to the number of keys declared for the
+ : index. Since the number of keys differs from one index to another, this
+ : function is variadic.</p>
+ :
+ : <p>The result of the function is either an error or the set of domain nodes for
+ : which the following xquery expression returns true:</p>
+ :
+ : <pre>
+ : $key1 eq $node/keyExpr1 and ... and $keyM eq $node/keyExprM
+ : </pre>
+ : where keyExpr<sub>i</sub> is the expression specified in the i-th keyspec
+ : of the index.
:
: @param $name The QName of the index to probe
- : @param $key_i any number of key used to probe the index (i.e. the search condition).
- :
- : @return If the index contains an entry with the given key tuple,
- : the associated domain nodes are
- : returned. Otherwise, the empty sequence is returned.
+ : @param $key_i the search keys used to probe the index with. The i-th search
+ : key corresponds to the i-th key expression in the index declaration.
+ : @return The set of domain nodes that satisfy the search condition.
:
: @error zerr:ZDDY0021 if the index with name $name is not declared.
: @error zerr:ZDDY0023 if the index with name $name does not exist.
- : @error zerr:ZDDY0025 if the number of keys passed as arguments
- : does not match the number of keys declared for the index.
+ : @error zerr:ZDDY0025 if the number of search keys passed as arguments is not
+ : the same as the number of keys declared for the index.
+ : @error err:XPTY0004 if a non-empty seach key is given, whose type does not match
+ : the sequence type specified in the corresponding keyspec.
+ :
:)
declare %ann:variadic function idml:probe-index-point-value(
$name as xs:QName,
@@ -76,55 +86,171 @@
(:~
- : The probe function retrieves the domain nodes associated with a particular
- : search condition, which is presented as a range of key tuples.
- : This function accept a variable number of arguments.
- :
- : To describe the semantics of this function, we start by defining the i-th
- : key column of an index as the set of key items produced by evaluating the
- : i-th keyspec of the index for every domain node. Then, the search condition
- : of a range probe can be defined as a number of rangespecs, where a
- : rangespec describes a constraint on the values of a key column. The first
- : rangespec applies to the first key column, the second rangespec to the
- : second key column, etc. The number of rangespecs must be less or equal to
- : the number of keyspecs found in the declaration of the given index.
- : Each rangespec consists of six values (i.e. rangeLowerBound_i,
- : rangeUpperBound_i, rangeHaveLowerBound_i, rangeHaveUpperBound_i,
- : rangeLowerBoundIncluded_i, rangeUpperBoundIncluded_i). Because the
- : function is declared as variadic, several rangespecs can be passed
- : as arguments to the function.
+ : <p>The probe-index-point-general function retrieves from an index the domain
+ : nodes associated by general equality with a given <strong>search sequence
+ : </strong>. The search sequence consists of an arbitrary number of <strong>
+ : search keys</strong>, where each search key is an atomic item. The function
+ : is supported by general indexes only. Its result is either an error or the
+ : set of domain nodes for which the following xquery expression returns true:</p>
+ : <pre>
+ : $keys = $node/keyExpr
+ : </pre>
+ : where keyExpr is the expression specified in the keyspec of the index (remember
+ : that for general indexes, there can be only one keyspec).
+ :
+ : @param $name The QName of the index to probe.
+ : @param $key The search sequence.
+ : @return The set of domain nodes that satisfy the search condition.
+ :
+ : @error zerr:ZDDY0021 if the index with name $name is not declared.
+ : @error zerr:ZDDY0023 if the index with name $name does not exist.
+ : @error zerr:ZDDY0029 if the index is not general.
+ : @error err:XPTY0004 if the search sequence contains a search key, whose
+ : type does not match the sequence type specified in the keyspec of
+ : the index.
+ :)
+declare function idml:probe-index-point-general(
+ $name as xs:QName,
+ $key as xs:anyAtomicType*) as node()* external;
+
+
+(:~
+ : <p>The probe-index-range-value function retrieves the domain nodes associated
+ : by value order-comparison (operators le, lt, ge, gt) with a given <strong>search
+ : box</strong>. The search box is specified as a number M of <strong>rangespecs
+ : </strong>, where each rangespec consists of six values. The number M must be
+ : greater than 0 and less than or equal to the number N of keyspecs found in the
+ : index declaration. If M is less than N, then the "missing" rangespecs are
+ : assumed to have the following value: [(), (), false, false, false, false].
+ : As a result, we can assume that M is equal to N (Remember that for general
+ : indexes, there can be only one IndexKeySpec, and as a result, for general
+ : indexes, M = N = 1). Since the number of keys differs from one index to
+ : another, this function is variadic.</p>
+ :
+ : <p>The i<sup>th</sup> rangespec corresponds to the i<sup>th</sup> keyspec, and
+ : specifies a search condition on the key values that are produced by evaluating
+ : that keyspec for every domain node. Specifically, we define the i<sup>th</sup>
+ : <strong>rangespec result</strong> as the set of domain nodes for which the
+ : following xquery expression returns true:</p>
+ :
+ :<pre>
+ : if ($haveLowerBound-i and $haveUpperBound-i) then
+ : $lowerBound-i lop $node/keyExpr-i and $node/keyExpr-i uop $upperBound-i
+ : else if ($haveLowerBound-i) then
+ : $lowerBound-i lop $node/keyExpr-i
+ : else if ($haveUpperBound-i) then
+ : $node/keyExpr-i uop $upperBound-i
+ : else
+ : fn:true()
+ :</pre>
+ :
+ : <p>where keyExpr-i is the expression specified by the i<sup>th</sup> keyspec
+ : of the index, lop is either the le or the lt operator depending on whether
+ : $lowerBoundsIncluded-i is true or false, and uop is either the le or the
+ : lt operator depending on whether $upperBoundsIncluded-i is true or false.</p>
+ :
+ : <p>The result of the probe-index-range-value function is either an error,
+ : or the intersection of all the rangespec results.</p>
:
: @param $name The QName of the index to probe
- : @param $rangeLowerBound1 The lower bound in a range of key values.
- : @param $rangeUpperBound1 The upper bound in a range of key values.
- : @param $rangeHaveLowerBound If false, then there is no lower bound, or
- : equivalently, the lower bound is -INFINITY. Otherwise, the lower
- : bound is the one given by the rangeLowerBound value.
- : @param $rangeHaveUpperBound If false, then there is no upper bound, or
- : equivalently, the upper bound is +INFINITY. Otherwise, the upper
- : bound is the one given by the rangeUpperBound value.
- : @param $rangeLowerBoundIncluded If false, then the range is open from below,
- : i.e., the rangeLowerBound value is not considered part of the
- : range. Otherwise, the range is closed from below, i.e., the
- : rangeLowerBound value is part of the range.
- : @param $rangeUpperBoundIncluded If false, then the range is open from above,
- : i.e., the rangeUpperBound value is not considered part of the
- : range. Otherwise, the range is closed from above, i.e., the
- : rangeUpperBound value is part of the range.
- : @return The sequence of domain nodes matching this range probe.
+ : @param $lowerBound-i The lower bound in a range of key values.
+ : @param $upperBound-i The upper bound in a range of key values.
+ : @param $haveLowerBound-i If false, then there is no lower bound, or
+ : equivalently, the lower bound is -INFINITY. Otherwise, the lower
+ : bound is the one given by the lowerBound-i value.
+ : @param $haveUpperBound-i If false, then there is no upper bound, or
+ : equivalently, the upper bound is +INFINITY. Otherwise, the upper
+ : bound is the one given by the upperBound-i value.
+ : @param $lowerBoundIncluded-i If false, then the range is open from below,
+ : i.e., the lowerBound-i value is not considered part of the
+ : range. Otherwise, the range is closed from below, i.e., the
+ : lowerBound-i value is part of the range.
+ : @param $upperBoundIncluded-i If false, then the range is open from above,
+ : i.e., the upperBound-i value is not considered part of the
+ : range. Otherwise, the range is closed from above, i.e., the
+ : upperBound-i value is part of the range.
+ : @return The set of domain nodes that satisfy the search condition.
:
: @error zerr:ZDDY0021 if the index with name $name is not declared.
: @error zerr:ZDDY0023 if the index with name $name does not exist.
: @error zerr:ZDDY0025 if the number of rangespecs passed as arguments
- : does not match the number of keys declared for the index.
- :)
-declare %ann:variadic function idml:probe-index-range-value($name as xs:QName,
- $rangeLowerBound1 as xs:anyAtomicType?,
- $rangeUpperBound1 as xs:anyAtomicType?,
- $rangeHaveLowerBound1 as xs:boolean,
- $rangeHaveupperBound1 as xs:boolean,
- $rangeLowerBoundIncluded1 as xs:boolean,
- $rangeupperBoundIncluded1 as xs:boolean) as node()* external;
+ : is zero or greater than the number of keys declared for the index.
+ : @error zerr:ZDDY0026 if the index is not a range index.
+ : @error err:XPTY0004 if $haveLowerBound-i is true and $lowerBound-i is an
+ : atomic item whose type does not match the sequence type specified
+ : by the i<sup>th</sup> keyspec, or $haveUpperBound-i is true and
+ : $upperBound-i is an atomic item whose type does not match the
+ : sequence type specified by the i<sup>th</sup> keyspec.
+ : @error zerr:ZDDY0034 if (a) the index is general (in which case there is
+ : only one rangespac), (b) the index is untyped, (c) there is both a
+ : lower and an upper bound, and (d) if T1 and T2 are the types of the
+ : lower and upper bound, neither T1 is a subtype of T2 nor T2 is a
+ : subtype of T1.
+ :)
+declare %ann:variadic function idml:probe-index-range-value(
+ $name as xs:QName,
+ $lowerBound-i as xs:anyAtomicType?,
+ $upperBound-i as xs:anyAtomicType?,
+ $haveLowerBound-i as xs:boolean,
+ $haveUpperBound-i as xs:boolean,
+ $lowerBoundIncluded-i as xs:boolean,
+ $upperBoundIncluded-i as xs:boolean) as node()* external;
+
+
+(:~
+ : <p>The probe-index-range-general function retrieves the domain nodes associated
+ : by general order-comparison (operators <=, <, >=, >) with one or two
+ : <strong>search sequences</strong>. Each search sequence consists of an
+ : arbitrary number of <strong>search keys</strong>, where each search key is
+ : an atomic item. This method is supported by general range indexes only. Its
+ : result is either an error or the set of domain nodes for which the following
+ : xquery expression returns true:</p>
+ :
+ : <pre>
+ : if ($haveLowerBound and $haveUpperBound) then
+ : $lowerBoundKeys lop $node/keyExpr and $node/keyExpr uop $upperBoundKeys
+ : else if ($haveLowerBound) then
+ : $lowerBoundKeys lop $node/keyExpr
+ : else if ($haveUpperBound) then
+ : $node/keyExpr uop $upperBoundKeys
+ : else
+ : fn:true()
+ : </pre>
+ :
+ : <p>where keyExpr is the expression specified in the keyspec of the index,
+ : lop is either the <= or the < operator depending on whether
+ : $lowerBoundsIncluded is true or false, and uop is either the <= or the
+ : < operator depending on whether $upperBoundsIncluded is true or false</p>.
+ :
+ : @param $name The QName of the index to probe.
+ : @param $lowerBound The lower bound search sequence.
+ : @param $upperBound The upper bound search sequence.
+ : @param $haveLowerBound Whether a lower bound search sequence exists or not.
+ : @param $haveUpperBound Whether an upper bound search sequence exists or not.
+ : @param $lowerBoundIncluded Whether to use the <= or the < operator when
+ : comparing a search key from $lowerBound with an index key.
+ : @param $upperBoundIncluded Whether to use the <= or the < operator when
+ : comparing an index key with a search key from $upperBound.
+ : @return The set of domain nodes that satisfy the search condition
+ :
+ : @error zerr:ZDDY0021 if the index with name $name is not declared.
+ : @error zerr:ZDDY0023 if the index with name $name does not exist.
+ : @error zerr:ZDDY0030 if the index is not a general range index.
+ : @error err:XPTY0004 if $haveLowerBound is true and $lowerBoundKeys constains
+ : an atomic item whose type does not match the sequence type specified by the
+ : index keyspec, or $haveUpperBound is true and $upperBoundKeys contains an
+ : atomic item whose type does not match the sequence type specified by the
+ : index keyspec.
+ :)
+declare function idml:probe-index-range-general(
+ $name as xs:QName,
+ $lowerBound as xs:anyAtomicType*,
+ $upperBound as xs:anyAtomicType*,
+ $haveLowerBound as xs:boolean,
+ $haveUpperBound as xs:boolean,
+ $lowerBoundIncluded as xs:boolean,
+ $upperBoundIncluded as xs:boolean) as node()* external;
+
(:~
: The refresh-index function is an updating function which updates
@@ -136,6 +262,7 @@
: @return The result of the function is an empty XDM instance and a
: pending update list which, when applied, refreshes the contents
: of the index.that consists of a
+ :
: @error zerr:ZDDY0021 if the index with name $name is not declared.
: @error zerr:ZDDY0023 if the index with name $name does not exist.
:)
=== modified file 'modules/com/zorba-xquery/www/modules/xml.xq' (properties changed: +x to -x)
=== modified file 'modules/com/zorba-xquery/www/modules/xqdoc2xhtml/index.xq'
--- modules/com/zorba-xquery/www/modules/xqdoc2xhtml/index.xq 2011-10-19 05:09:31 +0000
+++ modules/com/zorba-xquery/www/modules/xqdoc2xhtml/index.xq 2011-11-04 19:40:32 +0000
@@ -1154,7 +1154,7 @@
: @return the XHTML for the module annotations.
:)
declare %private function xqdoc2html:annotations-module($comment) {
- let $annotations := $comment/xqdoc:*[not((local-name(.) = ("description", "param", "return", "error", "deprecated", "see", "library", "project", "custom")))]
+ let $annotations := $comment/xqdoc:*[not((local-name(.) = ("description", "param", "return", "error", "deprecated", "see", "project", "custom")))]
return
for $annotation in $annotations
let $annName := local-name($annotation)
@@ -1195,7 +1195,7 @@
declare %private function xqdoc2html:module-dependencies(
$xqdoc) {
if (fn:count($xqdoc/xqdoc:imports/xqdoc:import) > 0 or
- fn:count($xqdoc/xqdoc:module/xqdoc:comment/xqdoc:*[(local-name(.) = ("library"))]) > 0) then
+ fn:count($xqdoc/xqdoc:module/xqdoc:comment/xqdoc:custom[@tag="library"]) > 0) then
(<div class="section"><span id="module_dependencies">Module Dependencies</span></div>,
xqdoc2html:imports($xqdoc))
else
@@ -1238,10 +1238,10 @@
}
</ul></p>
else (),
- if (fn:count($xqdoc/xqdoc:module/xqdoc:comment/xqdoc:*[(local-name(.) = ("library"))]) > 0) then
+ if (fn:count($xqdoc/xqdoc:module/xqdoc:comment/xqdoc:custom[@tag="library"]) > 0) then
<p>External C++ library dependencies:<ul>
{
- for $library in $xqdoc/xqdoc:module/xqdoc:comment/xqdoc:*[(local-name(.) = ("library"))]
+ for $library in $xqdoc/xqdoc:module/xqdoc:comment/xqdoc:custom[@tag="library"]
return
<li>{$library/node()}</li>
}
=== modified file 'src/annotations/annotations.cpp'
--- src/annotations/annotations.cpp 2011-08-11 17:19:25 +0000
+++ src/annotations/annotations.cpp 2011-11-04 19:40:32 +0000
@@ -15,21 +15,17 @@
*/
#include "stdafx.h"
-#include <cmath>
-
#include "annotations/annotations.h"
-#include "system/globalenv.h"
#include "store/api/item.h"
#include "store/api/item_factory.h"
-#include "context/static_context.h"
-#include "context/static_context_consts.h"
#include "compiler/expression/expr.h"
#include "zorbaserialization/serialization_engine.h"
#include "diagnostics/assert.h"
+#include "diagnostics/util_macros.h"
#include "system/globalenv.h"
@@ -38,90 +34,270 @@
SERIALIZABLE_CLASS_VERSIONS(AnnotationInternal)
END_SERIALIZABLE_CLASS_VERSIONS(AnnotationInternal)
-SERIALIZABLE_CLASS_VERSIONS(AnnotationLiteral)
-END_SERIALIZABLE_CLASS_VERSIONS(AnnotationLiteral)
-
SERIALIZABLE_CLASS_VERSIONS(AnnotationList)
END_SERIALIZABLE_CLASS_VERSIONS(AnnotationList);
-/*******************************************************************************
-
-********************************************************************************/
-AnnotationInternal::AnnotationInternal(const store::Item_t& aExpandedQName)
+std::vector<store::Item_t>
+AnnotationInternal::theAnnotId2NameMap;
+
+ItemHandleHashMap<AnnotationInternal::AnnotationId>
+AnnotationInternal::theAnnotName2IdMap(0, NULL, 64, false);
+
+std::vector<AnnotationInternal::RuleBitSet>
+AnnotationInternal::theRuleSet;
+
+
+/*******************************************************************************
+ Static method, called from GlobalEnvironment::init()
+********************************************************************************/
+void AnnotationInternal::createBuiltIn()
+{
+ store::Item_t qname;
+ AnnotationId id;
+
+ theAnnotId2NameMap.resize(zann_end);
+
+ //
+ // W3C annotations
+ //
+ GENV_ITEMFACTORY->createQName(qname, static_context::W3C_FN_NS, "fn", "public");
+ id = fn_public;
+ theAnnotId2NameMap[id] = qname;
+ theAnnotName2IdMap.insert(qname, id);
+
+ GENV_ITEMFACTORY->createQName(qname, static_context::W3C_FN_NS, "fn", "private");
+ id = fn_private;
+ theAnnotId2NameMap[id] = qname;
+ theAnnotName2IdMap.insert(qname, id);
+
+#define ZANN(a, b) \
+ GENV_ITEMFACTORY->createQName(qname, ZORBA_ANNOTATIONS_NS, "", #a); \
+ id = zann_##b; \
+ theAnnotId2NameMap[id] = qname; \
+ theAnnotName2IdMap.insert(qname, id);
+
+
+ //
+ // Zorba annotations - deterministic/nondeterministic
+ //
+ ZANN(deterministic, deterministic);
+ ZANN(nondeterministic, nondeterministic);
+
+ //
+ // Zorba annotations - xquery scripting
+ //
+ ZANN(assignable, assignable);
+ ZANN(nonassignable, nonassignable);
+
+ ZANN(sequential, sequential);
+ ZANN(nonsequential, nonsequential);
+
+ //
+ // Zorba annotations - misc
+ //
+ ZANN(variadic, variadic);
+
+ ZANN(streamable, streamable);
+
+ //
+ // Zorba annotations - xqddf
+ //
+ ZANN(unique, unique);
+ ZANN(nonunique, nonunique);
+
+ ZANN(value-equality, value_equality);
+ ZANN(general-equality, general_equality);
+ ZANN(value-range, value_range);
+ ZANN(general-range, general_range);
+
+ ZANN(automatic, automatic);
+ ZANN(manual, manual);
+
+ ZANN(mutable, mutable);
+ ZANN(queue, queue);
+ ZANN(append-only, append_only);
+ ZANN(const, const);
+
+ ZANN(ordered, ordered);
+ ZANN(unordered, unordered);
+
+ ZANN(read-only-nodes, read_only_nodes);
+ ZANN(mutable-nodes, mutable_nodes);
+
+#undef ZANN
+
+ // create a set of rules to detect conflicts between annotations
+#define ZANN(a) \
+ ( 1 << static_cast<uint64_t>(AnnotationInternal::a) )
+
+ theRuleSet.push_back(
+ ZANN(zann_unique) |
+ ZANN(zann_nonunique));
+
+ theRuleSet.push_back(
+ ZANN(zann_value_equality) |
+ ZANN(zann_general_equality) |
+ ZANN(zann_value_range) |
+ ZANN(zann_general_range));
+
+ theRuleSet.push_back(
+ ZANN(zann_automatic) |
+ ZANN(zann_manual));
+
+ theRuleSet.push_back(
+ ZANN(zann_mutable) |
+ ZANN(zann_queue) |
+ ZANN(zann_append_only) |
+ ZANN(zann_const));
+
+ theRuleSet.push_back(
+ ZANN(zann_ordered) |
+ ZANN(zann_unordered));
+
+ theRuleSet.push_back(
+ ZANN(zann_assignable) |
+ ZANN(zann_nonassignable));
+
+ theRuleSet.push_back(
+ ZANN(zann_deterministic) |
+ ZANN(zann_nondeterministic));
+
+ theRuleSet.push_back(
+ ZANN(zann_sequential) |
+ ZANN(zann_nonsequential));
+
+ theRuleSet.push_back(
+ ZANN(fn_private) |
+ ZANN(fn_public));
+
+ theRuleSet.push_back(
+ ZANN(zann_unordered) |
+ ZANN(zann_queue));
+
+ theRuleSet.push_back(
+ ZANN(zann_unordered) |
+ ZANN(zann_append_only));
+
+ theRuleSet.push_back(
+ ZANN(zann_queue) |
+ ZANN(zann_append_only));
+
+ theRuleSet.push_back(
+ ZANN(zann_read_only_nodes) |
+ ZANN(zann_mutable_nodes));
+#undef ZANN
+}
+
+
+/*******************************************************************************
+ Static method, called from GlobalEnvironment::init()
+********************************************************************************/
+void AnnotationInternal::destroyBuiltIn()
+{
+ theAnnotId2NameMap.clear();
+ theAnnotName2IdMap.clear();
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+AnnotationInternal::AnnotationId AnnotationInternal::lookup(
+ const store::Item_t& qname)
+{
+ ItemHandleHashMap<AnnotationId>::iterator ite = theAnnotName2IdMap.find(qname);
+
+ if (ite == theAnnotName2IdMap.end())
+ return zann_end;
+
+ return (*ite).second;
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+store::Item* AnnotationInternal::lookup(AnnotationInternal::AnnotationId id)
+{
+ assert(id < zann_end);
+ assert(id < theAnnotId2NameMap.size());
+
+ return theAnnotId2NameMap[id].getp();
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+AnnotationInternal::AnnotationInternal(const store::Item_t& qname)
:
- theQName(aExpandedQName)
+ theId(zann_end),
+ theQName(qname)
{
+ ItemHandleHashMap<AnnotationId>::iterator ite = theAnnotName2IdMap.find(qname);
+ if (ite != theAnnotName2IdMap.end())
+ theId = (*ite).second;
}
+/*******************************************************************************
+
+********************************************************************************/
AnnotationInternal::AnnotationInternal(
- const store::Item_t& aExpandedQName,
- const std::vector<AnnotationLiteral_t>& aLiteralList)
+ const store::Item_t& qname,
+ std::vector<store::Item_t>& literals)
:
- theQName(aExpandedQName),
- theLiteralList(aLiteralList)
+ theId(zann_end),
+ theQName(qname)
{
+ theLiterals.swap(literals);
+
+ ItemHandleHashMap<AnnotationId>::iterator ite = theAnnotName2IdMap.find(qname);
+ if (ite != theAnnotName2IdMap.end())
+ theId = (*ite).second;
}
+/*******************************************************************************
+
+********************************************************************************/
void AnnotationInternal::serialize(::zorba::serialization::Archiver& ar)
{
+ SERIALIZE_ENUM(AnnotationId, theId);
ar & theQName;
- ar & theLiteralList;
+ ar & theLiterals;
}
+/*******************************************************************************
+
+********************************************************************************/
const store::Item* AnnotationInternal::getQName() const
{
return theQName.getp();
}
-unsigned int AnnotationInternal::getNumLiterals() const
-{
- return (unsigned int)theLiteralList.size();
-}
-
-
-const AnnotationLiteral* AnnotationInternal::getLiteral(unsigned int index) const
-{
- if (index < theLiteralList.size())
- return theLiteralList[index];
- else
- return NULL;
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-void AnnotationLiteral::serialize(::zorba::serialization::Archiver& ar)
-{
- ar & theLiteral;
-}
-
-
-AnnotationLiteral::AnnotationLiteral(const store::Item_t& aLiteralValue)
- : theLiteral(aLiteralValue)
-{
-}
-
-
-store::Item_t AnnotationLiteral::getLiteralItem() const
-{
- return theLiteral;
-}
-
-
-AnnotationInternal* AnnotationList::getAnnotation(unsigned int index) const
-{
- if (index < theAnnotationList.size())
- return theAnnotationList[index].getp();
- else
- return NULL;
-}
-
+/*******************************************************************************
+
+********************************************************************************/
+csize AnnotationInternal::getNumLiterals() const
+{
+ return theLiterals.size();
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+store::Item* AnnotationInternal::getLiteral(csize index) const
+{
+ if (index < theLiterals.size())
+ return theLiterals[index].getp();
+ else
+ return NULL;
+}
/*******************************************************************************
@@ -152,38 +328,45 @@
/*******************************************************************************
********************************************************************************/
+AnnotationInternal* AnnotationList::getAnnotation(csize index) const
+{
+ if (index < theAnnotationList.size())
+ return theAnnotationList[index].getp();
+ else
+ return NULL;
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
void AnnotationList::push_back(
- const store::Item_t& aExpQName,
- const std::vector<rchandle<const_expr> >& aLiterals)
+ const store::Item_t& qname,
+ const std::vector<rchandle<const_expr> >& literals)
{
- std::vector<AnnotationLiteral_t> lLiterals;
+ std::vector<store::Item_t> lLiterals;
- for (std::vector<rchandle<const_expr> >::const_iterator it = aLiterals.begin();
- it != aLiterals.end();
+ for (std::vector<rchandle<const_expr> >::const_iterator it = literals.begin();
+ it != literals.end();
++it)
{
- lLiterals.push_back(new AnnotationLiteral((*it)->get_val()));
+ lLiterals.push_back((*it)->get_val());
}
- theAnnotationList.push_back(new AnnotationInternal(aExpQName, lLiterals));
+ theAnnotationList.push_back(new AnnotationInternal(qname, lLiterals));
}
/*******************************************************************************
********************************************************************************/
-bool AnnotationList::contains(const store::Item_t& aSearchQName) const
+bool AnnotationList::contains(AnnotationInternal::AnnotationId id) const
{
- if (aSearchQName.getp() == NULL)
- return false;
-
- // sequential search might not be the most efficient but
- // how many annotations might a function or variable have? 5?
- for (ListConstIter_t lIter = theAnnotationList.begin();
- lIter != theAnnotationList.end();
- ++lIter)
+ for (ListConstIter_t ite = theAnnotationList.begin();
+ ite != theAnnotationList.end();
+ ++ite)
{
- if ((*lIter)->getQName()->equals(aSearchQName))
+ if ((*ite)->getId() == id)
return true;
}
@@ -196,232 +379,61 @@
********************************************************************************/
void AnnotationList::checkConflictingDeclarations(const QueryLoc& loc) const
{
- static_context& lCtx = GENV_ROOT_STATIC_CONTEXT;
-
// make sure we don't have more annotations then max 64 bit
- assert( static_cast<uint64_t>(StaticContextConsts::zann_end) <
+ assert( static_cast<uint64_t>(AnnotationInternal::zann_end) <
std::numeric_limits<uint64_t>::max() );
RuleBitSet lCurrAnn;
// mark and detect duplicates
- for (ListConstIter_t lIter = theAnnotationList.begin();
- lIter != theAnnotationList.end();
- ++lIter)
+ for (ListConstIter_t ite = theAnnotationList.begin();
+ ite != theAnnotationList.end();
+ ++ite)
{
- store::Item_t lQName = const_cast<store::Item*>((*lIter)->getQName());
- StaticContextConsts::annotations_t lAnn = lCtx.lookup_ann(lQName);
+ const store::Item* qname = (*ite)->getQName();
+ AnnotationId id = (*ite)->getId();
// detect duplicate annotations (if we "know" them)
- if ( lAnn != StaticContextConsts::zann_end && lCurrAnn.test( lAnn ) )
+ if (id != AnnotationInternal::zann_end && lCurrAnn.test(id))
{
- throw XQUERY_EXCEPTION(
- err::XQST0106,
- ERROR_PARAMS(
- lQName->getStringValue(),
- ZED(XQST0106_THE_SAME)
- ),
- ERROR_LOC(loc));
+ RAISE_ERROR(err::XQST0106, loc,
+ ERROR_PARAMS(qname->getStringValue(), ZED(XQST0106_THE_SAME)));
}
- lCurrAnn.set( lAnn );
+ lCurrAnn.set(id);
}
// check rules
- for ( std::vector<RuleBitSet>::const_iterator lIter = theRuleSet.begin();
- lIter != theRuleSet.end();
- ++lIter )
+ std::vector<RuleBitSet>::const_iterator ite = AnnotationInternal::theRuleSet.begin();
+ std::vector<RuleBitSet>::const_iterator end = AnnotationInternal::theRuleSet.end();
+
+ for (; ite != end; ++ite)
{
- const RuleBitSet lCurrSet = *lIter;
- if ( ( lCurrAnn & lCurrSet ).count() > 1 )
+ const RuleBitSet& lCurrSet = *ite;
+
+ if ((lCurrAnn & lCurrSet).count() > 1)
{
// build error string to return set of conflicting annotations
std::ostringstream lProblems;
- for ( size_t i = 0, j = 0; i < StaticContextConsts::zann_end; ++i )
+ for (csize i = 0, j = 0; i < AnnotationInternal::zann_end; ++i)
{
- if ( lCurrSet.test( i ) )
+ if (lCurrSet.test(i))
{
- lProblems
- << lCtx.lookup_ann(
- static_cast<StaticContextConsts::annotations_t>(i)
- )->getStringValue()
- << ((j == lCurrSet.count() - 1) ? "" : ", ");
+ AnnotationId id = static_cast<AnnotationId>(i);
+
+ lProblems << AnnotationInternal::lookup(id)->getStringValue()
+ << ((j == lCurrSet.count() - 1) ? "" : ", ");
++j;
}
}
- throw XQUERY_EXCEPTION(
- err::XQST0106,
- ERROR_PARAMS(
- lProblems.str(),
- ZED(XQST0106_CONFLICTING)
- ),
- ERROR_LOC(loc));
+
+ RAISE_ERROR(err::XQST0106, loc,
+ ERROR_PARAMS(lProblems.str(), ZED(XQST0106_CONFLICTING)));
}
}
}
-void AnnotationList::createBuiltIn(static_context* aCtx)
-{
- store::Item_t lTmp;
-
- //
- // W3C annotations
- //
- GENV_ITEMFACTORY->createQName(lTmp, static_context::W3C_FN_NS, "fn", "public");
- aCtx->add_ann(StaticContextConsts::fn_public, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, static_context::W3C_FN_NS, "fn", "private");
- aCtx->add_ann(StaticContextConsts::fn_private, lTmp);
-
- //
- // Zorba annotations - deterministic/nondeterministic
- //
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "deterministic");
- aCtx->add_ann(StaticContextConsts::zann_deterministic, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "nondeterministic");
- aCtx->add_ann(StaticContextConsts::zann_nondeterministic, lTmp);
-
- //
- // Zorba annotations - xquery scripting
- //
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "assignable");
- aCtx->add_ann(StaticContextConsts::zann_assignable, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "nonassignable");
- aCtx->add_ann(StaticContextConsts::zann_nonassignable, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "sequential");
- aCtx->add_ann(StaticContextConsts::zann_sequential, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "nonsequential");
- aCtx->add_ann(StaticContextConsts::zann_nonsequential, lTmp);
-
- //
- // Zorba annotations - misc
- //
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "variadic");
- aCtx->add_ann(StaticContextConsts::zann_variadic, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "streamable");
- aCtx->add_ann(StaticContextConsts::zann_streamable, lTmp);
-
- //
- // Zorba annotations - xqddf
- //
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "unique");
- aCtx->add_ann(StaticContextConsts::zann_unique, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "nonunique");
- aCtx->add_ann(StaticContextConsts::zann_nonunique, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "value-equality");
- aCtx->add_ann(StaticContextConsts::zann_value_equality, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "general-equality");
- aCtx->add_ann(StaticContextConsts::zann_general_equality, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "value-range");
- aCtx->add_ann(StaticContextConsts::zann_value_range, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "general-range");
- aCtx->add_ann(StaticContextConsts::zann_general_range, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "automatic");
- aCtx->add_ann(StaticContextConsts::zann_automatic, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "manual");
- aCtx->add_ann(StaticContextConsts::zann_manual, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "mutable");
- aCtx->add_ann(StaticContextConsts::zann_mutable, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "queue");
- aCtx->add_ann(StaticContextConsts::zann_queue, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "append-only");
- aCtx->add_ann(StaticContextConsts::zann_append_only, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "const");
- aCtx->add_ann(StaticContextConsts::zann_const, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "ordered");
- aCtx->add_ann(StaticContextConsts::zann_ordered, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "unordered");
- aCtx->add_ann(StaticContextConsts::zann_unordered, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "read-only-nodes");
- aCtx->add_ann(StaticContextConsts::zann_read_only_nodes, lTmp);
-
- GENV_ITEMFACTORY->createQName(lTmp, ZORBA_ANNOTATIONS_NS, "", "mutable-nodes");
- aCtx->add_ann(StaticContextConsts::zann_mutable_nodes, lTmp);
-
- // create a set of rules to detect conflicts between annotations
-#define ZANN(a) \
- ( 1 << static_cast<uint64_t>(StaticContextConsts:: a) )
- theRuleSet.push_back(
- ZANN(zann_unique) |
- ZANN(zann_nonunique)
- );
- theRuleSet.push_back(
- ZANN(zann_value_equality) |
- ZANN(zann_general_equality) |
- ZANN(zann_value_range) |
- ZANN(zann_general_range)
- );
- theRuleSet.push_back(
- ZANN(zann_automatic) |
- ZANN(zann_manual)
- );
- theRuleSet.push_back(
- ZANN(zann_mutable) |
- ZANN(zann_queue) |
- ZANN(zann_append_only) |
- ZANN(zann_const)
- );
- theRuleSet.push_back(
- ZANN(zann_ordered) |
- ZANN(zann_unordered)
- );
- theRuleSet.push_back(
- ZANN(zann_assignable) |
- ZANN(zann_nonassignable)
- );
- theRuleSet.push_back(
- ZANN(zann_deterministic) |
- ZANN(zann_nondeterministic)
- );
- theRuleSet.push_back(
- ZANN(zann_sequential) |
- ZANN(zann_nonsequential)
- );
- theRuleSet.push_back(
- ZANN(fn_private) |
- ZANN(fn_public)
- );
- theRuleSet.push_back(
- ZANN(zann_unordered) |
- ZANN(zann_queue)
- );
- theRuleSet.push_back(
- ZANN(zann_unordered) |
- ZANN(zann_append_only)
- );
- theRuleSet.push_back(
- ZANN(zann_queue) |
- ZANN(zann_append_only)
- );
- theRuleSet.push_back(
- ZANN(zann_read_only_nodes) |
- ZANN(zann_mutable_nodes)
- );
-#undef ZANN
-}
-
-std::vector<AnnotationList::RuleBitSet> AnnotationList::theRuleSet;
-
} /* namespace zorba */
/* vim:set et sw=2 ts=2: */
=== modified file 'src/annotations/annotations.h'
--- src/annotations/annotations.h 2011-07-21 01:30:19 +0000
+++ src/annotations/annotations.h 2011-11-04 19:40:32 +0000
@@ -19,39 +19,95 @@
#include <vector>
#include <bitset>
+
#include "common/shared_types.h"
+
#include "compiler/parsetree/parsenodes.h"
+#include "zorbautils/hashmap_itemh.h"
+
namespace zorba
{
-class AnnotationLiteral;
class AnnotationInternal;
class AnnotationList;
typedef rchandle<AnnotationInternal> AnnotationInternal_t;
typedef rchandle<AnnotationList> AnnotationList_t;
-typedef rchandle<AnnotationLiteral> AnnotationLiteral_t;
class const_expr;
/*******************************************************************************
-
+ Annotation ::= "%" EQName ("(" Literal ("," Literal)* ")")?
********************************************************************************/
class AnnotationInternal : public SimpleRCObject
{
friend class AnnotationList;
-protected:
- store::Item_t theQName;
- std::vector<AnnotationLiteral_t> theLiteralList;
-
-public:
- AnnotationInternal(const store::Item_t& aExpandedQName);
+public:
+ enum AnnotationId
+ {
+ fn_public = 0,
+ fn_private,
+ zann_deterministic,
+ zann_nondeterministic,
+ zann_assignable,
+ zann_nonassignable,
+ zann_sequential,
+ zann_nonsequential,
+ zann_variadic,
+ zann_streamable,
+ zann_unique,
+ zann_nonunique,
+ zann_value_equality,
+ zann_general_equality,
+ zann_value_range,
+ zann_general_range,
+ zann_automatic,
+ zann_manual,
+ zann_mutable,
+ zann_queue,
+ zann_append_only,
+ zann_const,
+ zann_ordered,
+ zann_unordered,
+ zann_read_only_nodes,
+ zann_mutable_nodes,
+
+ // must be at the end
+ zann_end
+ };
+
+protected:
+ typedef std::bitset<zann_end + 1> RuleBitSet;
+
+protected:
+ static std::vector<store::Item_t> theAnnotId2NameMap;
+
+ static ItemHandleHashMap<AnnotationId> theAnnotName2IdMap;
+
+ static std::vector<RuleBitSet> theRuleSet;
+
+protected:
+ AnnotationId theId;
+ store::Item_t theQName;
+ std::vector<store::Item_t> theLiterals;
+
+public:
+ static void createBuiltIn();
+
+ static void destroyBuiltIn();
+
+ static AnnotationId lookup(const store::Item_t& qname);
+
+ static store::Item* lookup(AnnotationId id);
+
+public:
+ AnnotationInternal(const store::Item_t& qname);
AnnotationInternal(
- const store::Item_t& aExpandedQName,
- const std::vector<AnnotationLiteral_t>& aLiteralList);
+ const store::Item_t& qname,
+ std::vector<store::Item_t>& literals);
public:
SERIALIZABLE_CLASS(AnnotationInternal);
@@ -59,55 +115,37 @@
void serialize(::zorba::serialization::Archiver& ar);
public:
- virtual ~AnnotationInternal() { };
+ ~AnnotationInternal() { };
+
+ AnnotationId getId() const { return theId; }
const store::Item* getQName() const;
- unsigned int getNumLiterals() const;
-
- const AnnotationLiteral* getLiteral(unsigned int index) const;
-};
-
-
-
-/*******************************************************************************
-
-********************************************************************************/
-class AnnotationLiteral : public SimpleRCObject
-{
-protected:
- store::Item_t theLiteral;
-
-public:
- AnnotationLiteral(const store::Item_t& aLiteral);
-
-public:
- SERIALIZABLE_CLASS(AnnotationLiteral);
- SERIALIZABLE_CLASS_CONSTRUCTOR2(AnnotationLiteral, SimpleRCObject)
- void serialize(::zorba::serialization::Archiver& ar);
-
-public:
- virtual ~AnnotationLiteral() {};
-
- store::Item_t getLiteralItem() const;
-};
-
-
-/*******************************************************************************
-
+ csize getNumLiterals() const;
+
+ store::Item* getLiteral(csize index) const;
+};
+
+
+/*******************************************************************************
+ AnnotationList := Annotation*
+
+ Annotation ::= "%" EQName ("(" Literal ("," Literal)* ")")?
********************************************************************************/
class AnnotationList : public SimpleRCObject
{
public:
+ typedef AnnotationInternal::RuleBitSet RuleBitSet;
+
+ typedef AnnotationInternal::AnnotationId AnnotationId;
+
typedef std::vector<AnnotationInternal_t> List_t;
+
typedef List_t::const_iterator ListConstIter_t;
protected:
List_t theAnnotationList;
- typedef std::bitset<StaticContextConsts::zann_end + 1> RuleBitSet;
- static std::vector<RuleBitSet> theRuleSet;
-
public:
SERIALIZABLE_CLASS(AnnotationList);
SERIALIZABLE_CLASS_CONSTRUCTOR2(AnnotationList, SimpleRCObject)
@@ -116,22 +154,19 @@
public:
AnnotationList();
- virtual ~AnnotationList();
-
- size_t size() const { return theAnnotationList.size(); }
-
- AnnotationInternal* getAnnotation(unsigned int index) const;
+ ~AnnotationList();
+
+ csize size() const { return theAnnotationList.size(); }
+
+ AnnotationInternal* getAnnotation(csize index) const;
void push_back(
- const store::Item_t& aExpQName,
- const std::vector<rchandle<const_expr> >& aLiterals);
+ const store::Item_t& qname,
+ const std::vector<rchandle<const_expr> >& literals);
- bool contains(const store::Item_t& aSearchQName) const;
+ bool contains(AnnotationInternal::AnnotationId id) const;
void checkConflictingDeclarations(const QueryLoc& loc) const;
-
-public:
- static void createBuiltIn(static_context* aCtx);
};
=== modified file 'src/api/annotationimpl.cpp'
--- src/api/annotationimpl.cpp 2011-06-14 17:26:33 +0000
+++ src/api/annotationimpl.cpp 2011-11-04 19:40:32 +0000
@@ -50,7 +50,7 @@
if (i >= theAnnotation->getNumLiterals())
return Item(NULL);
- Item lItem(theAnnotation->getLiteral(i)->getLiteralItem().getp());
+ Item lItem(theAnnotation->getLiteral(i));
return lItem;
}
=== modified file 'src/api/collectionimpl.cpp'
--- src/api/collectionimpl.cpp 2011-09-15 13:11:51 +0000
+++ src/api/collectionimpl.cpp 2011-11-04 19:40:32 +0000
@@ -444,17 +444,10 @@
{
store::Annotation_t lSAnn = *lIter;
- std::vector<AnnotationLiteral_t> lILiterals;
- std::vector<store::Item_t>::const_iterator lLiteral;
- for (lLiteral = lSAnn->theLiterals.begin();
- lLiteral != lSAnn->theLiterals.end();
- ++lLiteral)
- {
- lILiterals.push_back(new AnnotationLiteral(*lLiteral));
- }
+ std::vector<store::Item_t> lLiterals = lSAnn->theLiterals;
aAnnotations.push_back(
- new AnnotationImpl(new AnnotationInternal(lSAnn->theName, lILiterals)));
+ new AnnotationImpl(new AnnotationInternal(lSAnn->theName, lLiterals)));
}
}
ZORBA_DM_CATCH
=== modified file 'src/compiler/codegen/plan_visitor.cpp'
--- src/compiler/codegen/plan_visitor.cpp 2011-09-16 19:36:18 +0000
+++ src/compiler/codegen/plan_visitor.cpp 2011-11-04 19:40:32 +0000
@@ -199,7 +199,10 @@
/*******************************************************************************
-
+ A FlworClauseVarMap is created for each flwor clause that defines variables.
+ If M is such a clause, then for each variable Vi defined by M, theVarExprs[i]
+ and theVarRebinds[i] contain an entry for Vi. theVarExprs[i] contains the
+ var_expr representing the Vi definition.
********************************************************************************/
class FlworClauseVarMap : public SimpleRCObject
{
@@ -207,7 +210,7 @@
bool theIsGeneral;
const flwor_clause * theClause;
- std::vector<const var_expr*> theVarExprs;
+ std::vector<var_expr*> theVarExprs;
std::vector<VarRebind_t> theVarRebinds;
public:
@@ -222,8 +225,8 @@
long find_var(const var_expr* var) const
{
- ulong numVars = (ulong)theVarExprs.size();
- for (ulong i = 0; i < numVars; ++i)
+ csize numVars = theVarExprs.size();
+ for (csize i = 0; i < numVars; ++i)
{
if (theVarExprs[i] == var)
return i;
@@ -759,7 +762,7 @@
{
varRebind = new VarRebind;
- clauseVarMap->theVarExprs.push_back(&var);
+ clauseVarMap->theVarExprs.push_back(const_cast<var_expr*>(&var));
clauseVarMap->theVarRebinds.push_back(varRebind);
varRebind->theInputVar = varIter;
@@ -1189,14 +1192,14 @@
const group_clause::rebind_list_t& grouping_vars = gbc->get_grouping_vars();
const group_clause::rebind_list_t& nongrouping_vars = gbc->get_nongrouping_vars();
- for (unsigned i = 0; i < grouping_vars.size(); i++)
+ for (unsigned i = 0; i < grouping_vars.size(); ++i)
{
VarRebind_t varRebind = new VarRebind;
clauseVarMap->theVarExprs.push_back(grouping_vars[i].second.getp());
clauseVarMap->theVarRebinds.push_back(varRebind);
}
- for (unsigned i = 0; i < nongrouping_vars.size(); i++)
+ for (unsigned i = 0; i < nongrouping_vars.size(); ++i)
{
VarRebind_t varRebind = new VarRebind;
clauseVarMap->theVarExprs.push_back(nongrouping_vars[i].second.getp());
@@ -1363,22 +1366,17 @@
xqtref_t colType = colExpr->get_return_type();
- if (TypeOps::is_subtype(tm, *colType, *rtm.STRING_TYPE_STAR, loc) ||
- TypeOps::is_subtype(tm, *colType, *rtm.DOUBLE_TYPE_STAR, loc) ||
- TypeOps::is_subtype(tm, *colType, *rtm.FLOAT_TYPE_STAR, loc) ||
- TypeOps::is_subtype(tm, *colType, *rtm.LONG_TYPE_STAR, loc) ||
- TypeOps::is_subtype(tm, *colType, *rtm.UNSIGNED_LONG_TYPE_STAR, loc) ||
- TypeOps::is_equal(tm,
- *TypeOps::prime_type(tm, *colType),
- *rtm.DECIMAL_TYPE_ONE,
- loc) ||
- TypeOps::is_equal(tm,
- *TypeOps::prime_type(tm, *colType),
- *rtm.INTEGER_TYPE_ONE,
- loc) ||
- TypeOps::is_subtype(tm, *colType, *rtm.DATE_TYPE_STAR, loc) ||
- TypeOps::is_subtype(tm, *colType, *rtm.TIME_TYPE_STAR, loc) ||
- TypeOps::is_subtype(tm, *colType, *rtm.DATETIME_TYPE_STAR, loc))
+ if (colType->type_kind() == XQType::NODE_TYPE_KIND)
+ {
+ colType = static_cast<const NodeXQType*>(colType.getp())->get_content_type();
+ }
+
+ if (colType != NULL &&
+ TypeOps::is_subtype(tm, *colType, *rtm.ANY_ATOMIC_TYPE_STAR, loc) &&
+ !TypeOps::is_equal(tm,
+ *TypeOps::prime_type(tm, *colType),
+ *rtm.ANY_ATOMIC_TYPE_ONE,
+ loc))
{
return true;
}
@@ -1669,7 +1667,7 @@
if (c.get_kind() != flwor_clause::where_clause)
{
ZORBA_ASSERT(!theClauseStack.empty());
- ulong stackSize = (ulong)theClauseStack.size();
+ csize stackSize = theClauseStack.size();
clauseVarMap = theClauseStack[stackSize-1];
theClauseStack.resize(stackSize - 1);
@@ -1878,9 +1876,12 @@
std::vector<flwor::NonGroupingSpec>& ngspecs)
{
const group_clause* gbc = static_cast<const group_clause*>(clauseVarMap->theClause);
+
const group_clause::rebind_list_t& gvars = gbc->get_grouping_vars();
const group_clause::rebind_list_t& ngvars = gbc->get_nongrouping_vars();
+
const std::vector<std::string>& collations = gbc->get_collations();
+
long numVars = (long)(gvars.size() + ngvars.size());
long numGroupVars = (long)gvars.size();
long i = numVars - 1;
@@ -1900,7 +1901,12 @@
const std::vector<PlanIter_t>& varRefs = varRebind->theOutputVarRefs;
- gspecs.push_back(flwor::GroupingSpec(pop_itstack(), varRefs, collations[i]));
+ bool fastComparison = nativeColumnSort(clauseVarMap->theVarExprs[i]);
+
+ gspecs.push_back(flwor::GroupingSpec(pop_itstack(),
+ varRefs,
+ collations[i],
+ fastComparison));
}
}
=== modified file 'src/compiler/expression/flwor_expr.cpp'
--- src/compiler/expression/flwor_expr.cpp 2011-08-15 14:17:09 +0000
+++ src/compiler/expression/flwor_expr.cpp 2011-11-04 19:40:32 +0000
@@ -616,26 +616,26 @@
theNonGroupVars(ngvars),
theCollations(collations)
{
- ulong numGVars = (ulong)theGroupVars.size();
- ulong numNGVars = (ulong)theNonGroupVars.size();
+ csize numGVars = theGroupVars.size();
+ csize numNGVars = theNonGroupVars.size();
- for (ulong i = 0; i < numGVars; ++i)
+ for (csize i = 0; i < numGVars; ++i)
theGroupVars[i].second->set_flwor_clause(this);
- for (ulong i = 0; i < numNGVars; ++i)
+ for (csize i = 0; i < numNGVars; ++i)
theNonGroupVars[i].second->set_flwor_clause(this);
}
group_clause::~group_clause()
{
- ulong numGVars = (ulong)theGroupVars.size();
- ulong numNGVars = (ulong)theNonGroupVars.size();
+ csize numGVars = theGroupVars.size();
+ csize numNGVars = theNonGroupVars.size();
- for (ulong i = 0; i < numGVars; ++i)
+ for (csize i = 0; i < numGVars; ++i)
theGroupVars[i].second->set_flwor_clause(NULL);
- for (ulong i = 0; i < numNGVars; ++i)
+ for (csize i = 0; i < numNGVars; ++i)
theNonGroupVars[i].second->set_flwor_clause(NULL);
}
@@ -651,8 +651,8 @@
expr* group_clause::get_input_for_group_var(const var_expr* var)
{
- ulong numVars = (ulong)theGroupVars.size();
- for (ulong i = 0; i < numVars; ++i)
+ csize numVars = theGroupVars.size();
+ for (csize i = 0; i < numVars; ++i)
{
if (theGroupVars[i].second.getp() == var)
return theGroupVars[i].first.getp();
@@ -664,8 +664,8 @@
expr* group_clause::get_input_for_nongroup_var(const var_expr* var)
{
- ulong numVars = (ulong)theNonGroupVars.size();
- for (ulong i = 0; i < numVars; ++i)
+ csize numVars = theNonGroupVars.size();
+ for (csize i = 0; i < numVars; ++i)
{
if (theNonGroupVars[i].second.getp() == var)
return theNonGroupVars[i].first.getp();
@@ -677,20 +677,20 @@
flwor_clause_t group_clause::clone(expr::substitution_t& subst) const
{
- ulong numGroupVars = (ulong)theGroupVars.size();
- ulong numNonGroupVars = (ulong)theNonGroupVars.size();
+ csize numGroupVars = theGroupVars.size();
+ csize numNonGroupVars = theNonGroupVars.size();
rebind_list_t cloneGroupVars(numGroupVars);
rebind_list_t cloneNonGroupVars(numNonGroupVars);
- for (ulong i = 0; i < numGroupVars; ++i)
+ for (csize i = 0; i < numGroupVars; ++i)
{
cloneGroupVars[i].first = theGroupVars[i].first->clone(subst);
cloneGroupVars[i].second = new var_expr(*theGroupVars[i].second);
subst[theGroupVars[i].second.getp()] = cloneGroupVars[i].second.getp();
}
- for (ulong i = 0; i < numNonGroupVars; ++i)
+ for (csize i = 0; i < numNonGroupVars; ++i)
{
cloneNonGroupVars[i].first = theNonGroupVars[i].first->clone(subst);
cloneNonGroupVars[i].second = new var_expr(*theNonGroupVars[i].second);
=== modified file 'src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp'
--- src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp 2011-08-11 19:09:24 +0000
+++ src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp 2011-11-04 19:40:32 +0000
@@ -338,7 +338,7 @@
// library
for (lIt = lLibraryAnn.begin(); lIt != lLibraryAnn.end(); ++lIt) {
const XQDocAnnotation lAnnotation = *lIt;
- printCommentFragment(lCommentElem, lAnnotation.getValue().str(), "library");
+ printCommentFragment(lCommentElem, lAnnotation.getValue().str(), "library", true);
}
// example
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2011-10-18 21:29:50 +0000
+++ src/compiler/translator/translator.cpp 2011-11-04 19:40:32 +0000
@@ -161,8 +161,7 @@
/*******************************************************************************
********************************************************************************/
-#define ZANN_CONTAINS( ann ) \
- theAnnotations->contains(theSctx->lookup_ann(StaticContextConsts:: ann))
+#define ZANN_CONTAINS( ann ) theAnnotations->contains(AnnotationInternal::ann)
/*******************************************************************************
@@ -1305,11 +1304,25 @@
if (qname != NULL)
{
RAISE_ERROR(zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, loc,
- ERROR_PARAMS(qname->getStringValue()));
+ ERROR_PARAMS(
+ qname->getStringValue(),
+ "index",
+ n-1,
+ "multiple of 6"
+ )
+ );
}
else
{
- RAISE_ERROR_NO_PARAMS(zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, loc);
+ RAISE_ERROR(
+ zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, loc,
+ ERROR_PARAMS(
+ "anonymous",
+ "index",
+ n-1,
+ "multiple of 6"
+ )
+ );
}
}
@@ -3540,8 +3553,7 @@
let_clause_t lc = wrap_in_letclause(&*arg_var, subst_var);
- // theCurrentPrologVFDecl might be null in case
- // of inline functions
+ // theCurrentPrologVFDecl might be null in case of inline functions
// inline functions currently can't be sequential anyway
// hence, we can always lazy evaluation
if (!theCurrentPrologVFDecl.isNull())
@@ -3654,19 +3666,15 @@
{
if (v.is_global())
{
- if (theAnnotations->contains(
-
- theSctx->lookup_ann(StaticContextConsts::fn_private)))
+ if (ZANN_CONTAINS(fn_private))
ve->set_private(true);
}
- if (theAnnotations->contains(
- theSctx->lookup_ann(StaticContextConsts::zann_assignable)))
+ if (ZANN_CONTAINS(zann_assignable))
{
ve->set_mutable(true);
}
- else if (theAnnotations->contains(
- theSctx->lookup_ann(StaticContextConsts::zann_nonassignable)))
+ else if (ZANN_CONTAINS(zann_nonassignable))
{
ve->set_mutable(false);
}
@@ -3793,22 +3801,22 @@
store::Item_t lExpandedQName;
expand_function_qname(lExpandedQName, v.get_qname().getp(), loc);
- if (lExpandedQName->getNamespace() == static_context::W3C_XML_NS ||
- lExpandedQName->getNamespace() == XML_SCHEMA_NS ||
- lExpandedQName->getNamespace() == XSI_NS ||
- lExpandedQName->getNamespace() == static_context::W3C_FN_NS ||
- lExpandedQName->getNamespace() == XQUERY_MATH_FN_NS ||
- lExpandedQName->getNamespace() == ZORBA_ANNOTATIONS_NS)
+ zstring annotNS = lExpandedQName->getNamespace();
+
+ if (annotNS == static_context::W3C_XML_NS ||
+ annotNS == XML_SCHEMA_NS ||
+ annotNS == XSI_NS ||
+ annotNS == static_context::W3C_FN_NS ||
+ annotNS == XQUERY_MATH_FN_NS ||
+ annotNS == ZORBA_ANNOTATIONS_NS)
{
- if ( theSctx->lookup_ann(lExpandedQName) == StaticContextConsts::zann_end)
+ if (AnnotationInternal::lookup(lExpandedQName) == AnnotationInternal::zann_end)
{
- throw XQUERY_EXCEPTION(
- err::XQST0045,
- ERROR_PARAMS( "%" + (lExpandedQName->getPrefix().empty() ?
- "\'" + lExpandedQName->getNamespace() + "\'"
- : lExpandedQName->getPrefix())
- + ":" + lExpandedQName->getLocalName()),
- ERROR_LOC(loc));
+ RAISE_ERROR(err::XQST0045, loc,
+ ERROR_PARAMS( "%" + (lExpandedQName->getPrefix().empty() ?
+ "\'" + lExpandedQName->getNamespace() + "\'"
+ : lExpandedQName->getPrefix())
+ + ":" + lExpandedQName->getLocalName()));
}
}
else
@@ -3825,6 +3833,7 @@
}
std::vector<rchandle<const_expr> > lLiterals;
+
if (v.get_literals())
{
std::vector<rchandle<exprnode> >::const_iterator lIter;
@@ -4017,62 +4026,62 @@
StaticContextConsts::node_modifier_t lNodeModifier;
std::vector<rchandle<const_expr> > lLiterals;
- if ( ZANN_CONTAINS (zann_queue) )
+ if (ZANN_CONTAINS(zann_queue))
{
lUpdateMode = StaticContextConsts::decl_queue;
}
- else if ( ZANN_CONTAINS ( zann_append_only) )
+ else if (ZANN_CONTAINS(zann_append_only))
{
lUpdateMode = StaticContextConsts::decl_append_only;
}
- else if ( ZANN_CONTAINS ( zann_const ) )
+ else if (ZANN_CONTAINS(zann_const))
{
lUpdateMode = StaticContextConsts::decl_const;
}
- else if ( ZANN_CONTAINS ( zann_mutable ) )
+ else if (ZANN_CONTAINS(zann_mutable))
{
lUpdateMode = StaticContextConsts::decl_mutable;
}
else
{
- theAnnotations->push_back(
- theSctx->lookup_ann( StaticContextConsts::zann_mutable ),
- lLiterals
- );
+ theAnnotations->
+ push_back(AnnotationInternal::lookup(AnnotationInternal::zann_mutable),
+ lLiterals);
+
lUpdateMode = StaticContextConsts::decl_mutable;
}
- if ( ZANN_CONTAINS ( zann_ordered) )
+ if (ZANN_CONTAINS(zann_ordered))
{
lOrderMode = StaticContextConsts::decl_ordered;
}
- else if ( ZANN_CONTAINS ( zann_unordered ) )
+ else if (ZANN_CONTAINS(zann_unordered))
{
lOrderMode = StaticContextConsts::decl_unordered;
}
else
{
- theAnnotations->push_back(
- theSctx->lookup_ann( StaticContextConsts::zann_unordered ),
- lLiterals
- );
+ theAnnotations->
+ push_back(AnnotationInternal::lookup(AnnotationInternal::zann_unordered),
+ lLiterals);
+
lOrderMode = StaticContextConsts::decl_unordered;
}
- if ( ZANN_CONTAINS ( zann_read_only_nodes) )
+ if (ZANN_CONTAINS(zann_read_only_nodes))
{
lNodeModifier = StaticContextConsts::read_only;
}
- else if ( ZANN_CONTAINS ( zann_mutable_nodes ) )
+ else if (ZANN_CONTAINS(zann_mutable_nodes))
{
lNodeModifier = StaticContextConsts::mutable_node;
}
else
{
- theAnnotations->push_back(
- theSctx->lookup_ann( StaticContextConsts::zann_mutable_nodes ),
- lLiterals
- );
+ theAnnotations->
+ push_back(AnnotationInternal::lookup(AnnotationInternal::zann_mutable_nodes),
+ lLiterals);
+
lNodeModifier = StaticContextConsts::mutable_node;
}
@@ -4123,11 +4132,8 @@
if ( !theSctx->is_feature_set(feature::ddl) )
{
- throw XQUERY_EXCEPTION(
- zerr::ZXQP0050_FEATURE_NOT_AVAILABLE,
- ERROR_PARAMS( "data-definition (ddl)" ),
- ERROR_LOC( v.get_location() )
- );
+ RAISE_ERROR(zerr::ZXQP0050_FEATURE_NOT_AVAILABLE, v.get_location(),
+ ERROR_PARAMS("data-definition (ddl)"));
}
const QName* qname = v.getName();
@@ -4149,10 +4155,10 @@
}
IndexDecl_t index = new IndexDecl(theSctx, loc, qnameItem);
- index->setGeneral ( false );
- index->setUnique ( false );
- index->setMethod ( IndexDecl::HASH );
- index->setMaintenanceMode ( IndexDecl::MANUAL );
+ index->setGeneral(false);
+ index->setUnique(false);
+ index->setMethod(IndexDecl::HASH);
+ index->setMaintenanceMode(IndexDecl::MANUAL);
AnnotationListParsenode* lAnns = v.get_annotations();
if (lAnns)
@@ -4160,27 +4166,28 @@
lAnns->accept(*this);
}
- if ( theAnnotations )
+ if (theAnnotations)
{
- if ( ZANN_CONTAINS ( zann_general_equality ) ||
- ZANN_CONTAINS ( zann_general_range ) )
- {
- index->setGeneral( true );
- }
- if ( ZANN_CONTAINS ( zann_general_range ) ||
- ZANN_CONTAINS ( zann_value_range ) )
- {
- index->setMethod( IndexDecl::TREE );
- }
- if ( ZANN_CONTAINS ( zann_unique ) )
- {
- index->setUnique( true );
- }
- if ( ZANN_CONTAINS ( zann_automatic ) )
+ if (ZANN_CONTAINS(zann_general_equality) ||
+ ZANN_CONTAINS(zann_general_range))
+ {
+ index->setGeneral(true);
+ }
+ if (ZANN_CONTAINS(zann_general_range) ||
+ ZANN_CONTAINS(zann_value_range))
+ {
+ index->setMethod(IndexDecl::TREE);
+ }
+ if (ZANN_CONTAINS(zann_unique))
+ {
+ index->setUnique(true);
+ }
+ if (ZANN_CONTAINS(zann_automatic))
{
index->setMaintenanceMode(IndexDecl::REBUILD);
}
}
+
theAnnotations = NULL;
theIndexDecl = index;
@@ -10329,15 +10336,13 @@
if ( !theSctx->is_feature_set(feature::hof) )
{
- throw XQUERY_EXCEPTION(
- zerr::ZXQP0050_FEATURE_NOT_AVAILABLE,
- ERROR_PARAMS( "higher-order functions (hof)" ),
- ERROR_LOC( v.get_location() )
- );
+ RAISE_ERROR(zerr::ZXQP0050_FEATURE_NOT_AVAILABLE, v.get_location(),
+ ERROR_PARAMS("higher-order functions (hof)"));
}
return no_state;
}
+
void end_visit(const LiteralFunctionItem& v, void* /*visit_state*/)
{
TRACE_VISIT_OUT();
@@ -10345,10 +10350,12 @@
rchandle<QName> qname = v.getQName();
uint32_t arity = 0;
- try {
+ try
+ {
arity = to_xs_unsignedInt(v.getArity());
}
- catch ( std::range_error const& ) {
+ catch ( std::range_error const& )
+ {
RAISE_ERROR(err::XPST0017, loc,
ERROR_PARAMS(v.getArity(), ZED(NoParseFnArity)));
}
@@ -10462,6 +10469,7 @@
var_expr_t arg_var = create_var(loc, qname, var_expr::arg_var);
var_expr_t subst_var = bind_var(loc, qname, var_expr::let_var);
+
let_clause_t lc = wrap_in_letclause(&*arg_var, subst_var);
arg_var->set_type(varExpr->get_return_type());
=== modified file 'src/compiler/xqddf/value_index.cpp'
--- src/compiler/xqddf/value_index.cpp 2011-06-14 17:26:33 +0000
+++ src/compiler/xqddf/value_index.cpp 2011-11-04 19:40:32 +0000
@@ -36,6 +36,8 @@
#include "store/api/item_factory.h"
+#include "diagnostics/util_macros.h"
+
namespace zorba
{
@@ -52,6 +54,7 @@
const QueryLoc& loc,
const store::Item_t& name)
:
+ theLocation(loc),
theSctx(sctx),
theName(name),
theIsGeneral(false),
@@ -210,7 +213,28 @@
********************************************************************************/
void IndexDecl::setKeyTypes(const std::vector<xqtref_t>& keyTypes)
{
+ assert(!keyTypes.empty());
+
theKeyTypes = keyTypes;
+
+ if (theIsGeneral && theIsUnique)
+ {
+ TypeManager* tm = theSctx->get_typemanager();
+
+ xqtref_t type = theKeyTypes[0];
+ xqtref_t ptype;
+
+ if (type != NULL)
+ ptype = TypeOps::prime_type(tm, *type);
+
+ if (ptype == NULL ||
+ TypeOps::is_equal(tm, *ptype, *GENV_TYPESYSTEM.ANY_ATOMIC_TYPE_ONE) ||
+ TypeOps::is_subtype(tm, *ptype, *GENV_TYPESYSTEM.UNTYPED_ATOMIC_TYPE_ONE))
+ {
+ RAISE_ERROR(zerr::ZDST0025_INDEX_BAD_UNIQUE_PROPERTY, theLocation,
+ ERROR_PARAMS(theName->getStringValue()));
+ }
+ }
}
@@ -269,7 +293,7 @@
std::vector<expr*> keySources;
- ulong numKeys = (ulong)theKeyExprs.size();
+ csize numKeys = theKeyExprs.size();
if (theIsGeneral && numKeys > 1)
{
@@ -281,7 +305,7 @@
}
// Check constraints on the key exprs
- for (ulong i = 0; i < numKeys; ++i)
+ for (csize i = 0; i < numKeys; ++i)
{
analyzeExprInternal(theKeyExprs[i].getp(),
theSourceNames,
@@ -307,11 +331,9 @@
// theMaintenanceMode is initially set to REBUILD. If theMaintenanceMode
// is not changed above (to DOC_MAP), then we throw an error because we
// don't want to automatically rebuild the full index with every update.
- throw XQUERY_EXCEPTION(
- zerr::ZDST0034_INDEX_CANNOT_DO_AUTOMATIC_MAINTENANCE,
- ERROR_PARAMS( theName->getStringValue() ),
- ERROR_LOC( getDomainExpr()->get_loc() )
- );
+ RAISE_ERROR(zerr::ZDST0034_INDEX_CANNOT_DO_AUTOMATIC_MAINTENANCE,
+ getDomainExpr()->get_loc(),
+ ERROR_PARAMS(theName->getStringValue()));
}
}
@@ -342,11 +364,8 @@
if (!func->isDeterministic())
{
- throw XQUERY_EXCEPTION(
- zerr::ZDST0028_INDEX_NOT_DETERMINISTIC,
- ERROR_PARAMS( theName->getStringValue() ),
- ERROR_LOC( e->get_loc() )
- );
+ RAISE_ERROR(zerr::ZDST0028_INDEX_NOT_DETERMINISTIC, e->get_loc(),
+ ERROR_PARAMS(theName->getStringValue()));
}
if (func->isSource())
@@ -364,20 +383,14 @@
}
else
{
- throw XQUERY_EXCEPTION(
- zerr::ZDST0030_INDEX_NON_CONST_DATA_SOURCE,
- ERROR_PARAMS( theName->getStringValue() ),
- ERROR_LOC( e->get_loc() )
- );
+ RAISE_ERROR(zerr::ZDST0030_INDEX_NON_CONST_DATA_SOURCE, e->get_loc(),
+ ERROR_PARAMS(theName->getStringValue()));
}
}
else
{
- throw XQUERY_EXCEPTION(
- zerr::ZDST0029_INDEX_INVALID_DATA_SOURCE,
- ERROR_PARAMS( theName->getStringValue() ),
- ERROR_LOC( e->get_loc() )
- );
+ RAISE_ERROR(zerr::ZDST0029_INDEX_INVALID_DATA_SOURCE, e->get_loc(),
+ ERROR_PARAMS(theName->getStringValue()));
}
}
}
=== modified file 'src/compiler/xqddf/value_index.h'
--- src/compiler/xqddf/value_index.h 2011-08-12 16:07:57 +0000
+++ src/compiler/xqddf/value_index.h 2011-11-04 19:40:32 +0000
@@ -92,32 +92,44 @@
Data members:
-------------
- - theSctx :
+ theLocation:
+ ------------
+ The query location where the index declaration appears at.
+
+ theSctx:
+ --------
The root static context of the data module containing the index declaration.
- - theName :
+ theName:
+ --------
The qname that identifies the index.
- - theIsGeneral :
+ theIsGeneral:
+ -------------
- - theIsUnique :
+ theIsUnique:
+ ------------
Whether it is a unique index or not.
- - theIsTemp :
+ theIsTemp:
+ ----------
Whether it is a temp index or not. A temp index is an index that is created
on-the-fly to optimize a query by converting a nested-lopp join to a hashjoin
(see index_join_rule.cpp). Such an index is destroyed at the end of the query
that created it.
- - theMaintenanceMode:
+ theMaintenanceMode:
+ -------------------
If and how to maintain the index during/after each apply-updates or not.
- - theContainerKind :
+ theContainerKind:
+ -----------------
The kind if container used to implement the index. Currently, there are 2
kinds: a tree-based container (std::map) for ordered indexes, or hash-based
container for unordered indexes.
- - theDomainClause :
+ theDomainClause:
+ ----------------
A FOR-clause that associates the domain expr with a FOR var that is referenced
by the key exprs and acts as the domain node for those exprs. If dexpr is the
domain expr specified in the index declaration, the actual domain expr is:
@@ -125,25 +137,31 @@
for value indexes : domainExpr := dexpr treat as node()*
for general indexes : domainExpr := check-distinct-nodes(dexpr treat as node()*)
- - theKeyExprs :
+ theKeyExprs:
+ ------------
The key expressions of the index. If kexpr is a key expr specified in the
index declaration, the actual domain expr is:
for value indexes : keyExpr := fn:data(kexpr) treat as typeDecl
for general indexes : distinct-values(fn:data(kexpr) treat as typeDecl)
- - theKeyTypes :
- The atomic item type that each key value must match with according to the
- rules of sequence type matching. For value indexes, their index declaration
- must always specify a type T, and the item type of T may not be xs:anyAtomicType
- or xs:untypedAtomic. For general indexes, the key type declaration may be
- absent, or its item type may be xs:anyAtomicType or xs:untypedAtomic. If
- absent, the associated entry in theKeyTypes will be NULL, but this is treated
- the same as xs:anyAtomicType.
-
- - theOrderModifiers :
-
- - theSourceNames :
+ theKeyTypes:
+ ------------
+ For each key expr, this vector contains the builtin atomic item that is the
+ base of the atomic type type T specified for that key expr. For value indexes,
+ their index declaration must always specify a type T, and the item type of T
+ may not be xs:anyAtomicType or xs:untypedAtomic. For general indexes, the key
+ type declaration may be absent, or its item type may be xs:anyAtomicType or
+ xs:untypedAtomic. If absent, the associated entry in theKeyTypes will be NULL,
+ but this is treated the same as xs:anyAtomicType. The translator makes sure
+ that each key value inserted into the index matches with T according to the
+ rules of sequence type matching.
+
+ theOrderModifiers:
+ ------------------
+
+ theSourceNames:
+ -----------------
The qnames of the collections referenced in the domain and key expressions.
Currently, it is required that the arg given to every xqddf:collection()
invocation within the domain expr or any of the key exprs is a constant expr.
@@ -166,11 +184,13 @@
determine the collection set of an index as the index is being created, and
then give this info to the store.
- - theDomainSourceExprs :
+ theDomainSourceExprs:
+ ---------------------
A vector containing pointers to the xqddf:collection() exprs within the
domain expr.
- -theBuildExpr :
+ theBuildExpr:
+ -------------
The expr that computes the index entries. It is used to create or rebuild
the full index from scratch. The expr is a flwor expr of the following form,
for value and general indexes, respectively:
@@ -181,23 +201,27 @@
for $$dot at $$pos in domainExpr
return general-index-entry-builder($$dot, fieldExpr);
- - theBuildPlan :
+ theBuildPlan:
+ -------------
The runtime plan corresponding to theBuildExpr. During runtime (see
CreateIndexIterator and RebuildIndexIterator), this plan is wrapper into a
PlanWrapper and then passed to the store, which uses it to create or
re-build the full index.
- - theDocIndexerExpr :
+ theDocIndexerExpr:
+ ------------------
This is an expr that builds the index over a single xml tree, which is
provided as an external var to this expr. It is basically the same as
theBuildExpr except that a reference to a collection inside the domainExpr
is replaced with a reference to an external var that can be bound dynamically
to some xml tree.
- - theDocIndexerVar :
+ theDocIndexerVar:
+ -----------------
The external var appearing in theDocIndexerExpr.
- - theDocIndexer :
+ theDocIndexer:
+ --------------
If the index domain expr is a map over a collection C, then theDocIndexer obj
is not NULL and it provides a method that takes as input a document D in C
and produces all the index entries for D. theDocIndexer obj is passed to the
@@ -223,6 +247,8 @@
private:
+ QueryLoc theLocation;
+
static_context * theSctx;
store::Item_t theName;
=== modified file 'src/context/static_context.cpp'
--- src/context/static_context.cpp 2011-10-18 19:06:06 +0000
+++ src/context/static_context.cpp 2011-11-04 19:40:32 +0000
@@ -280,6 +280,9 @@
static_context::ZORBA_NODEREF_FN_NS = NS_PRE + "modules/node-reference";
const zstring
+static_context::ZORBA_NODEPOS_FN_NS = NS_PRE + "modules/node-position";
+
+const zstring
static_context::ZORBA_STORE_DYNAMIC_COLLECTIONS_DDL_FN_NS
= NS_PRE + "modules/store/dynamic/collections/ddl";
@@ -352,6 +355,11 @@
const zstring
static_context::ZORBA_XML_FN_NS = NS_PRE + "modules/xml";
+#ifndef ZORBA_NO_FULL_TEXT
+const zstring
+static_context::ZORBA_FULL_TEXT_FN_NS = static_context::ZORBA_NS_PREFIX + "modules/full-text";
+#endif /* ZORBA_NO_FULL_TEXT */
+
/***************************************************************************//**
Target namespaces of zorba reserved modules
********************************************************************************/
@@ -373,6 +381,7 @@
return (ns == ZORBA_MATH_FN_NS ||
ns == ZORBA_BASE64_FN_NS ||
ns == ZORBA_NODEREF_FN_NS ||
+ ns == ZORBA_NODEPOS_FN_NS ||
ns == ZORBA_STORE_DYNAMIC_DOCUMENTS_FN_NS ||
ns == ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS ||
ns == ZORBA_STORE_DYNAMIC_COLLECTIONS_DDL_FN_NS ||
@@ -392,7 +401,8 @@
ns == ZORBA_STRING_FN_NS ||
ns == ZORBA_FETCH_FN_NS ||
ns == ZORBA_NODE_FN_NS ||
- ns == ZORBA_XML_FN_NS);
+ ns == ZORBA_XML_FN_NS ||
+ ns == ZORBA_FULL_TEXT_FN_NS);
}
else if (ns == W3C_FN_NS || ns == XQUERY_MATH_FN_NS)
{
@@ -475,7 +485,6 @@
theImportedPrivateVariablesMap(NULL),
theFunctionMap(NULL),
theFunctionArityMap(NULL),
- theAnnotationMap(NULL),
theCollectionMap(NULL),
theW3CCollectionMap(NULL),
theIndexMap(NULL),
@@ -523,7 +532,6 @@
theImportedPrivateVariablesMap(NULL),
theFunctionMap(NULL),
theFunctionArityMap(NULL),
- theAnnotationMap(NULL),
theCollectionMap(0),
theW3CCollectionMap(NULL),
theIndexMap(NULL),
@@ -576,7 +584,6 @@
theImportedPrivateVariablesMap(NULL),
theFunctionMap(NULL),
theFunctionArityMap(NULL),
- theAnnotationMap(NULL),
theCollectionMap(0),
theW3CCollectionMap(NULL),
theIndexMap(0),
@@ -652,9 +659,6 @@
delete theFunctionArityMap;
}
- if (theAnnotationMap)
- delete theAnnotationMap;
-
if (theW3CCollectionMap)
delete theW3CCollectionMap;
@@ -890,8 +894,6 @@
ar & theFunctionArityMap;
ar.set_serialize_only_for_eval(false);
- ar & theAnnotationMap;
-
ar & theCollectionMap;
ar & theW3CCollectionMap;
@@ -2616,49 +2618,6 @@
return lModule->getExternalFunction(aLocalName.str());
}
-/////////////////////////////////////////////////////////////////////////////////
-// //
-// Annotations //
-// //
-/////////////////////////////////////////////////////////////////////////////////
-void
-static_context::add_ann(
- StaticContextConsts::annotations_t aAnnotation,
- const store::Item_t& aQName)
-{
- if (!theAnnotationMap) {
- theAnnotationMap = new AnnotationMap();
- }
- (*theAnnotationMap)[static_cast<uint64_t>(aAnnotation)] = aQName;
-}
-
-store::Item_t
-static_context::lookup_ann(StaticContextConsts::annotations_t aAnnotation) const
-{
- std::map<uint64_t, store::Item_t>::const_iterator lIter;
- if (!theAnnotationMap ||
- (lIter = theAnnotationMap->find(static_cast<uint64_t>(aAnnotation))) == theAnnotationMap->end()) {
- return theParent?theParent->lookup_ann(aAnnotation):NULL;
- }
- return lIter->second;
-}
-
-StaticContextConsts::annotations_t
-static_context::lookup_ann(const store::Item_t& aQName) const
-{
- if ( theAnnotationMap )
- {
- std::map<uint64_t, store::Item_t>::const_iterator lIter;
- for (lIter = theAnnotationMap->begin(); lIter != theAnnotationMap->end(); ++lIter)
- {
- if (aQName->equals(lIter->second))
- {
- return static_cast<StaticContextConsts::annotations_t>(lIter->first);
- }
- }
- }
- return theParent?theParent->lookup_ann(aQName):StaticContextConsts::zann_end;
-}
/////////////////////////////////////////////////////////////////////////////////
// //
=== modified file 'src/context/static_context.h'
--- src/context/static_context.h 2011-10-18 19:06:06 +0000
+++ src/context/static_context.h 2011-11-04 19:40:32 +0000
@@ -321,13 +321,6 @@
different arities. One of these versions is stored in the theFunctionMap,
and the rest are regisreded in theFunctionArityMap.
- theAnnotations:
- --------------
- annotations_t -> store::Item_t map that contains a list of built-in annotations
- Those annotations are used in the translator to check if a function,
- variable, index, or collection declares any of these annotations.
-
-
theCollectionMap :
------------------
A hash mash map mapping XQDDF collection qnames to the objs storing the info
@@ -413,8 +406,6 @@
typedef std::map<std::string, XQPCollator*> CollationMap;
- typedef std::map<uint64_t, store::Item_t> AnnotationMap;
-
public:
struct ctx_module_t : public ::zorba::serialization::SerializeBaseClass
@@ -459,6 +450,7 @@
static const zstring ZORBA_MATH_FN_NS;
static const zstring ZORBA_BASE64_FN_NS;
static const zstring ZORBA_NODEREF_FN_NS;
+ static const zstring ZORBA_NODEPOS_FN_NS;
static const zstring ZORBA_STORE_DYNAMIC_COLLECTIONS_DDL_FN_NS;
static const zstring ZORBA_STORE_DYNAMIC_COLLECTIONS_DML_FN_NS;
static const zstring ZORBA_STORE_STATIC_COLLECTIONS_DDL_FN_NS;
@@ -478,6 +470,9 @@
static const zstring ZORBA_FETCH_FN_NS;
static const zstring ZORBA_NODE_FN_NS;
static const zstring ZORBA_XML_FN_NS;
+#ifndef ZORBA_NO_FULL_TEXT
+ static const zstring ZORBA_FULL_TEXT_FN_NS;
+#endif /* ZORBA_NO_FULL_TEXT */
//
// Namespaces of virtual modules declaring zorba builtin functions
@@ -538,8 +533,6 @@
FunctionMap * theFunctionMap;
FunctionArityMap * theFunctionArityMap;
- AnnotationMap * theAnnotationMap;
-
CollectionMap * theCollectionMap;
W3CCollectionMap * theW3CCollectionMap;
@@ -838,16 +831,6 @@
//
- // Annotation
- //
- void add_ann(StaticContextConsts::annotations_t ann, const store::Item_t& aQName);
-
- store::Item_t lookup_ann(StaticContextConsts::annotations_t ann) const;
-
- StaticContextConsts::annotations_t lookup_ann(const store::Item_t& aQName) const;
-
-
- //
// Documents
//
void bind_document(const zstring& uri, xqtref_t& t);
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2011-10-17 21:17:05 +0000
+++ src/diagnostics/diagnostic_en.xml 2011-11-04 19:40:32 +0000
@@ -1966,7 +1966,7 @@
</diagnostic>
<diagnostic code="ZDDY0025" name="INDEX_WRONG_NUMBER_OF_PROBE_ARGS">
- <value>${"1": }invalid number of arguments in probe</value>
+ <value>"$1": invalid number of arguments to $2 operation; given $3 expected $4</value>
</diagnostic>
<diagnostic code="ZDDY0026" name="INDEX_RANGE_PROBE_NOT_ALLOWED">
@@ -2046,6 +2046,10 @@
<value>index multiple property values</value>
</diagnostic>
+ <diagnostic code="ZDST0025" name="INDEX_BAD_UNIQUE_PROPERTY">
+ <value>"$1": index cannot be declared as unique</value>
+ </diagnostic>
+
<diagnostic code="ZDST0026" name="INDEX_INVALID_PROPERTY_VALUE">
<value>index invalid property value</value>
</diagnostic>
@@ -2174,14 +2178,6 @@
<value>"$1": partial key deletion from index "$2"</value>
</diagnostic>
- <diagnostic code="ZSTR0005" name="INDEX_PARTIAL_KEY_PROBE">
- <value>"$1": partial key probe into index "$2"</value>
- </diagnostic>
-
- <diagnostic code="ZSTR0006" name="INDEX_INVALID_BOX_PROBE">
- <value>for index "$1": $2</value>
- </diagnostic>
-
<diagnostic code="ZSTR0007" name="INDEX_UNSUPPORTED_PROBE_CONDITION">
<value>"$1": unsupported probe condition for index "$2"</value>
</diagnostic>
=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
--- src/diagnostics/pregenerated/diagnostic_list.cpp 2011-10-19 15:28:51 +0000
+++ src/diagnostics/pregenerated/diagnostic_list.cpp 2011-11-04 19:40:32 +0000
@@ -915,6 +915,9 @@
ZorbaErrorCode ZDST0024_INDEX_MULTIPLE_PROPERTY_VALUES( "ZDST0024" );
+ZorbaErrorCode ZDST0025_INDEX_BAD_UNIQUE_PROPERTY( "ZDST0025" );
+
+
ZorbaErrorCode ZDST0026_INDEX_INVALID_PROPERTY_VALUE( "ZDST0026" );
@@ -1004,12 +1007,6 @@
ZorbaErrorCode ZSTR0004_INDEX_PARTIAL_KEY_REMOVE( "ZSTR0004" );
-ZorbaErrorCode ZSTR0005_INDEX_PARTIAL_KEY_PROBE( "ZSTR0005" );
-
-
-ZorbaErrorCode ZSTR0006_INDEX_INVALID_BOX_PROBE( "ZSTR0006" );
-
-
ZorbaErrorCode ZSTR0007_INDEX_UNSUPPORTED_PROBE_CONDITION( "ZSTR0007" );
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2011-10-20 23:05:55 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2011-11-04 19:40:32 +0000
@@ -286,7 +286,7 @@
{ "ZDDY0022", "\"$1\": index already exists" },
{ "ZDDY0023", "\"$1\": index does not exist" },
{ "ZDDY0024", "\"$1\": index uniqueness violation" },
- { "ZDDY0025", "${\"1\": }invalid number of arguments in probe" },
+ { "ZDDY0025", "\"$1\": invalid number of arguments to $2 operation; given $3 expected $4" },
{ "ZDDY0026", "\"$1\": index range probe not allowed" },
{ "ZDDY0027", "\"$1\": index multiple creates" },
{ "ZDDY0028", "\"$1\": index domain has duplicate nodes" },
@@ -306,6 +306,7 @@
{ "ZDST0022", "\"$1\": index already imported into module \"$2\"" },
{ "ZDST0023", "\"$1\": index declaration not allowed in main module" },
{ "ZDST0024", "index multiple property values" },
+ { "ZDST0025", "\"$1\": index cannot be declared as unique" },
{ "ZDST0026", "index invalid property value" },
{ "ZDST0027", "\"$1\": index bad key type" },
{ "ZDST0028", "\"$1\": index not deterministic" },
@@ -337,8 +338,6 @@
{ "ZSTR0002", "\"$1\": index does not exist" },
{ "ZSTR0003", "\"$1\": partial key insertion into index \"$2\"" },
{ "ZSTR0004", "\"$1\": partial key deletion from index \"$2\"" },
- { "ZSTR0005", "\"$1\": partial key probe into index \"$2\"" },
- { "ZSTR0006", "for index \"$1\": $2" },
{ "ZSTR0007", "\"$1\": unsupported probe condition for index \"$2\"" },
{ "ZSTR0008", "\"$1\": collection already exists" },
{ "ZSTR0009", "\"$1\": collection not found" },
=== modified file 'src/functions/function.cpp'
--- src/functions/function.cpp 2011-07-29 06:13:28 +0000
+++ src/functions/function.cpp 2011-11-04 19:40:32 +0000
@@ -104,22 +104,16 @@
if (!theAnnotationList)
return;
- static_context& lCtx = GENV_ROOT_STATIC_CONTEXT;
-
- if (theAnnotationList->contains(
- lCtx.lookup_ann(StaticContextConsts::zann_nondeterministic)))
+ if (theAnnotationList->contains(AnnotationInternal::zann_nondeterministic))
setDeterministic(false);
- setPrivate(theAnnotationList->contains(
- lCtx.lookup_ann(StaticContextConsts::fn_private)));
+ setPrivate(theAnnotationList->contains(AnnotationInternal::fn_private));
- if (isUpdating()
- &&
- theAnnotationList->contains(
- lCtx.lookup_ann(StaticContextConsts::zann_sequential)))
+ if (isUpdating() &&
+ theAnnotationList->contains(AnnotationInternal::zann_sequential))
{
throw XQUERY_EXCEPTION(zerr::XSST0001,
- ERROR_PARAMS(getName()->getStringValue()));
+ ERROR_PARAMS(getName()->getStringValue()));
}
}
=== modified file 'src/functions/library.cpp'
--- src/functions/library.cpp 2011-09-27 16:01:34 +0000
+++ src/functions/library.cpp 2011-11-04 19:40:32 +0000
@@ -44,6 +44,7 @@
#include "functions/func_ic_ddl.h"
#include "functions/func_maths.h"
#include "functions/func_nodes.h"
+#include "functions/func_node_position.h"
#include "functions/func_node_sort_distinct.h"
#include "functions/func_numerics.h"
#include "functions/func_numerics_impl.h"
@@ -64,6 +65,7 @@
#include "functions/func_reflection.h"
#include "functions/func_apply.h"
#include "functions/func_fetch.h"
+#include "functions/func_ft_module.h"
#include "functions/func_function_item_iter.h"
@@ -108,6 +110,7 @@
populate_context_ic_ddl(sctx);
populate_context_maths(sctx);
populate_context_nodes(sctx);
+ populate_context_node_position(sctx);
populate_context_numerics(sctx);
populate_context_other_diagnostics(sctx);
populate_context_parsing_and_serializing(sctx);
@@ -136,6 +139,7 @@
populate_context_apply(sctx);
populate_context_fetch(sctx);
+ populate_context_ft_module(sctx);
ar.set_loading_hardcoded_objects(false);
}
=== added file 'src/functions/pregenerated/func_ft_module.cpp'
--- src/functions/pregenerated/func_ft_module.cpp 1970-01-01 00:00:00 +0000
+++ src/functions/pregenerated/func_ft_module.cpp 2011-11-04 19:40:32 +0000
@@ -0,0 +1,303 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ******************************************
+// * *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME *
+// * *
+// ******************************************
+
+
+#include "stdafx.h"
+#include "runtime/full_text/ft_module.h"
+#include "functions/func_ft_module.h"
+
+
+namespace zorba{
+
+
+
+PlanIter_t zorba_full_text_host_lang::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new HostLangIterator(sctx, loc, argv);
+}
+
+PlanIter_t zorba_full_text_is_stop_word::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsStopWordIterator(sctx, loc, argv);
+}
+
+PlanIter_t zorba_full_text_stem::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new StemIterator(sctx, loc, argv);
+}
+
+PlanIter_t zorba_full_text_strip_diacritics::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new StripDiacriticsIterator(sctx, loc, argv);
+}
+
+PlanIter_t zorba_full_text_thesaurus_lookup::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new ThesaurusLookupIterator(sctx, loc, argv);
+}
+
+PlanIter_t zorba_full_text_tokenize::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new TokenizeIterator(sctx, loc, argv);
+}
+
+PlanIter_t zorba_full_text_tokenizer_properties::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new TokenizerPropertiesIterator(sctx, loc, argv);
+}
+
+void populate_context_ft_module(static_context* sctx)
+{
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_full_text_host_lang,
+ (createQName("http://www.zorba-xquery.com/modules/full-text","","host-lang"),
+ GENV_TYPESYSTEM.LANGUAGE_TYPE_ONE),
+ FunctionConsts::ZORBA_FULL_TEXT_HOST_LANG_0);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_full_text_is_stop_word,
+ (createQName("http://www.zorba-xquery.com/modules/full-text","","is-stop-word"),
+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::ZORBA_FULL_TEXT_IS_STOP_WORD_1);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_full_text_is_stop_word,
+ (createQName("http://www.zorba-xquery.com/modules/full-text","","is-stop-word"),
+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
+ GENV_TYPESYSTEM.LANGUAGE_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::ZORBA_FULL_TEXT_IS_STOP_WORD_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_full_text_stem,
+ (createQName("http://www.zorba-xquery.com/modules/full-text","","stem"),
+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
+ GENV_TYPESYSTEM.STRING_TYPE_ONE),
+ FunctionConsts::ZORBA_FULL_TEXT_STEM_1);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_full_text_stem,
+ (createQName("http://www.zorba-xquery.com/modules/full-text","","stem"),
+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
+ GENV_TYPESYSTEM.LANGUAGE_TYPE_ONE,
+ GENV_TYPESYSTEM.STRING_TYPE_ONE),
+ FunctionConsts::ZORBA_FULL_TEXT_STEM_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_full_text_strip_diacritics,
+ (createQName("http://www.zorba-xquery.com/modules/full-text","","strip-diacritics"),
+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
+ GENV_TYPESYSTEM.STRING_TYPE_ONE),
+ FunctionConsts::ZORBA_FULL_TEXT_STRIP_DIACRITICS_1);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_full_text_thesaurus_lookup,
+ (createQName("http://www.zorba-xquery.com/modules/full-text","","thesaurus-lookup"),
+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
+ GENV_TYPESYSTEM.STRING_TYPE_PLUS),
+ FunctionConsts::ZORBA_FULL_TEXT_THESAURUS_LOOKUP_1);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_full_text_thesaurus_lookup,
+ (createQName("http://www.zorba-xquery.com/modules/full-text","","thesaurus-lookup"),
+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
+ GENV_TYPESYSTEM.STRING_TYPE_PLUS),
+ FunctionConsts::ZORBA_FULL_TEXT_THESAURUS_LOOKUP_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_full_text_thesaurus_lookup,
+ (createQName("http://www.zorba-xquery.com/modules/full-text","","thesaurus-lookup"),
+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
+ GENV_TYPESYSTEM.LANGUAGE_TYPE_ONE,
+ GENV_TYPESYSTEM.STRING_TYPE_PLUS),
+ FunctionConsts::ZORBA_FULL_TEXT_THESAURUS_LOOKUP_3);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_full_text_thesaurus_lookup,
+ (createQName("http://www.zorba-xquery.com/modules/full-text","","thesaurus-lookup"),
+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
+ GENV_TYPESYSTEM.LANGUAGE_TYPE_ONE,
+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
+ GENV_TYPESYSTEM.STRING_TYPE_PLUS),
+ FunctionConsts::ZORBA_FULL_TEXT_THESAURUS_LOOKUP_4);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_full_text_thesaurus_lookup,
+ (createQName("http://www.zorba-xquery.com/modules/full-text","","thesaurus-lookup"),
+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
+ GENV_TYPESYSTEM.LANGUAGE_TYPE_ONE,
+ GENV_TYPESYSTEM.STRING_TYPE_ONE,
+ GENV_TYPESYSTEM.INTEGER_TYPE_ONE,
+ GENV_TYPESYSTEM.INTEGER_TYPE_ONE,
+ GENV_TYPESYSTEM.STRING_TYPE_PLUS),
+ FunctionConsts::ZORBA_FULL_TEXT_THESAURUS_LOOKUP_6);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_full_text_tokenize,
+ (createQName("http://www.zorba-xquery.com/modules/full-text","","tokenize"),
+ GENV_TYPESYSTEM.ANY_NODE_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_NODE_TYPE_STAR),
+ FunctionConsts::ZORBA_FULL_TEXT_TOKENIZE_1);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_full_text_tokenize,
+ (createQName("http://www.zorba-xquery.com/modules/full-text","","tokenize"),
+ GENV_TYPESYSTEM.ANY_NODE_TYPE_ONE,
+ GENV_TYPESYSTEM.LANGUAGE_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_NODE_TYPE_STAR),
+ FunctionConsts::ZORBA_FULL_TEXT_TOKENIZE_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_full_text_tokenizer_properties,
+ (createQName("http://www.zorba-xquery.com/modules/full-text","","tokenizer-properties"),
+ GENV_TYPESYSTEM.ANY_NODE_TYPE_ONE),
+ FunctionConsts::ZORBA_FULL_TEXT_TOKENIZER_PROPERTIES_0);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, zorba_full_text_tokenizer_properties,
+ (createQName("http://www.zorba-xquery.com/modules/full-text","","tokenizer-properties"),
+ GENV_TYPESYSTEM.LANGUAGE_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_NODE_TYPE_ONE),
+ FunctionConsts::ZORBA_FULL_TEXT_TOKENIZER_PROPERTIES_1);
+
+ }
+
+}
+
+
+}
+
+
+
=== added file 'src/functions/pregenerated/func_ft_module.h'
--- src/functions/pregenerated/func_ft_module.h 1970-01-01 00:00:00 +0000
+++ src/functions/pregenerated/func_ft_module.h 2011-11-04 19:40:32 +0000
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ******************************************
+// * *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME *
+// * *
+// ******************************************
+
+
+#ifndef ZORBA_FUNCTIONS_FT_MODULE_H
+#define ZORBA_FUNCTIONS_FT_MODULE_H
+
+
+#include "common/shared_types.h"
+#include "functions/function_impl.h"
+
+
+namespace zorba {
+
+
+void populate_context_ft_module(static_context* sctx);
+
+
+
+
+//zorba-full-text:host-lang
+class zorba_full_text_host_lang : public function
+{
+public:
+ zorba_full_text_host_lang(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//zorba-full-text:is-stop-word
+class zorba_full_text_is_stop_word : public function
+{
+public:
+ zorba_full_text_is_stop_word(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//zorba-full-text:stem
+class zorba_full_text_stem : public function
+{
+public:
+ zorba_full_text_stem(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//zorba-full-text:strip-diacritics
+class zorba_full_text_strip_diacritics : public function
+{
+public:
+ zorba_full_text_strip_diacritics(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//zorba-full-text:thesaurus-lookup
+class zorba_full_text_thesaurus_lookup : public function
+{
+public:
+ zorba_full_text_thesaurus_lookup(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//zorba-full-text:tokenize
+class zorba_full_text_tokenize : public function
+{
+public:
+ zorba_full_text_tokenize(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//zorba-full-text:tokenizer-properties
+class zorba_full_text_tokenizer_properties : public function
+{
+public:
+ zorba_full_text_tokenizer_properties(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+} //namespace zorba
+
+
+#endif
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */
=== added file 'src/functions/pregenerated/func_node_position.cpp'
--- src/functions/pregenerated/func_node_position.cpp 1970-01-01 00:00:00 +0000
+++ src/functions/pregenerated/func_node_position.cpp 2011-11-04 19:40:32 +0000
@@ -0,0 +1,584 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ******************************************
+// * *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME *
+// * *
+// ******************************************
+
+
+#include "stdafx.h"
+#include "runtime/nodes/node_position.h"
+#include "functions/func_node_position.h"
+
+
+namespace zorba{
+
+
+
+PlanIter_t fn_zorba_pos_node_position::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new NodePositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_ancestor_of::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsAncestorPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_following_sibling_of::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsFollowingSiblingPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_following_of::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsFollowingPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_in_subtree_of::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsInSubtreeOfPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_descendant_of::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsDescendantPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_preceding_sibling_of::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsPrecedingSiblingPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_preceding_of::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsPrecedingPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_child_of::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsChildPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_attribute_of::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsAttributeOfPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_parent_of::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsParentPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_preceding_in_document_order_of::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsPrecedingInDocumentOrderPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_following_in_document_order_of::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsFollowingInDocumentOrderPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_level::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new LevelPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_is_attribute::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsAttributePositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_is_comment::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsCommentPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_is_document::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsDocumentPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_is_element::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsElementPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_is_processing_instruction::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsProcessingInstructionPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_is_text::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsTextPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_sibling_of::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new IsSiblingPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_in_same_tree_of::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new InSameTreePositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_in_collection::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new InCollectionPositionIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_pos_in_same_collection_of::codegen(
+ CompilerCB*,
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& argv,
+ AnnotationHolder& ann) const
+{
+ return new InSameCollectionPositionIterator(sctx, loc, argv);
+}
+
+void populate_context_node_position(static_context* sctx)
+{
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_node_position,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","node-position"),
+ GENV_TYPESYSTEM.ANY_NODE_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_NODE_POSITION_1);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_ancestor_of,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","ancestor-of"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_ANCESTOR_OF_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_following_sibling_of,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","following-sibling-of"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_FOLLOWING_SIBLING_OF_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_following_of,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","following-of"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_FOLLOWING_OF_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_in_subtree_of,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","in-subtree-of"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_IN_SUBTREE_OF_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_descendant_of,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","descendant-of"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_DESCENDANT_OF_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_preceding_sibling_of,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","preceding-sibling-of"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_PRECEDING_SIBLING_OF_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_preceding_of,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","preceding-of"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_PRECEDING_OF_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_child_of,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","child-of"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_CHILD_OF_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_attribute_of,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","attribute-of"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_ATTRIBUTE_OF_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_parent_of,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","parent-of"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_PARENT_OF_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_preceding_in_document_order_of,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","preceding-in-document-order-of"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_PRECEDING_IN_DOCUMENT_ORDER_OF_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_following_in_document_order_of,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","following-in-document-order-of"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_FOLLOWING_IN_DOCUMENT_ORDER_OF_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_level,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","level"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.INTEGER_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_LEVEL_1);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_is_attribute,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","is-attribute"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_IS_ATTRIBUTE_1);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_is_comment,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","is-comment"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_IS_COMMENT_1);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_is_document,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","is-document"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_IS_DOCUMENT_1);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_is_element,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","is-element"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_IS_ELEMENT_1);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_is_processing_instruction,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","is-processing-instruction"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_IS_PROCESSING_INSTRUCTION_1);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_is_text,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","is-text"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_IS_TEXT_1);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_sibling_of,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","sibling-of"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_SIBLING_OF_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_in_same_tree_of,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","in-same-tree-of"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_IN_SAME_TREE_OF_2);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_in_collection,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","in-collection"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_IN_COLLECTION_1);
+
+ }
+
+
+ {
+
+
+ DECL_WITH_KIND(sctx, fn_zorba_pos_in_same_collection_of,
+ (createQName("http://www.zorba-xquery.com/modules/node-position","","in-same-collection-of"),
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.ANY_URI_TYPE_ONE,
+ GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+ FunctionConsts::FN_ZORBA_POS_IN_SAME_COLLECTION_OF_2);
+
+ }
+
+}
+
+
+}
+
+
+
=== added file 'src/functions/pregenerated/func_node_position.h'
--- src/functions/pregenerated/func_node_position.h 1970-01-01 00:00:00 +0000
+++ src/functions/pregenerated/func_node_position.h 2011-11-04 19:40:32 +0000
@@ -0,0 +1,361 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ******************************************
+// * *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME *
+// * *
+// ******************************************
+
+
+#ifndef ZORBA_FUNCTIONS_NODE_POSITION_H
+#define ZORBA_FUNCTIONS_NODE_POSITION_H
+
+
+#include "common/shared_types.h"
+#include "functions/function_impl.h"
+
+
+namespace zorba {
+
+
+void populate_context_node_position(static_context* sctx);
+
+
+
+
+//fn-zorba-pos:node-position
+class fn_zorba_pos_node_position : public function
+{
+public:
+ fn_zorba_pos_node_position(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:ancestor-of
+class fn_zorba_pos_ancestor_of : public function
+{
+public:
+ fn_zorba_pos_ancestor_of(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:following-sibling-of
+class fn_zorba_pos_following_sibling_of : public function
+{
+public:
+ fn_zorba_pos_following_sibling_of(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:following-of
+class fn_zorba_pos_following_of : public function
+{
+public:
+ fn_zorba_pos_following_of(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:in-subtree-of
+class fn_zorba_pos_in_subtree_of : public function
+{
+public:
+ fn_zorba_pos_in_subtree_of(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:descendant-of
+class fn_zorba_pos_descendant_of : public function
+{
+public:
+ fn_zorba_pos_descendant_of(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:preceding-sibling-of
+class fn_zorba_pos_preceding_sibling_of : public function
+{
+public:
+ fn_zorba_pos_preceding_sibling_of(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:preceding-of
+class fn_zorba_pos_preceding_of : public function
+{
+public:
+ fn_zorba_pos_preceding_of(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:child-of
+class fn_zorba_pos_child_of : public function
+{
+public:
+ fn_zorba_pos_child_of(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:attribute-of
+class fn_zorba_pos_attribute_of : public function
+{
+public:
+ fn_zorba_pos_attribute_of(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:parent-of
+class fn_zorba_pos_parent_of : public function
+{
+public:
+ fn_zorba_pos_parent_of(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:preceding-in-document-order-of
+class fn_zorba_pos_preceding_in_document_order_of : public function
+{
+public:
+ fn_zorba_pos_preceding_in_document_order_of(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:following-in-document-order-of
+class fn_zorba_pos_following_in_document_order_of : public function
+{
+public:
+ fn_zorba_pos_following_in_document_order_of(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:level
+class fn_zorba_pos_level : public function
+{
+public:
+ fn_zorba_pos_level(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:is-attribute
+class fn_zorba_pos_is_attribute : public function
+{
+public:
+ fn_zorba_pos_is_attribute(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:is-comment
+class fn_zorba_pos_is_comment : public function
+{
+public:
+ fn_zorba_pos_is_comment(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:is-document
+class fn_zorba_pos_is_document : public function
+{
+public:
+ fn_zorba_pos_is_document(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:is-element
+class fn_zorba_pos_is_element : public function
+{
+public:
+ fn_zorba_pos_is_element(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:is-processing-instruction
+class fn_zorba_pos_is_processing_instruction : public function
+{
+public:
+ fn_zorba_pos_is_processing_instruction(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:is-text
+class fn_zorba_pos_is_text : public function
+{
+public:
+ fn_zorba_pos_is_text(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:sibling-of
+class fn_zorba_pos_sibling_of : public function
+{
+public:
+ fn_zorba_pos_sibling_of(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:in-same-tree-of
+class fn_zorba_pos_in_same_tree_of : public function
+{
+public:
+ fn_zorba_pos_in_same_tree_of(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:in-collection
+class fn_zorba_pos_in_collection : public function
+{
+public:
+ fn_zorba_pos_in_collection(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+//fn-zorba-pos:in-same-collection-of
+class fn_zorba_pos_in_same_collection_of : public function
+{
+public:
+ fn_zorba_pos_in_same_collection_of(const signature& sig, FunctionConsts::FunctionKind kind)
+ : function(sig, kind) {
+
+}
+
+ CODEGEN_DECL();
+};
+
+
+} //namespace zorba
+
+
+#endif
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */
=== modified file 'src/functions/pregenerated/function_enum.h'
--- src/functions/pregenerated/function_enum.h 2011-10-19 15:28:51 +0000
+++ src/functions/pregenerated/function_enum.h 2011-11-04 19:40:32 +0000
@@ -135,6 +135,21 @@
FN_ZORBA_FETCH_CONTENT_2,
FN_ZORBA_FETCH_CONTENT_TYPE_1,
FN_PUT_2,
+ ZORBA_FULL_TEXT_HOST_LANG_0,
+ ZORBA_FULL_TEXT_IS_STOP_WORD_1,
+ ZORBA_FULL_TEXT_IS_STOP_WORD_2,
+ ZORBA_FULL_TEXT_STEM_1,
+ ZORBA_FULL_TEXT_STEM_2,
+ ZORBA_FULL_TEXT_STRIP_DIACRITICS_1,
+ ZORBA_FULL_TEXT_THESAURUS_LOOKUP_1,
+ ZORBA_FULL_TEXT_THESAURUS_LOOKUP_2,
+ ZORBA_FULL_TEXT_THESAURUS_LOOKUP_3,
+ ZORBA_FULL_TEXT_THESAURUS_LOOKUP_4,
+ ZORBA_FULL_TEXT_THESAURUS_LOOKUP_6,
+ ZORBA_FULL_TEXT_TOKENIZE_1,
+ ZORBA_FULL_TEXT_TOKENIZE_2,
+ ZORBA_FULL_TEXT_TOKENIZER_PROPERTIES_0,
+ ZORBA_FULL_TEXT_TOKENIZER_PROPERTIES_1,
FN_FUNCTION_NAME_1,
FN_FUNCTION_ARITY_1,
FN_PARTIAL_APPLY_2,
@@ -193,6 +208,30 @@
FN_ZORBA_MATH_IS_NAN_1,
FN_ZORBA_MATH_MODF_1,
FN_ZORBA_MATH_FREXP_1,
+ FN_ZORBA_POS_NODE_POSITION_1,
+ FN_ZORBA_POS_ANCESTOR_OF_2,
+ FN_ZORBA_POS_FOLLOWING_SIBLING_OF_2,
+ FN_ZORBA_POS_FOLLOWING_OF_2,
+ FN_ZORBA_POS_IN_SUBTREE_OF_2,
+ FN_ZORBA_POS_DESCENDANT_OF_2,
+ FN_ZORBA_POS_PRECEDING_SIBLING_OF_2,
+ FN_ZORBA_POS_PRECEDING_OF_2,
+ FN_ZORBA_POS_CHILD_OF_2,
+ FN_ZORBA_POS_ATTRIBUTE_OF_2,
+ FN_ZORBA_POS_PARENT_OF_2,
+ FN_ZORBA_POS_PRECEDING_IN_DOCUMENT_ORDER_OF_2,
+ FN_ZORBA_POS_FOLLOWING_IN_DOCUMENT_ORDER_OF_2,
+ FN_ZORBA_POS_LEVEL_1,
+ FN_ZORBA_POS_IS_ATTRIBUTE_1,
+ FN_ZORBA_POS_IS_COMMENT_1,
+ FN_ZORBA_POS_IS_DOCUMENT_1,
+ FN_ZORBA_POS_IS_ELEMENT_1,
+ FN_ZORBA_POS_IS_PROCESSING_INSTRUCTION_1,
+ FN_ZORBA_POS_IS_TEXT_1,
+ FN_ZORBA_POS_SIBLING_OF_2,
+ FN_ZORBA_POS_IN_SAME_TREE_OF_2,
+ FN_ZORBA_POS_IN_COLLECTION_1,
+ FN_ZORBA_POS_IN_SAME_COLLECTION_OF_2,
FN_ZORBA_REF_NODE_REFERENCE_1,
FN_ZORBA_REF_NODE_BY_REFERENCE_1,
FN_LOCAL_NAME_0,
=== modified file 'src/runtime/collections/collections_impl.cpp'
--- src/runtime/collections/collections_impl.cpp 2011-10-19 15:28:51 +0000
+++ src/runtime/collections/collections_impl.cpp 2011-11-04 19:40:32 +0000
@@ -554,15 +554,15 @@
// dynamic collections have some default properties
lAnn = new store::Annotation();
- lAnn->theName = theSctx->lookup_ann(StaticContextConsts::zann_mutable);
- lAnnotations.push_back(lAnn);
-
- lAnn = new store::Annotation();
- lAnn->theName = theSctx->lookup_ann(StaticContextConsts::zann_ordered);
- lAnnotations.push_back(lAnn);
-
- lAnn = new store::Annotation();
- lAnn->theName = theSctx->lookup_ann(StaticContextConsts::zann_mutable_nodes);
+ lAnn->theName = AnnotationInternal::lookup(AnnotationInternal::zann_mutable);
+ lAnnotations.push_back(lAnn);
+
+ lAnn = new store::Annotation();
+ lAnn->theName = AnnotationInternal::lookup(AnnotationInternal::zann_ordered);
+ lAnnotations.push_back(lAnn);
+
+ lAnn = new store::Annotation();
+ lAnn->theName = AnnotationInternal::lookup(AnnotationInternal::zann_mutable_nodes);
lAnnotations.push_back(lAnn);
pul->addCreateCollection(
@@ -584,9 +584,9 @@
lAnn->theName = lTmp->getQName();
- for (size_t j = 0; j < lTmp->getNumLiterals(); ++j)
+ for (csize j = 0; j < lTmp->getNumLiterals(); ++j)
{
- lAnn->theLiterals.push_back(lTmp->getLiteral(j)->getLiteralItem());
+ lAnn->theLiterals.push_back(lTmp->getLiteral(j));
}
lAnnotations.push_back(lAnn);
}
=== modified file 'src/runtime/core/flwor_iterator.cpp'
--- src/runtime/core/flwor_iterator.cpp 2011-06-28 15:07:06 +0000
+++ src/runtime/core/flwor_iterator.cpp 2011-11-04 19:40:32 +0000
@@ -18,6 +18,7 @@
#include "zorbautils/fatal.h"
#include "diagnostics/assert.h"
#include "diagnostics/xquery_diagnostics.h"
+#include "diagnostics/util_macros.h"
#include "context/static_context.h"
@@ -1474,9 +1475,9 @@
store::Item_t temp;
if (typedValueIter->next(temp))
{
- throw XQUERY_EXCEPTION(err::XPTY0004,
- ERROR_PARAMS(ZED(SingletonExpected_2o),
- ZED(AtomizationHasMoreThanOneValue)));
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(SingletonExpected_2o),
+ ZED(AtomizationHasMoreThanOneValue)));
}
}
}
@@ -1485,9 +1486,7 @@
store::Item_t temp;
if (consumeNext(temp, specIter->theInput, planState))
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004, ERROR_PARAMS(ZED(SingletonExpected_2o))
- );
+ RAISE_ERROR(err::XPTY0004, loc, ERROR_PARAMS(ZED(SingletonExpected_2o)));
}
}
=== modified file 'src/runtime/core/gflwor/common.cpp'
--- src/runtime/core/gflwor/common.cpp 2011-06-14 17:26:33 +0000
+++ src/runtime/core/gflwor/common.cpp 2011-11-04 19:40:32 +0000
@@ -43,11 +43,13 @@
GroupingSpec::GroupingSpec(
PlanIter_t inputVar,
const std::vector<PlanIter_t>& varRefs,
- const std::string& collation)
+ const std::string& collation,
+ bool doFastComparison)
:
theInput(inputVar),
theCollation(collation),
- theCollator(NULL)
+ theCollator(NULL),
+ theDoFastComparison(doFastComparison)
{
castIterVector<ForVarIterator>(theVarRefs, varRefs);
}
@@ -59,6 +61,7 @@
ar & theVarRefs;
ar & theCollation;
ar & theCollator;
+ ar & theDoFastComparison;
}
@@ -170,7 +173,7 @@
const QueryLoc& loc,
dynamic_context* dctx,
const TypeManager* tm,
- std::vector<GroupingSpec>* groupingSpecs)
+ std::vector<GroupingSpec>* groupingSpecs)
:
theLocation(loc),
theGroupingSpecs(groupingSpecs),
@@ -184,9 +187,9 @@
{
uint32_t hash = 0;
- ulong numCols = (ulong)theGroupingSpecs->size();
+ csize numCols = theGroupingSpecs->size();
- for (ulong i = 0; i < numCols; i++)
+ for (csize i = 0; i < numCols; i++)
{
if (t->theTypedValues[i] != NULL)
{
@@ -229,19 +232,30 @@
try
{
- if (!CompareIterator::valueEqual(theLocation,
- item1,
- item2,
- theTypeManager,
- theTimezone,
- (*theGroupingSpecs)[i].theCollator))
- {
- return false;
+ if ((*theGroupingSpecs)[i].theDoFastComparison)
+ {
+ if (!item1->equals(item2, theTimezone, (*theGroupingSpecs)[i].theCollator))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (!CompareIterator::valueEqual(theLocation,
+ item1,
+ item2,
+ theTypeManager,
+ theTimezone,
+ (*theGroupingSpecs)[i].theCollator))
+ {
+ return false;
+ }
}
}
catch (ZorbaException const& e)
{
- if (e.diagnostic() == err::XPTY0004)
+ if (e.diagnostic() == err::XPTY0004 ||
+ e.diagnostic() == zerr::ZSTR0040_TYPE_ERROR)
return false;
else
throw;
=== modified file 'src/runtime/core/gflwor/common.h'
--- src/runtime/core/gflwor/common.h 2011-06-14 17:26:33 +0000
+++ src/runtime/core/gflwor/common.h 2011-11-04 19:40:32 +0000
@@ -107,6 +107,7 @@
std::vector<ForVarIter_t> theVarRefs;
std::string theCollation;
XQPCollator * theCollator;
+ bool theDoFastComparison;
public:
SERIALIZABLE_CLASS(GroupingSpec)
@@ -119,7 +120,8 @@
GroupingSpec(
PlanIter_t inputVar,
const std::vector<PlanIter_t>& varRefs,
- const std::string& aCollation);
+ const std::string& aCollation,
+ bool doFastComparison);
virtual ~GroupingSpec() {}
=== modified file 'src/runtime/core/gflwor/groupby_iterator.cpp'
--- src/runtime/core/gflwor/groupby_iterator.cpp 2011-06-14 17:26:33 +0000
+++ src/runtime/core/gflwor/groupby_iterator.cpp 2011-11-04 19:40:32 +0000
@@ -18,6 +18,7 @@
#include "zorbautils/fatal.h"
#include "diagnostics/assert.h"
#include "diagnostics/xquery_diagnostics.h"
+#include "diagnostics/util_macros.h"
#include "context/static_context.h"
@@ -358,10 +359,10 @@
std::vector<store::Item_t>& groupTupleItems = groupTuple->theItems;
std::vector<store::Item_t>& groupTupleValues = groupTuple->theTypedValues;
- ulong numVars = (ulong)theGroupingSpecs.size();
+ csize numVars = theGroupingSpecs.size();
// For each grouping variable
- for (ulong i = 0; i < numVars; ++i)
+ for (csize i = 0; i < numVars; ++i)
{
groupTupleItems.push_back(NULL);
groupTupleValues.push_back(NULL);
@@ -379,11 +380,8 @@
// than 1 item.
if (consumeNext(temp, theGroupingSpecs[i].theInput.getp(), aPlanState))
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004,
- ERROR_PARAMS( ZED( GroupByVarHasMoreThanOneItem_2 ) ),
- ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(GroupByVarHasMoreThanOneItem_2)));
}
store::Iterator_t typedValueIter;
@@ -405,11 +403,8 @@
if (typedValueIter->next(temp))
{
- throw XQUERY_EXCEPTION(
- err::XPTY0004,
- ERROR_PARAMS( ZED( AtomizationOfGroupByMakesMoreThanOneItem ) ),
- ERROR_LOC( loc )
- );
+ RAISE_ERROR(err::XPTY0004, loc,
+ ERROR_PARAMS(ZED(AtomizationOfGroupByMakesMoreThanOneItem)));
}
}
}
=== modified file 'src/runtime/full_text/CMakeLists.txt'
--- src/runtime/full_text/CMakeLists.txt 2011-08-31 13:17:59 +0000
+++ src/runtime/full_text/CMakeLists.txt 2011-11-04 19:40:32 +0000
@@ -40,6 +40,7 @@
thesaurus.cpp
tokenizer.cpp
default_tokenizer.cpp
+ ft_module.cpp
)
IF (ZORBA_NO_UNICODE)
@@ -51,5 +52,5 @@
ADD_SRC_SUBFOLDER(FULLTEXT_SRCS stemmer LIBSTEMMER_SRCS)
IF (ZORBA_WITH_FILE_ACCESS)
- ADD_SRC_SUBFOLDER(FULLTEXT_SRCS thesauri THESAURUS_SRCS)
+ ADD_SRC_SUBFOLDER(FULLTEXT_SRCS thesauri THESAURUS_SRCS)
ENDIF (ZORBA_WITH_FILE_ACCESS)
=== added file 'src/runtime/full_text/ft_module_impl.cpp'
--- src/runtime/full_text/ft_module_impl.cpp 1970-01-01 00:00:00 +0000
+++ src/runtime/full_text/ft_module_impl.cpp 2011-11-04 19:40:32 +0000
@@ -0,0 +1,411 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <limits>
+
+#include "diagnostics/assert.h"
+#include "diagnostics/xquery_diagnostics.h"
+
+#include "zorbatypes/URI.h"
+
+#include "system/globalenv.h"
+
+#include "context/static_context.h"
+#include "context/namespace_context.h"
+
+#include "store/api/pul.h"
+#include "store/api/store.h"
+#include "store/api/item.h"
+#include "store/api/item_factory.h"
+#include "store/api/iterator_factory.h" // for creating the probe iterator
+#include "store/api/iterator.h"
+#include "store/api/index.h"
+
+#include "runtime/core/apply_updates.h"
+#include "runtime/api/plan_iterator_wrapper.h"
+
+#include "types/typeimpl.h"
+#include "types/typeops.h"
+#include "types/casting.h"
+
+#include "zorbautils/locale.h"
+
+#include "runtime/full_text/ft_module.h"
+#include "ft_stop_words_set.h"
+#include "thesaurus.h"
+#include "ft_util.h"
+
+using namespace std;
+using namespace zorba::locale;
+
+namespace zorba {
+
+///////////////////////////////////////////////////////////////////////////////
+
+static iso639_1::type get_lang_from( store::Item_t lang_item,
+ QueryLoc const &loc ) {
+ zstring lang_string;
+ lang_item->getStringValue2( lang_string );
+
+ if ( !GenericCast::instance()->castableToLanguage( lang_string ) )
+ throw XQUERY_EXCEPTION(
+ err::XPTY0004,
+ ERROR_PARAMS(
+ ZED( BadType_23o ), lang_string, ZED( NoCastTo_45o ), "xs:language"
+ ),
+ ERROR_LOC( loc )
+ );
+ if ( iso639_1::type lang = find_lang( lang_string.c_str() ) )
+ return lang;
+ throw XQUERY_EXCEPTION(
+ err::FTST0009, ERROR_PARAMS( lang_string ), ERROR_LOC( loc )
+ );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+bool HostLangIterator::nextImpl( store::Item_t &result,
+ PlanState &plan_state ) const {
+ iso639_1::type const lang = get_host_lang();
+ zstring lang_string = iso639_1::string_of[ lang ];
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT( PlanIteratorState, state, plan_state );
+
+ GENV_ITEMFACTORY->createLanguage( result, lang_string );
+ STACK_PUSH( true, state );
+
+ STACK_END( state );
+}
+
+bool IsStopWordIterator::nextImpl( store::Item_t &result,
+ PlanState &plan_state ) const {
+ store::Item_t item;
+ iso639_1::type lang;
+ ftmatch_options const *options;
+ static_context const *static_ctx;
+ ft_stop_words_set::ptr stop_words;
+ zstring word;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT( PlanIteratorState, state, plan_state );
+
+ static_ctx = getStaticContext();
+ options = static_ctx->get_match_options();
+ lang = get_lang_from( options );
+
+ if ( consumeNext( item, theChildren[0], plan_state ) ) {
+ item->getStringValue2( word );
+ if ( theChildren.size() > 1 ) {
+ ZORBA_ASSERT( consumeNext( item, theChildren[1], plan_state ) );
+ lang = get_lang_from( item, loc );
+ }
+ stop_words.reset( ft_stop_words_set::get_default( lang ) );
+ GENV_ITEMFACTORY->createBoolean( result, stop_words->contains( word ) );
+ STACK_PUSH( true, state );
+ }
+
+ STACK_END( state );
+}
+
+bool StemIterator::nextImpl( store::Item_t &result,
+ PlanState &plan_state ) const {
+ store::Item_t item;
+ iso639_1::type lang;
+ ftmatch_options const *options;
+ internal::StemmerProvider const *provider;
+ static_context const *static_ctx;
+ internal::Stemmer::ptr stemmer;
+ zstring word, stem;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT( PlanIteratorState, state, plan_state );
+
+ static_ctx = getStaticContext();
+ options = static_ctx->get_match_options();
+ lang = get_lang_from( options );
+
+ if ( consumeNext( item, theChildren[0], plan_state ) ) {
+ item->getStringValue2( word );
+ if ( theChildren.size() > 1 ) {
+ ZORBA_ASSERT( consumeNext( item, theChildren[1], plan_state ) );
+ lang = get_lang_from( item, loc );
+ }
+ provider = &internal::StemmerProvider::get_default();
+ stemmer = provider->get_stemmer( lang );
+ if ( stemmer ) {
+ stemmer->stem( word, lang, &stem );
+ GENV_ITEMFACTORY->createString( result, stem );
+ STACK_PUSH( true, state );
+ }
+ }
+
+ STACK_END( state );
+}
+
+bool StripDiacriticsIterator::nextImpl( store::Item_t &result,
+ PlanState &plan_state ) const {
+ store::Item_t item;
+ zstring phrase, stripped_phrase;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT( PlanIteratorState, state, plan_state );
+
+ if ( consumeNext( item, theChildren[0], plan_state ) ) {
+ item->getStringValue2( phrase );
+ utf8::strip_diacritics( phrase, &stripped_phrase );
+ GENV_ITEMFACTORY->createString( result, stripped_phrase );
+ STACK_PUSH( true, state );
+ }
+
+ STACK_END( state );
+}
+
+bool ThesaurusLookupIterator::nextImpl( store::Item_t &result,
+ PlanState &plan_state ) const {
+ vector<zstring> comp_uris;
+ store::Item_t item;
+ iso639_1::type lang;
+ ftmatch_options const *options;
+ zstring uri = "##default";
+ static_context const *static_ctx;
+ zstring synonym;
+
+ ThesaurusLookupIteratorState *state;
+ DEFAULT_STACK_INIT( ThesaurusLookupIteratorState, state, plan_state );
+
+ static_ctx = getStaticContext();
+ options = static_ctx->get_match_options();
+ lang = get_lang_from( options );
+ state->at_least_ = 0;
+ state->at_most_ = numeric_limits<internal::Thesaurus::level_type>::max();
+
+ if ( theChildren.size() == 1 ) {
+ ZORBA_ASSERT( consumeNext( item, theChildren[0], plan_state ) );
+ item->getStringValue2( state->phrase_ );
+ } else if ( theChildren.size() > 1 ) {
+ ZORBA_ASSERT( consumeNext( item, theChildren[0], plan_state ) );
+ item->getStringValue2( uri );
+ ZORBA_ASSERT( consumeNext( item, theChildren[1], plan_state ) );
+ item->getStringValue2( state->phrase_ );
+ if ( theChildren.size() > 2 ) {
+ ZORBA_ASSERT( consumeNext( item, theChildren[2], plan_state ) );
+ lang = get_lang_from( item, loc );
+ if ( theChildren.size() > 3 ) {
+ ZORBA_ASSERT( consumeNext( item, theChildren[3], plan_state ) );
+ item->getStringValue2( state->relationship_ );
+ if ( theChildren.size() > 4 ) {
+ ZORBA_ASSERT( theChildren.size() == 6 );
+ ZORBA_ASSERT( consumeNext( item, theChildren[4], plan_state ) );
+ state->at_least_ = item->getUnsignedIntValue();
+ ZORBA_ASSERT( consumeNext( item, theChildren[5], plan_state ) );
+ state->at_most_ = item->getUnsignedIntValue();
+ }
+ }
+ }
+ }
+
+ static_ctx->get_component_uris( uri, impl::EntityData::THESAURUS, comp_uris );
+ if ( comp_uris.size() != 1 )
+ throw XQUERY_EXCEPTION(
+ err::FTST0018, ERROR_PARAMS( uri ), ERROR_LOC( loc )
+ );
+
+ state->thesaurus_ = std::move(
+ static_ctx->get_thesaurus( comp_uris.front(), lang )
+ );
+ ZORBA_ASSERT( state->thesaurus_.get() );
+ state->tresult_ = std::move(
+ state->thesaurus_->lookup(
+ state->phrase_, state->relationship_, state->at_least_, state->at_most_
+ )
+ );
+ ZORBA_ASSERT( state->tresult_.get() );
+
+ while ( state->tresult_->next( &synonym ) ) {
+ GENV_ITEMFACTORY->createString( result, synonym );
+ STACK_PUSH( true, state );
+ }
+
+ STACK_END( state );
+}
+
+void ThesaurusLookupIterator::resetImpl( PlanState &plan_state ) const {
+ NaryBaseIterator<ThesaurusLookupIterator,ThesaurusLookupIteratorState>::
+ resetImpl( plan_state );
+ ThesaurusLookupIteratorState *const state =
+ StateTraitsImpl<ThesaurusLookupIteratorState>::getState(
+ plan_state, this->theStateOffset
+ );
+ state->tresult_ = std::move(
+ state->thesaurus_->lookup(
+ state->phrase_, state->relationship_, state->at_least_, state->at_most_
+ )
+ );
+ ZORBA_ASSERT( state->tresult_.get() );
+}
+
+bool TokenizeIterator::nextImpl( store::Item_t &result,
+ PlanState &plan_state ) const {
+ store::Item_t attr_name, attr_node;
+ zstring base_uri = static_context::ZORBA_FULL_TEXT_FN_NS;
+ store::Item_t item;
+ iso639_1::type lang;
+ Tokenizer::Numbers no;
+ store::NsBindings const ns_bindings;
+ ftmatch_options const *options;
+ static_context const *static_ctx;
+ TokenizerProvider const *tokenizer_provider;
+ store::Item_t type_name;
+ zstring value_string;
+
+ TokenizeIteratorState *state;
+ DEFAULT_STACK_INIT( TokenizeIteratorState, state, plan_state );
+
+ static_ctx = getStaticContext();
+ options = static_ctx->get_match_options();
+ lang = get_lang_from( options );
+
+ if ( consumeNext( state->doc_item_, theChildren[0], plan_state ) ) {
+ if ( theChildren.size() > 1 ) {
+ ZORBA_ASSERT( consumeNext( item, theChildren[1], plan_state ) );
+ lang = get_lang_from( item, loc );
+ }
+
+ tokenizer_provider = GENV_STORE.getTokenizerProvider();
+ state->doc_tokens_ =
+ state->doc_item_->getTokens( *tokenizer_provider, no, lang );
+
+ while ( state->doc_tokens_->hasNext() ) {
+ FTToken const *token;
+ token = state->doc_tokens_->next();
+ ZORBA_ASSERT( token );
+
+ if ( state->token_qname_.isNull() )
+ GENV_ITEMFACTORY->createQName(
+ state->token_qname_, static_context::ZORBA_FULL_TEXT_FN_NS, "",
+ "token"
+ );
+
+ type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
+ GENV_ITEMFACTORY->createElementNode(
+ result, nullptr, state->token_qname_, type_name, true, false,
+ ns_bindings, base_uri
+ );
+
+ if ( token->lang() ) {
+ value_string = iso639_1::string_of[ token->lang() ];
+ type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
+ GENV_ITEMFACTORY->createQName( attr_name, "", "", "lang" );
+ GENV_ITEMFACTORY->createString( item, value_string );
+ GENV_ITEMFACTORY->createAttributeNode(
+ attr_node, result, attr_name, type_name, item
+ );
+ }
+
+ ztd::to_string( token->para(), &value_string );
+ type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
+ GENV_ITEMFACTORY->createQName( attr_name, "", "", "paragraph" );
+ GENV_ITEMFACTORY->createString( item, value_string );
+ GENV_ITEMFACTORY->createAttributeNode(
+ attr_node, result, attr_name, type_name, item
+ );
+
+ ztd::to_string( token->sent(), &value_string );
+ type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
+ GENV_ITEMFACTORY->createQName( attr_name, "", "", "sentence" );
+ GENV_ITEMFACTORY->createString( item, value_string );
+ GENV_ITEMFACTORY->createAttributeNode(
+ attr_node, result, attr_name, type_name, item
+ );
+
+ value_string = token->value();
+ type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
+ GENV_ITEMFACTORY->createQName( attr_name, "", "", "value" );
+ GENV_ITEMFACTORY->createString( item, value_string );
+ GENV_ITEMFACTORY->createAttributeNode(
+ attr_node, result, attr_name, type_name, item
+ );
+
+ STACK_PUSH( true, state );
+ }
+ }
+
+ STACK_END( state );
+}
+
+void TokenizeIterator::resetImpl( PlanState &plan_state ) const {
+ NaryBaseIterator<TokenizeIterator,TokenizeIteratorState>::
+ resetImpl( plan_state );
+ TokenizeIteratorState *const state =
+ StateTraitsImpl<TokenizeIteratorState>::getState(
+ plan_state, this->theStateOffset
+ );
+ state->doc_tokens_->reset();
+}
+
+bool TokenizerPropertiesIterator::nextImpl( store::Item_t &result,
+ PlanState &plan_state ) const {
+ store::Item_t attr_name, attr_node, item;
+ zstring base_uri = static_context::ZORBA_FULL_TEXT_FN_NS;
+ iso639_1::type lang;
+ Tokenizer::Numbers no;
+ store::NsBindings const ns_bindings;
+ ftmatch_options const *options;
+ static_context const *static_ctx;
+ Tokenizer::ptr tokenizer;
+ store::Item_t type_name;
+ Tokenizer::Properties props;
+ TokenizerProvider const *tokenizer_provider;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT( PlanIteratorState, state, plan_state );
+
+ static_ctx = getStaticContext();
+ options = static_ctx->get_match_options();
+ lang = get_lang_from( options );
+
+ if ( !theChildren.empty() ) {
+ ZORBA_ASSERT( consumeNext( item, theChildren[0], plan_state ) );
+ lang = get_lang_from( item, loc );
+ }
+
+ tokenizer_provider = GENV_STORE.getTokenizerProvider();
+ tokenizer = tokenizer_provider->getTokenizer( lang, no );
+ tokenizer->properties( &props );
+
+ GENV_ITEMFACTORY->createQName(
+ item, static_context::ZORBA_FULL_TEXT_FN_NS, "", "tokenizer-properties"
+ );
+ type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
+ GENV_ITEMFACTORY->createElementNode(
+ result, nullptr, item, type_name, true, false, ns_bindings, base_uri
+ );
+
+ GENV_ITEMFACTORY->createQName( attr_name, "", "", "elements-separate-tokens" );
+ GENV_ITEMFACTORY->createBoolean( item, props.elements_separate_tokens );
+ GENV_ITEMFACTORY->createAttributeNode(
+ attr_node, result, attr_name, type_name, item
+ );
+
+ STACK_PUSH( true, state );
+ STACK_END( state );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+} // namespace zorba
+/* vim:set et sw=2 ts=2: */
=== modified file 'src/runtime/full_text/ft_stop_words_set.cpp'
--- src/runtime/full_text/ft_stop_words_set.cpp 2011-07-22 07:23:17 +0000
+++ src/runtime/full_text/ft_stop_words_set.cpp 2011-11-04 19:40:32 +0000
@@ -72,7 +72,7 @@
///////////////////////////////////////////////////////////////////////////////
-void ft_stop_words_set::apply_word( zstring const &word, set_t &word_set,
+void ft_stop_words_set::apply_word( zstring const &word, word_set_t &word_set,
ft_stop_words_unex::type mode ) {
// TODO: should "word" be converted to lower-case?
std::cout << "applying word " << word << std::endl;
@@ -87,33 +87,33 @@
}
void ft_stop_words_set::apply_word( char const *begin, char const *end,
- set_t &word_set,
+ word_set_t &word_set,
ft_stop_words_unex::type mode ) {
- set_t::value_type const word( begin, end - begin );
+ word_set_t::value_type const word( begin, end - begin );
apply_word( word, word_set, mode );
}
-ft_stop_words_set const*
+ft_stop_words_set::ptr
ft_stop_words_set::construct( ftstop_word_option const &option,
iso639_1::type lang,
static_context const& sctx ) {
bool must_delete = false;
- set_t *word_set = nullptr; // pointless init. to stifle warning
+ word_set_t *word_set = nullptr; // pointless init. to stifle warning
switch ( option.get_mode() ) {
case ft_stop_words_mode::with:
- word_set = new set_t;
+ word_set = new word_set_t;
must_delete = true;
break;
case ft_stop_words_mode::with_default:
word_set = get_default_word_set_for( lang );
if ( !word_set ) {
// TODO: throw exception?
- return 0;
+ return ptr();
}
break;
case ft_stop_words_mode::without:
- return 0;
+ return ptr();
}
FOR_EACH( ftstop_word_option::list_t, ftsw, option.get_stop_words() ) {
@@ -122,7 +122,7 @@
if ( !uri.empty() ) {
if ( !must_delete ) {
- word_set = new set_t( *word_set );
+ word_set = new word_set_t( *word_set );
must_delete = true;
}
@@ -167,25 +167,30 @@
ftstop_words::list_t const &word_list = (*ftsw)->get_list();
if ( !word_list.empty() ) {
if ( !must_delete ) {
- word_set = new set_t( *word_set );
+ word_set = new word_set_t( *word_set );
must_delete = true;
}
FOR_EACH( ftstop_words::list_t, word, word_list )
apply_word( *word, *word_set, mode );
}
}
- return new ft_stop_words_set( word_set, must_delete );
-}
-
-ft_stop_words_set::set_t*
+ return ptr( new ft_stop_words_set( word_set, must_delete ) );
+}
+
+ft_stop_words_set const*
+ft_stop_words_set::get_default( iso639_1::type lang ) {
+ return new ft_stop_words_set( get_default_word_set_for( lang ), false );
+}
+
+ft_stop_words_set::word_set_t*
ft_stop_words_set::get_default_word_set_for( iso639_1::type lang ) {
- static set_t* cached_word_sets[ iso639_1::NUM_ENTRIES ];
+ static word_set_t *cached_word_sets[ iso639_1::NUM_ENTRIES ];
if ( !lang )
lang = get_host_lang();
- set_t *&word_set = cached_word_sets[ lang ];
+ word_set_t *&word_set = cached_word_sets[ lang ];
if ( !word_set ) {
if ( ft_stop_table const table = get_table_for( lang ) ) {
- word_set = new set_t;
+ word_set = new word_set_t;
for ( ft_stop_table word = table; *word; ++word )
word_set->insert( *word );
}
=== modified file 'src/runtime/full_text/ft_stop_words_set.h'
--- src/runtime/full_text/ft_stop_words_set.h 2011-06-26 09:43:12 +0000
+++ src/runtime/full_text/ft_stop_words_set.h 2011-11-04 19:40:32 +0000
@@ -20,6 +20,7 @@
#include <set>
#include <zorba/locale.h>
+#include <zorba/internal/unique_ptr.h>
#include "compiler/expression/ftnode.h"
#include "zorbatypes/zstring.h"
@@ -31,6 +32,8 @@
*/
class ft_stop_words_set {
public:
+ typedef std::unique_ptr<ft_stop_words_set const> ptr;
+
~ft_stop_words_set() {
if ( delete_ )
delete word_set_;
@@ -44,9 +47,9 @@
* @param lang The language of the stop-words.
* @return Returns a new %ft_stop_words_set.
*/
- static ft_stop_words_set const* construct( ftstop_word_option const &option,
- locale::iso639_1::type lang,
- static_context const& sctx );
+ static ptr construct( ftstop_word_option const &option,
+ locale::iso639_1::type lang,
+ static_context const& sctx );
/**
* Checks whether this %ft_stop_words_set contains the given word.
@@ -60,22 +63,32 @@
return word_set_->find( word ) != word_set_->end();
}
+ /**
+ * Gets the default %ft_stop_words_set.
+ *
+ * @param lang The language of the stop-words.
+ * @return Returns said default.
+ */
+ static ft_stop_words_set const* get_default( locale::iso639_1::type lang );
+
private:
- typedef std::set<zstring> set_t;
+ typedef std::set<zstring> word_set_t;
- set_t const *const word_set_;
+ word_set_t const *const word_set_;
bool const delete_;
- ft_stop_words_set( set_t const *word_set, bool must_delete ) :
+ ft_stop_words_set( word_set_t const *word_set, bool must_delete ) :
word_set_( word_set ), delete_( must_delete )
{
}
- static void apply_word( zstring const&, set_t&, ft_stop_words_unex::type );
- static void apply_word( char const*, char const*, set_t&,
- ft_stop_words_unex::type );
-
- static set_t* get_default_word_set_for( locale::iso639_1::type );
+ static void apply_word( zstring const&, word_set_t&,
+ ft_stop_words_unex::type );
+
+ static void apply_word( char const*, char const*, word_set_t&,
+ ft_stop_words_unex::type );
+
+ static word_set_t* get_default_word_set_for( locale::iso639_1::type );
// forbid these
ft_stop_words_set( ft_stop_words_set const& );
=== modified file 'src/runtime/full_text/ft_token_matcher.cpp'
--- src/runtime/full_text/ft_token_matcher.cpp 2011-08-25 15:54:19 +0000
+++ src/runtime/full_text/ft_token_matcher.cpp 2011-11-04 19:40:32 +0000
@@ -47,12 +47,12 @@
return false;
}
-inline ft_stop_words_set const* get_stop_words( ftmatch_options const &options,
- iso639_1::type lang,
- static_context const& sctx ) {
+inline ft_stop_words_set::ptr
+get_stop_words( ftmatch_options const &options, iso639_1::type lang,
+ static_context const& sctx ) {
if ( ftstop_word_option const *const sw = options.get_stop_word_option() )
return ft_stop_words_set::construct( *sw, lang, sctx );
- return nullptr;
+ return ft_stop_words_set::ptr();
}
///////////////////////////////////////////////////////////////////////////////
@@ -69,7 +69,7 @@
}
ft_token_matcher::~ft_token_matcher() {
- delete stop_words_;
+ // out-of-line since it's virtual
}
///////////////////////////////////////////////////////////////////////////////
=== modified file 'src/runtime/full_text/ft_token_matcher.h'
--- src/runtime/full_text/ft_token_matcher.h 2011-08-30 19:11:59 +0000
+++ src/runtime/full_text/ft_token_matcher.h 2011-11-04 19:40:32 +0000
@@ -62,7 +62,7 @@
locale::iso639_1::type const lang_;
bool const stemming_;
match_stemmer const stemmer_;
- ft_stop_words_set const *const stop_words_;
+ ft_stop_words_set::ptr stop_words_;
bool const wildcards_;
};
=== modified file 'src/runtime/full_text/icu_tokenizer.cpp'
--- src/runtime/full_text/icu_tokenizer.cpp 2011-10-03 09:18:49 +0000
+++ src/runtime/full_text/icu_tokenizer.cpp 2011-11-04 19:40:32 +0000
@@ -16,6 +16,7 @@
#include "stdafx.h"
#include <cctype>
+#include <cstring>
#include <unicode/unistr.h>
#define DEBUG_TOKENIZER 0
@@ -158,6 +159,11 @@
delete this;
}
+void ICU_Tokenizer::properties( Properties *p ) const {
+ ::memset( p, 0, sizeof( Properties ) );
+ p->elements_separate_tokens = true;
+}
+
#define HANDLE_BACKSLASH() \
if ( !got_backslash ) ; else { \
got_backslash = in_wild = false; \
=== modified file 'src/runtime/full_text/icu_tokenizer.h'
--- src/runtime/full_text/icu_tokenizer.h 2011-09-05 02:06:22 +0000
+++ src/runtime/full_text/icu_tokenizer.h 2011-11-04 19:40:32 +0000
@@ -48,6 +48,7 @@
// inherited
void destroy() const;
+ void properties( Properties* ) const;
void tokenize( char const*, size_type, locale::iso639_1::type, bool,
Callback&, void* );
=== added directory 'src/runtime/full_text/pregenerated'
=== added file 'src/runtime/full_text/pregenerated/ft_module.cpp'
--- src/runtime/full_text/pregenerated/ft_module.cpp 1970-01-01 00:00:00 +0000
+++ src/runtime/full_text/pregenerated/ft_module.cpp 2011-11-04 19:40:32 +0000
@@ -0,0 +1,251 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ******************************************
+// * *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME *
+// * *
+// ******************************************
+
+#include "stdafx.h"
+#include "zorbatypes/rchandle.h"
+#include "zorbatypes/zstring.h"
+#include "runtime/visitors/planiter_visitor.h"
+#include "runtime/full_text/ft_module.h"
+#include "system/globalenv.h"
+
+
+#include "store/api/iterator.h"
+
+namespace zorba {
+
+// <HostLangIterator>
+const char* HostLangIterator::class_name_str = "HostLangIterator";
+HostLangIterator::class_factory<HostLangIterator>
+HostLangIterator::g_class_factory;
+
+const serialization::ClassVersion
+HostLangIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int HostLangIterator::class_versions_count =
+sizeof(HostLangIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void HostLangIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+HostLangIterator::~HostLangIterator() {}
+
+// </HostLangIterator>
+
+
+// <IsStopWordIterator>
+const char* IsStopWordIterator::class_name_str = "IsStopWordIterator";
+IsStopWordIterator::class_factory<IsStopWordIterator>
+IsStopWordIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsStopWordIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsStopWordIterator::class_versions_count =
+sizeof(IsStopWordIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsStopWordIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsStopWordIterator::~IsStopWordIterator() {}
+
+// </IsStopWordIterator>
+
+
+// <StemIterator>
+const char* StemIterator::class_name_str = "StemIterator";
+StemIterator::class_factory<StemIterator>
+StemIterator::g_class_factory;
+
+const serialization::ClassVersion
+StemIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int StemIterator::class_versions_count =
+sizeof(StemIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void StemIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+StemIterator::~StemIterator() {}
+
+// </StemIterator>
+
+
+// <StripDiacriticsIterator>
+const char* StripDiacriticsIterator::class_name_str = "StripDiacriticsIterator";
+StripDiacriticsIterator::class_factory<StripDiacriticsIterator>
+StripDiacriticsIterator::g_class_factory;
+
+const serialization::ClassVersion
+StripDiacriticsIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int StripDiacriticsIterator::class_versions_count =
+sizeof(StripDiacriticsIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void StripDiacriticsIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+StripDiacriticsIterator::~StripDiacriticsIterator() {}
+
+// </StripDiacriticsIterator>
+
+
+// <ThesaurusLookupIterator>
+const char* ThesaurusLookupIterator::class_name_str = "ThesaurusLookupIterator";
+ThesaurusLookupIterator::class_factory<ThesaurusLookupIterator>
+ThesaurusLookupIterator::g_class_factory;
+
+const serialization::ClassVersion
+ThesaurusLookupIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int ThesaurusLookupIterator::class_versions_count =
+sizeof(ThesaurusLookupIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void ThesaurusLookupIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+ThesaurusLookupIterator::~ThesaurusLookupIterator() {}
+
+ThesaurusLookupIteratorState::ThesaurusLookupIteratorState() {}
+
+ThesaurusLookupIteratorState::~ThesaurusLookupIteratorState() {}
+
+
+void ThesaurusLookupIteratorState::reset(PlanState& planState) {
+ PlanIteratorState::reset(planState);
+}
+// </ThesaurusLookupIterator>
+
+
+// <TokenizeIterator>
+const char* TokenizeIterator::class_name_str = "TokenizeIterator";
+TokenizeIterator::class_factory<TokenizeIterator>
+TokenizeIterator::g_class_factory;
+
+const serialization::ClassVersion
+TokenizeIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int TokenizeIterator::class_versions_count =
+sizeof(TokenizeIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void TokenizeIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+TokenizeIterator::~TokenizeIterator() {}
+
+TokenizeIteratorState::TokenizeIteratorState() {}
+
+TokenizeIteratorState::~TokenizeIteratorState() {}
+
+
+void TokenizeIteratorState::reset(PlanState& planState) {
+ PlanIteratorState::reset(planState);
+}
+// </TokenizeIterator>
+
+
+// <TokenizerPropertiesIterator>
+const char* TokenizerPropertiesIterator::class_name_str = "TokenizerPropertiesIterator";
+TokenizerPropertiesIterator::class_factory<TokenizerPropertiesIterator>
+TokenizerPropertiesIterator::g_class_factory;
+
+const serialization::ClassVersion
+TokenizerPropertiesIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int TokenizerPropertiesIterator::class_versions_count =
+sizeof(TokenizerPropertiesIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void TokenizerPropertiesIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+TokenizerPropertiesIterator::~TokenizerPropertiesIterator() {}
+
+// </TokenizerPropertiesIterator>
+
+
+
+}
+
+
=== added file 'src/runtime/full_text/pregenerated/ft_module.h'
--- src/runtime/full_text/pregenerated/ft_module.h 1970-01-01 00:00:00 +0000
+++ src/runtime/full_text/pregenerated/ft_module.h 2011-11-04 19:40:32 +0000
@@ -0,0 +1,316 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ******************************************
+// * *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME *
+// * *
+// ******************************************
+#ifndef ZORBA_RUNTIME_FULL_TEXT_FT_MODULE_H
+#define ZORBA_RUNTIME_FULL_TEXT_FT_MODULE_H
+
+
+#include "common/shared_types.h"
+
+
+
+#include "runtime/base/narybase.h"
+#include "runtime/full_text/thesaurus.h"
+
+
+namespace zorba {
+
+/**
+ *
+ * Author:
+ */
+class HostLangIterator : public NaryBaseIterator<HostLangIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(HostLangIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(HostLangIterator,
+ NaryBaseIterator<HostLangIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<HostLangIterator, PlanIteratorState>*)this);
+ }
+
+ HostLangIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<HostLangIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~HostLangIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author:
+ */
+class IsStopWordIterator : public NaryBaseIterator<IsStopWordIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsStopWordIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsStopWordIterator,
+ NaryBaseIterator<IsStopWordIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsStopWordIterator, PlanIteratorState>*)this);
+ }
+
+ IsStopWordIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsStopWordIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsStopWordIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author:
+ */
+class StemIterator : public NaryBaseIterator<StemIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(StemIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(StemIterator,
+ NaryBaseIterator<StemIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<StemIterator, PlanIteratorState>*)this);
+ }
+
+ StemIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<StemIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~StemIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author:
+ */
+class StripDiacriticsIterator : public NaryBaseIterator<StripDiacriticsIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(StripDiacriticsIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(StripDiacriticsIterator,
+ NaryBaseIterator<StripDiacriticsIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<StripDiacriticsIterator, PlanIteratorState>*)this);
+ }
+
+ StripDiacriticsIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<StripDiacriticsIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~StripDiacriticsIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author:
+ */
+class ThesaurusLookupIteratorState : public PlanIteratorState
+{
+public:
+ zstring phrase_; //
+ zstring relationship_; //
+ internal::Thesaurus::level_type at_least_; //
+ internal::Thesaurus::level_type at_most_; //
+ internal::Thesaurus::ptr thesaurus_; //
+ internal::Thesaurus::iterator::ptr tresult_; //
+
+ ThesaurusLookupIteratorState();
+
+ ~ThesaurusLookupIteratorState();
+
+ void reset(PlanState&);
+};
+
+class ThesaurusLookupIterator : public NaryBaseIterator<ThesaurusLookupIterator, ThesaurusLookupIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(ThesaurusLookupIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(ThesaurusLookupIterator,
+ NaryBaseIterator<ThesaurusLookupIterator, ThesaurusLookupIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<ThesaurusLookupIterator, ThesaurusLookupIteratorState>*)this);
+ }
+
+ ThesaurusLookupIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<ThesaurusLookupIterator, ThesaurusLookupIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~ThesaurusLookupIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+
+ void resetImpl(PlanState&) const;
+};
+
+
+/**
+ *
+ * Author:
+ */
+class TokenizeIteratorState : public PlanIteratorState
+{
+public:
+ store::Item_t doc_item_; //
+ FTTokenIterator_t doc_tokens_; //
+ store::Item_t token_qname_; //
+
+ TokenizeIteratorState();
+
+ ~TokenizeIteratorState();
+
+ void reset(PlanState&);
+};
+
+class TokenizeIterator : public NaryBaseIterator<TokenizeIterator, TokenizeIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(TokenizeIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(TokenizeIterator,
+ NaryBaseIterator<TokenizeIterator, TokenizeIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<TokenizeIterator, TokenizeIteratorState>*)this);
+ }
+
+ TokenizeIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<TokenizeIterator, TokenizeIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~TokenizeIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+
+ void resetImpl(PlanState&) const;
+};
+
+
+/**
+ *
+ * Author:
+ */
+class TokenizerPropertiesIterator : public NaryBaseIterator<TokenizerPropertiesIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(TokenizerPropertiesIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(TokenizerPropertiesIterator,
+ NaryBaseIterator<TokenizerPropertiesIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<TokenizerPropertiesIterator, PlanIteratorState>*)this);
+ }
+
+ TokenizerPropertiesIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<TokenizerPropertiesIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~TokenizerPropertiesIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+}
+#endif
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */
=== modified file 'src/runtime/full_text/thesauri/wn_thesaurus.cpp'
--- src/runtime/full_text/thesauri/wn_thesaurus.cpp 2011-08-31 13:17:59 +0000
+++ src/runtime/full_text/thesauri/wn_thesaurus.cpp 2011-11-04 19:40:32 +0000
@@ -70,8 +70,10 @@
* broad, hence if at_most specifies "all levels" (max int), clamp it at 2
* (which seems to work well in practice).
*/
-inline ft_int fix_at_most( ft_int at_most ) {
- return at_most == numeric_limits<ft_int>::max() ? 2 : at_most;
+inline internal::Thesaurus::level_type
+fix_at_most( internal::Thesaurus::level_type at_most ) {
+ return at_most == numeric_limits<internal::Thesaurus::level_type>::max() ?
+ 2 : at_most;
}
/**
@@ -233,8 +235,8 @@
thesaurus::iterator::LevelMarker = make_pair( ~0u, iso2788::neutral );
thesaurus::iterator::iterator( thesaurus const &t, char const *p,
- pointer::type ptr_type, ft_int at_least,
- ft_int at_most ) :
+ pointer::type ptr_type, level_type at_least,
+ level_type at_most ) :
thesaurus_( t ), query_ptr_type_( ptr_type ),
at_least_( at_least ), at_most_( fix_at_most( at_most ) ), level_( 0 )
{
@@ -506,7 +508,7 @@
thesaurus::iterator::ptr
thesaurus::lookup( zstring const &phrase, zstring const &relationship,
- ft_int at_least, ft_int at_most ) const {
+ level_type at_least, level_type at_most ) const {
iterator::ptr result;
# if DEBUG_FT_THESAURUS
cout << "==================================================" << endl;
=== modified file 'src/runtime/full_text/thesauri/wn_thesaurus.h'
--- src/runtime/full_text/thesauri/wn_thesaurus.h 2011-08-31 13:17:59 +0000
+++ src/runtime/full_text/thesauri/wn_thesaurus.h 2011-11-04 19:40:32 +0000
@@ -44,7 +44,8 @@
// inherited
void destroy() const;
- iterator::ptr lookup( zstring const&, zstring const&, ft_int, ft_int ) const;
+ iterator::ptr lookup( zstring const&, zstring const&, level_type,
+ level_type ) const;
private:
/**
@@ -86,7 +87,7 @@
private:
iterator( thesaurus const&, char const *lemma, pointer::type,
- ft_int at_least, ft_int at_most );
+ level_type at_least, level_type at_most );
~iterator();
thesaurus const &thesaurus_;
@@ -97,8 +98,8 @@
*/
pointer::type query_ptr_type_;
- ft_int const at_least_, at_most_;
- ft_int level_;
+ level_type const at_least_, at_most_;
+ level_type level_;
typedef std::pair<synset_id_t,iso2788::rel_dir> candidate_t;
typedef std::deque<candidate_t> candidate_queue_t;
=== modified file 'src/runtime/full_text/thesauri/xqftts_thesaurus.cpp'
--- src/runtime/full_text/thesauri/xqftts_thesaurus.cpp 2011-08-31 13:17:59 +0000
+++ src/runtime/full_text/thesauri/xqftts_thesaurus.cpp 2011-11-04 19:40:32 +0000
@@ -60,8 +60,8 @@
make_pair( static_cast<synonym*>(0), iso2788::neutral );
thesaurus::iterator::iterator( thesaurus_t const &t, zstring const &phrase,
- zstring const &rel_string, ft_int at_least,
- ft_int at_most ) :
+ zstring const &rel_string, level_type at_least,
+ level_type at_most ) :
thesaurus_( t ), at_least_( at_least ), at_most_( at_most ), level_( 1 )
{
using namespace iso2788;
@@ -217,7 +217,7 @@
thesaurus::iterator::ptr
thesaurus::lookup( zstring const &phrase, zstring const &relationship,
- ft_int at_least, ft_int at_most ) const {
+ level_type at_least, level_type at_most ) const {
# if DEBUG_THESAURUS
cout << "==================================================" << endl;
cout << "query phrase: " << phrase << endl;
=== modified file 'src/runtime/full_text/thesauri/xqftts_thesaurus.h'
--- src/runtime/full_text/thesauri/xqftts_thesaurus.h 2011-08-31 13:17:59 +0000
+++ src/runtime/full_text/thesauri/xqftts_thesaurus.h 2011-11-04 19:40:32 +0000
@@ -44,7 +44,8 @@
// inherited
void destroy() const;
- iterator::ptr lookup( zstring const&, zstring const&, ft_int, ft_int ) const;
+ iterator::ptr lookup( zstring const&, zstring const&, level_type,
+ level_type ) const;
private:
//
@@ -123,13 +124,14 @@
private:
iterator( thesaurus_t const&, zstring const &phrase,
- zstring const &relationship, ft_int at_least, ft_int at_most );
+ zstring const &relationship, level_type at_least,
+ level_type at_most );
~iterator();
thesaurus_t const &thesaurus_;
- ft_int const at_least_, at_most_;
- ft_int level_;
+ level_type const at_least_, at_most_;
+ level_type level_;
typedef std::pair<synonym const*,iso2788::rel_dir> candidate_t;
typedef std::deque<candidate_t> candidate_queue_t;
=== modified file 'src/runtime/full_text/thesaurus.h'
--- src/runtime/full_text/thesaurus.h 2011-08-31 13:17:59 +0000
+++ src/runtime/full_text/thesaurus.h 2011-11-04 19:40:32 +0000
@@ -35,6 +35,7 @@
*/
class Thesaurus {
public:
+ typedef ft_int level_type;
typedef std::unique_ptr<Thesaurus,ztd::destroy_delete<Thesaurus> > ptr;
/**
@@ -81,8 +82,9 @@
* the phrase was not found.
*/
virtual iterator::ptr lookup( zstring const &phrase,
- zstring const &relationship, ft_int at_least,
- ft_int at_most ) const = 0;
+ zstring const &relationship,
+ level_type at_least,
+ level_type at_most ) const = 0;
protected:
Thesaurus() { }
=== modified file 'src/runtime/indexing/index_ddl.cpp'
--- src/runtime/indexing/index_ddl.cpp 2011-10-05 17:49:48 +0000
+++ src/runtime/indexing/index_ddl.cpp 2011-11-04 19:40:32 +0000
@@ -135,11 +135,11 @@
{
const std::vector<xqtref_t>& keyTypes(indexDecl->getKeyTypes());
const std::vector<OrderModifier>& keyModifiers(indexDecl->getOrderModifiers());
- ulong numColumns = (ulong)keyTypes.size();
+ csize numColumns = keyTypes.size();
spec.resize(numColumns);
- for (ulong i = 0; i < numColumns; ++i)
+ for (csize i = 0; i < numColumns; ++i)
{
if (keyTypes[i] != NULL)
{
@@ -156,11 +156,11 @@
spec.theIsThreadSafe = true;
spec.theIsAutomatic = indexDecl->getMaintenanceMode() != IndexDecl::MANUAL;
- ulong numSources = (ulong)indexDecl->numSources();
+ csize numSources = indexDecl->numSources();
spec.theSources.resize(numSources);
- for (ulong i = 0; i < numSources; ++i)
+ for (csize i = 0; i < numSources; ++i)
{
spec.theSources[i] = const_cast<store::Item*>(indexDecl->getSourceName(i));
}
@@ -545,7 +545,10 @@
/*******************************************************************************
- ProbeIndexPointValueIterator
+ probe-index-point-value($indexName as xs:QName,
+ $key1 as anyAtomic?,
+ ...,
+ $keyN as anyAtomic?) as node()*
********************************************************************************/
ProbeIndexPointValueIteratorState::ProbeIndexPointValueIteratorState()
@@ -634,7 +637,12 @@
if (state->theIndexDecl->getKeyExpressions().size() != numChildren-1)
{
RAISE_ERROR(zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, loc,
- ERROR_PARAMS(qnameItem->getStringValue()));
+ ERROR_PARAMS(
+ qnameItem->getStringValue(),
+ "index",
+ numChildren-1,
+ state->theIndexDecl->getKeyExpressions().size())
+ );
}
state->theIndex = (state->theIndexDecl->isTemp() ?
@@ -720,7 +728,7 @@
/*******************************************************************************
ProbeIndexPointGeneralIterator
- fn-zorba-ddl:probe-index-point-general(
+ probe-index-point-general(
$indexName as xs:QName,
$keys as xs:anyAtomicItem*) as node()*
@@ -800,7 +808,12 @@
numChildren != 2)
{
RAISE_ERROR(zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, loc,
- ERROR_PARAMS(qnameItem->getStringValue()));
+ ERROR_PARAMS(
+ qnameItem->getStringValue(),
+ "index",
+ numChildren-1,
+ state->theIndexDecl->getKeyExpressions().size())
+ );
}
state->theIndex = (state->theIndexDecl->isTemp() ?
@@ -874,7 +887,24 @@
/*******************************************************************************
- ProbeIndexRangeValueIterator
+
+ probe-index-range-value($indexName as xs:QName,
+ $range1LowerBound as anyAtomic?,
+ $range1UpperBound as anyAtomic?,
+ $range1HaveLowerBound as boolean?,
+ $range1HaveupperBound as boolean?,
+ $range1LowerBoundIncluded as boolean?,
+ $range1upperBoundIncluded as boolean?,
+ ....,
+ $rangeNLowerBound as anyAtomic?,
+ $rangeNUpperBound as anyAtomic?,
+ $rangeNHaveLowerBound as boolean?,
+ $rangeNHaveupperBound as boolean?,
+ $rangeNLowerBoundIncluded as boolean?,
+ $rangeNupperBoundIncluded as boolean?) as node()*
+
+ Note: the translator makes sure that there is at least one range, and each
+ range consits of exactly 6 values.
********************************************************************************/
ProbeIndexRangeValueIteratorState::ProbeIndexRangeValueIteratorState()
@@ -930,7 +960,8 @@
void ProbeIndexRangeValueIterator::serialize(::zorba::serialization::Archiver& ar)
{
serialize_baseclass(ar,
- (NaryBaseIterator<ProbeIndexRangeValueIterator, ProbeIndexRangeValueIteratorState>*)this);
+ (NaryBaseIterator<ProbeIndexRangeValueIterator,
+ ProbeIndexRangeValueIteratorState>*)this);
ar & theCheckKeyType;
}
@@ -970,16 +1001,22 @@
ERROR_PARAMS(qname->getStringValue()));
}
- if ((numChildren-1) % 6 != 0)
+ if (numChildren < 7 || (numChildren-1) % 6 != 0)
{
RAISE_ERROR(zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, loc,
- ERROR_PARAMS(qname->getStringValue()));
+ ERROR_PARAMS(qname->getStringValue(),
+ "index",
+ numChildren-1,
+ "multiple of 6"));
}
- if (indexDecl->getKeyExpressions().size() * 6 > numChildren-1)
+ if (indexDecl->getKeyExpressions().size() * 6 < numChildren-1)
{
RAISE_ERROR(zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS, loc,
- ERROR_PARAMS(qname->getStringValue()));
+ ERROR_PARAMS(qname->getStringValue(),
+ "index",
+ numChildren-1,
+ indexDecl->getKeyExpressions().size() * 6));
}
state->theIndex = (indexDecl->isTemp() ?
@@ -1114,7 +1151,7 @@
/*******************************************************************************
- ProbeIndexRangeGeneralIterator
+ probe-index-range-general
********************************************************************************/
ProbeIndexRangeGeneralIteratorState::ProbeIndexRangeGeneralIteratorState()
:
=== modified file 'src/runtime/indexing/index_ddl.h'
--- src/runtime/indexing/index_ddl.h 2011-08-12 16:07:57 +0000
+++ src/runtime/indexing/index_ddl.h 2011-11-04 19:40:32 +0000
@@ -191,17 +191,14 @@
};
-/**
- *
- * refresh-index($indexName as xs:QName) as pul()
- *
- * This is an updating function. During normal runtime (see RefreshIndexIterator),
- * it checks that index exists (in the dynamic context) and generates an update
- * primitive. During applyUpdates(), it clears the index of its contents and then
- * rebuilds the index the same way as the create() function.
- *
- * Author: Zorba Team
- */
+/******************************************************************************
+ refresh-index($indexName as xs:QName) as pul()
+
+ This is an updating function. During normal runtime (see RefreshIndexIterator),
+ it checks that index exists (in the dynamic context) and generates an update
+ primitive. During applyUpdates(), it clears the index of its contents and then
+ rebuilds the index the same way as the create() function.
+*******************************************************************************/
class RefreshIndexIterator : public UnaryBaseIterator<RefreshIndexIterator,
PlanIteratorState>
{
@@ -344,6 +341,9 @@
$key1 as anyAtomic?,
...,
$keyN as anyAtomic?) as node()*
+
+ Note: the translator wraps calls to this function with an OP_NODE_SORT_ASC
+ function.
********************************************************************************/
class ProbeIndexPointValueIteratorState : public PlanIteratorState
{
@@ -403,6 +403,9 @@
$key1 as anyAtomic*,
...,
$keyN as anyAtomic*) as node()*
+
+ Note: the translator wraps calls to this function with an OP_NODE_SORT_DISTINCT_ASC
+ function.
********************************************************************************/
class ProbeIndexPointGeneralIteratorState : public ProbeIndexPointValueIteratorState
{
@@ -431,11 +434,12 @@
void serialize(::zorba::serialization::Archiver& ar);
+public:
ProbeIndexPointGeneralIterator(
- static_context* sctx,
- const QueryLoc& loc,
- std::vector<PlanIter_t>& children);
-
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children);
+
~ProbeIndexPointGeneralIterator();
void accept(PlanIterVisitor& v) const;
@@ -460,6 +464,9 @@
$rangeNLowerBoundIncluded as boolean?,
$rangeNupperBoundIncluded as boolean?) as node()*
+ Note: the translator wraps calls to this function with an OP_NODE_SORT_ASC
+ function.
+
theQname : the name of the index
theIndex : the index to probe
theIterator : the index probe iterator
@@ -482,10 +489,9 @@
};
-class ProbeIndexRangeValueIterator
- :
- public NaryBaseIterator<ProbeIndexRangeValueIterator,
- ProbeIndexRangeValueIteratorState>
+class ProbeIndexRangeValueIterator :
+public NaryBaseIterator<ProbeIndexRangeValueIterator,
+ ProbeIndexRangeValueIteratorState>
{
protected:
bool theCheckKeyType;
@@ -498,10 +504,11 @@
void serialize(::zorba::serialization::Archiver& ar);
+public:
ProbeIndexRangeValueIterator(
- static_context* sctx,
- const QueryLoc& loc,
- std::vector<PlanIter_t>& children);
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children);
~ProbeIndexRangeValueIterator();
@@ -553,10 +560,9 @@
};
-class ProbeIndexRangeGeneralIterator
- :
- public NaryBaseIterator<ProbeIndexRangeGeneralIterator,
- ProbeIndexRangeGeneralIteratorState>
+class ProbeIndexRangeGeneralIterator :
+public NaryBaseIterator<ProbeIndexRangeGeneralIterator,
+ ProbeIndexRangeGeneralIteratorState>
{
protected:
bool theCheckKeyType;
@@ -569,11 +575,12 @@
void serialize(::zorba::serialization::Archiver& ar);
+public:
ProbeIndexRangeGeneralIterator(
- static_context* sctx,
- const QueryLoc& loc,
- std::vector<PlanIter_t>& children);
-
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children);
+
~ProbeIndexRangeGeneralIterator();
void accept(PlanIterVisitor& v) const;
=== added file 'src/runtime/nodes/node_position_impl.cpp'
--- src/runtime/nodes/node_position_impl.cpp 1970-01-01 00:00:00 +0000
+++ src/runtime/nodes/node_position_impl.cpp 2011-11-04 19:40:32 +0000
@@ -0,0 +1,756 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "stdafx.h"
+
+#include "runtime/nodes/node_position.h"
+#include "zorbamisc/ns_consts.h"
+
+#include "system/globalenv.h"
+
+#include "store/api/item.h"
+#include "store/api/iterator.h"
+#include "store/api/item_factory.h"
+#include "store/api/store.h"
+#include "store/naive/atomic_items.h"
+#include "store/naive/ordpath.h"
+
+#include "util/string_util.h"
+#include "util/uri_util.h"
+#include "zorbautils/string_util.h"
+
+using namespace std;
+
+namespace zorba {
+
+/*******************************************************************************
+
+********************************************************************************/
+bool NodePositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ bool valid;
+ store::Item_t inNode;
+
+ PlanIteratorState* state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ valid = consumeNext(inNode, theChildren[0], planState);
+ assert(valid);
+
+ STACK_PUSH(GENV_STORE.getStructuralInformation(result, inNode), state);
+ STACK_END(state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsAncestorPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUriA;
+ store::Item_t lUriB;
+
+ PlanIteratorState* state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUriA, theChildren[0].getp(), planState);
+ consumeNext(lUriB, theChildren[1].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUriA->isAncestor(lUriB));
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsFollowingSiblingPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUriA;
+ store::Item_t lUriB;
+
+ PlanIteratorState* state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUriA, theChildren[0].getp(), planState);
+ consumeNext(lUriB, theChildren[1].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUriA->isFollowingSibling(lUriB));
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsFollowingPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUriA;
+ store::Item_t lUriB;
+
+ PlanIteratorState* state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUriA, theChildren[0].getp(), planState);
+ consumeNext(lUriB, theChildren[1].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUriA->isFollowing(lUriB));
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsInSubtreeOfPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUriA;
+ store::Item_t lUriB;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUriA, theChildren[0].getp(), planState);
+ consumeNext(lUriB, theChildren[1].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUriA->isInSubtreeOf(lUriB));
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsDescendantPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUriA;
+ store::Item_t lUriB;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUriA, theChildren[0].getp(), planState);
+ consumeNext(lUriB, theChildren[1].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUriA->isDescendant(lUriB));
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsPrecedingSiblingPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUriA;
+ store::Item_t lUriB;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUriA, theChildren[0].getp(), planState);
+ consumeNext(lUriB, theChildren[1].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUriA->isPrecedingSibling(lUriB));
+
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsPrecedingPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUriA;
+ store::Item_t lUriB;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUriA, theChildren[0].getp(), planState);
+ consumeNext(lUriB, theChildren[1].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUriA->isPreceding(lUriB));
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsChildPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUriA;
+ store::Item_t lUriB;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUriA, theChildren[0].getp(), planState);
+ consumeNext(lUriB, theChildren[1].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUriA->isChild(lUriB));
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsAttributeOfPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUriA;
+ store::Item_t lUriB;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUriA, theChildren[0].getp(), planState);
+ consumeNext(lUriB, theChildren[1].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUriA->isAttribute(lUriB));
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsParentPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUriA;
+ store::Item_t lUriB;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUriA, theChildren[0].getp(), planState);
+ consumeNext(lUriB, theChildren[1].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUriA->isParent(lUriB));
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsPrecedingInDocumentOrderPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUriA;
+ store::Item_t lUriB;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUriA, theChildren[0].getp(), planState);
+ consumeNext(lUriB, theChildren[1].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUriA->isPrecedingInDocumentOrder(lUriB));
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsFollowingInDocumentOrderPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUriA;
+ store::Item_t lUriB;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUriA, theChildren[0].getp(), planState);
+ consumeNext(lUriB, theChildren[1].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUriA->isFollowingInDocumentOrder(lUriB));
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+LevelPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUri;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUri, theChildren[0].getp(), planState);
+
+ try
+ {
+ result = lUri->getLevel();
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true, state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsAttributePositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUri;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUri, theChildren[0].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUri->isAttribute());
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsCommentPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUri;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUri, theChildren[0].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUri->isComment());
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsDocumentPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUri;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUri, theChildren[0].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUri->isDocument());
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsElementPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUri;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUri, theChildren[0].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUri->isElement());
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsProcessingInstructionPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUri;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUri, theChildren[0].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUri->isProcessingInstruction());
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsTextPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUri;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUri, theChildren[0].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUri->isText());
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+IsSiblingPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUriA;
+ store::Item_t lUriB;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUriA, theChildren[0].getp(), planState);
+ consumeNext(lUriB, theChildren[1].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUriA->isSibling(lUriB));
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+InSameTreePositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUriA;
+ store::Item_t lUriB;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUriA, theChildren[0].getp(), planState);
+ consumeNext(lUriB, theChildren[1].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUriA->inSameTree(lUriB));
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+InCollectionPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUri;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUri, theChildren[0].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUri->inCollection());
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+InSameCollectionPositionIterator::nextImpl(store::Item_t& result, PlanState& planState) const
+{
+ store::Item_t lUriA;
+ store::Item_t lUriB;
+
+ PlanIteratorState *state;
+ DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
+
+ consumeNext(lUriA, theChildren[0].getp(), planState);
+ consumeNext(lUriB, theChildren[1].getp(), planState);
+
+ try
+ {
+ GENV_ITEMFACTORY->createBoolean(result, lUriA->inSameCollection(lUriB));
+ }
+ catch (ZorbaException& e)
+ {
+ set_source(e, loc);
+ throw;
+ }
+
+ STACK_PUSH(true,state);
+
+ STACK_END (state);
+}
+
+} // namespace zorba
+/* vim:set et sw=2 ts=2: */
+
=== added file 'src/runtime/nodes/pregenerated/node_position.cpp'
--- src/runtime/nodes/pregenerated/node_position.cpp 1970-01-01 00:00:00 +0000
+++ src/runtime/nodes/pregenerated/node_position.cpp 2011-11-04 19:40:32 +0000
@@ -0,0 +1,710 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ******************************************
+// * *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME *
+// * *
+// ******************************************
+
+#include "stdafx.h"
+#include "zorbatypes/rchandle.h"
+#include "zorbatypes/zstring.h"
+#include "runtime/visitors/planiter_visitor.h"
+#include "runtime/nodes/node_position.h"
+#include "system/globalenv.h"
+
+
+
+namespace zorba {
+
+// <NodePositionIterator>
+const char* NodePositionIterator::class_name_str = "NodePositionIterator";
+NodePositionIterator::class_factory<NodePositionIterator>
+NodePositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+NodePositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int NodePositionIterator::class_versions_count =
+sizeof(NodePositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void NodePositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+NodePositionIterator::~NodePositionIterator() {}
+
+// </NodePositionIterator>
+
+
+// <IsAncestorPositionIterator>
+const char* IsAncestorPositionIterator::class_name_str = "IsAncestorPositionIterator";
+IsAncestorPositionIterator::class_factory<IsAncestorPositionIterator>
+IsAncestorPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsAncestorPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsAncestorPositionIterator::class_versions_count =
+sizeof(IsAncestorPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsAncestorPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsAncestorPositionIterator::~IsAncestorPositionIterator() {}
+
+// </IsAncestorPositionIterator>
+
+
+// <IsFollowingSiblingPositionIterator>
+const char* IsFollowingSiblingPositionIterator::class_name_str = "IsFollowingSiblingPositionIterator";
+IsFollowingSiblingPositionIterator::class_factory<IsFollowingSiblingPositionIterator>
+IsFollowingSiblingPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsFollowingSiblingPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsFollowingSiblingPositionIterator::class_versions_count =
+sizeof(IsFollowingSiblingPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsFollowingSiblingPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsFollowingSiblingPositionIterator::~IsFollowingSiblingPositionIterator() {}
+
+// </IsFollowingSiblingPositionIterator>
+
+
+// <IsFollowingPositionIterator>
+const char* IsFollowingPositionIterator::class_name_str = "IsFollowingPositionIterator";
+IsFollowingPositionIterator::class_factory<IsFollowingPositionIterator>
+IsFollowingPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsFollowingPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsFollowingPositionIterator::class_versions_count =
+sizeof(IsFollowingPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsFollowingPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsFollowingPositionIterator::~IsFollowingPositionIterator() {}
+
+// </IsFollowingPositionIterator>
+
+
+// <IsInSubtreeOfPositionIterator>
+const char* IsInSubtreeOfPositionIterator::class_name_str = "IsInSubtreeOfPositionIterator";
+IsInSubtreeOfPositionIterator::class_factory<IsInSubtreeOfPositionIterator>
+IsInSubtreeOfPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsInSubtreeOfPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsInSubtreeOfPositionIterator::class_versions_count =
+sizeof(IsInSubtreeOfPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsInSubtreeOfPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsInSubtreeOfPositionIterator::~IsInSubtreeOfPositionIterator() {}
+
+// </IsInSubtreeOfPositionIterator>
+
+
+// <IsDescendantPositionIterator>
+const char* IsDescendantPositionIterator::class_name_str = "IsDescendantPositionIterator";
+IsDescendantPositionIterator::class_factory<IsDescendantPositionIterator>
+IsDescendantPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsDescendantPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsDescendantPositionIterator::class_versions_count =
+sizeof(IsDescendantPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsDescendantPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsDescendantPositionIterator::~IsDescendantPositionIterator() {}
+
+// </IsDescendantPositionIterator>
+
+
+// <IsPrecedingSiblingPositionIterator>
+const char* IsPrecedingSiblingPositionIterator::class_name_str = "IsPrecedingSiblingPositionIterator";
+IsPrecedingSiblingPositionIterator::class_factory<IsPrecedingSiblingPositionIterator>
+IsPrecedingSiblingPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsPrecedingSiblingPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsPrecedingSiblingPositionIterator::class_versions_count =
+sizeof(IsPrecedingSiblingPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsPrecedingSiblingPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsPrecedingSiblingPositionIterator::~IsPrecedingSiblingPositionIterator() {}
+
+// </IsPrecedingSiblingPositionIterator>
+
+
+// <IsPrecedingPositionIterator>
+const char* IsPrecedingPositionIterator::class_name_str = "IsPrecedingPositionIterator";
+IsPrecedingPositionIterator::class_factory<IsPrecedingPositionIterator>
+IsPrecedingPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsPrecedingPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsPrecedingPositionIterator::class_versions_count =
+sizeof(IsPrecedingPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsPrecedingPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsPrecedingPositionIterator::~IsPrecedingPositionIterator() {}
+
+// </IsPrecedingPositionIterator>
+
+
+// <IsChildPositionIterator>
+const char* IsChildPositionIterator::class_name_str = "IsChildPositionIterator";
+IsChildPositionIterator::class_factory<IsChildPositionIterator>
+IsChildPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsChildPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsChildPositionIterator::class_versions_count =
+sizeof(IsChildPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsChildPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsChildPositionIterator::~IsChildPositionIterator() {}
+
+// </IsChildPositionIterator>
+
+
+// <IsAttributeOfPositionIterator>
+const char* IsAttributeOfPositionIterator::class_name_str = "IsAttributeOfPositionIterator";
+IsAttributeOfPositionIterator::class_factory<IsAttributeOfPositionIterator>
+IsAttributeOfPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsAttributeOfPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsAttributeOfPositionIterator::class_versions_count =
+sizeof(IsAttributeOfPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsAttributeOfPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsAttributeOfPositionIterator::~IsAttributeOfPositionIterator() {}
+
+// </IsAttributeOfPositionIterator>
+
+
+// <IsParentPositionIterator>
+const char* IsParentPositionIterator::class_name_str = "IsParentPositionIterator";
+IsParentPositionIterator::class_factory<IsParentPositionIterator>
+IsParentPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsParentPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsParentPositionIterator::class_versions_count =
+sizeof(IsParentPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsParentPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsParentPositionIterator::~IsParentPositionIterator() {}
+
+// </IsParentPositionIterator>
+
+
+// <IsPrecedingInDocumentOrderPositionIterator>
+const char* IsPrecedingInDocumentOrderPositionIterator::class_name_str = "IsPrecedingInDocumentOrderPositionIterator";
+IsPrecedingInDocumentOrderPositionIterator::class_factory<IsPrecedingInDocumentOrderPositionIterator>
+IsPrecedingInDocumentOrderPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsPrecedingInDocumentOrderPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsPrecedingInDocumentOrderPositionIterator::class_versions_count =
+sizeof(IsPrecedingInDocumentOrderPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsPrecedingInDocumentOrderPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsPrecedingInDocumentOrderPositionIterator::~IsPrecedingInDocumentOrderPositionIterator() {}
+
+// </IsPrecedingInDocumentOrderPositionIterator>
+
+
+// <IsFollowingInDocumentOrderPositionIterator>
+const char* IsFollowingInDocumentOrderPositionIterator::class_name_str = "IsFollowingInDocumentOrderPositionIterator";
+IsFollowingInDocumentOrderPositionIterator::class_factory<IsFollowingInDocumentOrderPositionIterator>
+IsFollowingInDocumentOrderPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsFollowingInDocumentOrderPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsFollowingInDocumentOrderPositionIterator::class_versions_count =
+sizeof(IsFollowingInDocumentOrderPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsFollowingInDocumentOrderPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsFollowingInDocumentOrderPositionIterator::~IsFollowingInDocumentOrderPositionIterator() {}
+
+// </IsFollowingInDocumentOrderPositionIterator>
+
+
+// <LevelPositionIterator>
+const char* LevelPositionIterator::class_name_str = "LevelPositionIterator";
+LevelPositionIterator::class_factory<LevelPositionIterator>
+LevelPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+LevelPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int LevelPositionIterator::class_versions_count =
+sizeof(LevelPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void LevelPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+LevelPositionIterator::~LevelPositionIterator() {}
+
+// </LevelPositionIterator>
+
+
+// <IsAttributePositionIterator>
+const char* IsAttributePositionIterator::class_name_str = "IsAttributePositionIterator";
+IsAttributePositionIterator::class_factory<IsAttributePositionIterator>
+IsAttributePositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsAttributePositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsAttributePositionIterator::class_versions_count =
+sizeof(IsAttributePositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsAttributePositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsAttributePositionIterator::~IsAttributePositionIterator() {}
+
+// </IsAttributePositionIterator>
+
+
+// <IsCommentPositionIterator>
+const char* IsCommentPositionIterator::class_name_str = "IsCommentPositionIterator";
+IsCommentPositionIterator::class_factory<IsCommentPositionIterator>
+IsCommentPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsCommentPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsCommentPositionIterator::class_versions_count =
+sizeof(IsCommentPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsCommentPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsCommentPositionIterator::~IsCommentPositionIterator() {}
+
+// </IsCommentPositionIterator>
+
+
+// <IsDocumentPositionIterator>
+const char* IsDocumentPositionIterator::class_name_str = "IsDocumentPositionIterator";
+IsDocumentPositionIterator::class_factory<IsDocumentPositionIterator>
+IsDocumentPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsDocumentPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsDocumentPositionIterator::class_versions_count =
+sizeof(IsDocumentPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsDocumentPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsDocumentPositionIterator::~IsDocumentPositionIterator() {}
+
+// </IsDocumentPositionIterator>
+
+
+// <IsElementPositionIterator>
+const char* IsElementPositionIterator::class_name_str = "IsElementPositionIterator";
+IsElementPositionIterator::class_factory<IsElementPositionIterator>
+IsElementPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsElementPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsElementPositionIterator::class_versions_count =
+sizeof(IsElementPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsElementPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsElementPositionIterator::~IsElementPositionIterator() {}
+
+// </IsElementPositionIterator>
+
+
+// <IsProcessingInstructionPositionIterator>
+const char* IsProcessingInstructionPositionIterator::class_name_str = "IsProcessingInstructionPositionIterator";
+IsProcessingInstructionPositionIterator::class_factory<IsProcessingInstructionPositionIterator>
+IsProcessingInstructionPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsProcessingInstructionPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsProcessingInstructionPositionIterator::class_versions_count =
+sizeof(IsProcessingInstructionPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsProcessingInstructionPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsProcessingInstructionPositionIterator::~IsProcessingInstructionPositionIterator() {}
+
+// </IsProcessingInstructionPositionIterator>
+
+
+// <IsTextPositionIterator>
+const char* IsTextPositionIterator::class_name_str = "IsTextPositionIterator";
+IsTextPositionIterator::class_factory<IsTextPositionIterator>
+IsTextPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsTextPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsTextPositionIterator::class_versions_count =
+sizeof(IsTextPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsTextPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsTextPositionIterator::~IsTextPositionIterator() {}
+
+// </IsTextPositionIterator>
+
+
+// <IsSiblingPositionIterator>
+const char* IsSiblingPositionIterator::class_name_str = "IsSiblingPositionIterator";
+IsSiblingPositionIterator::class_factory<IsSiblingPositionIterator>
+IsSiblingPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+IsSiblingPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int IsSiblingPositionIterator::class_versions_count =
+sizeof(IsSiblingPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void IsSiblingPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+IsSiblingPositionIterator::~IsSiblingPositionIterator() {}
+
+// </IsSiblingPositionIterator>
+
+
+// <InSameTreePositionIterator>
+const char* InSameTreePositionIterator::class_name_str = "InSameTreePositionIterator";
+InSameTreePositionIterator::class_factory<InSameTreePositionIterator>
+InSameTreePositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+InSameTreePositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int InSameTreePositionIterator::class_versions_count =
+sizeof(InSameTreePositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void InSameTreePositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+InSameTreePositionIterator::~InSameTreePositionIterator() {}
+
+// </InSameTreePositionIterator>
+
+
+// <InCollectionPositionIterator>
+const char* InCollectionPositionIterator::class_name_str = "InCollectionPositionIterator";
+InCollectionPositionIterator::class_factory<InCollectionPositionIterator>
+InCollectionPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+InCollectionPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int InCollectionPositionIterator::class_versions_count =
+sizeof(InCollectionPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void InCollectionPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+InCollectionPositionIterator::~InCollectionPositionIterator() {}
+
+// </InCollectionPositionIterator>
+
+
+// <InSameCollectionPositionIterator>
+const char* InSameCollectionPositionIterator::class_name_str = "InSameCollectionPositionIterator";
+InSameCollectionPositionIterator::class_factory<InSameCollectionPositionIterator>
+InSameCollectionPositionIterator::g_class_factory;
+
+const serialization::ClassVersion
+InSameCollectionPositionIterator::class_versions[] ={{ 1, 0x000905, false}};
+
+const int InSameCollectionPositionIterator::class_versions_count =
+sizeof(InSameCollectionPositionIterator::class_versions)/sizeof(struct serialization::ClassVersion);
+
+void InSameCollectionPositionIterator::accept(PlanIterVisitor& v) const {
+ v.beginVisit(*this);
+
+ std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+ std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+ for ( ; lIter != lEnd; ++lIter ){
+ (*lIter)->accept(v);
+ }
+
+ v.endVisit(*this);
+}
+
+InSameCollectionPositionIterator::~InSameCollectionPositionIterator() {}
+
+// </InSameCollectionPositionIterator>
+
+
+
+}
+
+
=== added file 'src/runtime/nodes/pregenerated/node_position.h'
--- src/runtime/nodes/pregenerated/node_position.h 1970-01-01 00:00:00 +0000
+++ src/runtime/nodes/pregenerated/node_position.h 2011-11-04 19:40:32 +0000
@@ -0,0 +1,858 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ******************************************
+// * *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME *
+// * *
+// ******************************************
+#ifndef ZORBA_RUNTIME_NODES_NODE_POSITION_H
+#define ZORBA_RUNTIME_NODES_NODE_POSITION_H
+
+
+#include "common/shared_types.h"
+
+
+
+#include "runtime/base/narybase.h"
+
+
+namespace zorba {
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class NodePositionIterator : public NaryBaseIterator<NodePositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(NodePositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(NodePositionIterator,
+ NaryBaseIterator<NodePositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<NodePositionIterator, PlanIteratorState>*)this);
+ }
+
+ NodePositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<NodePositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~NodePositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsAncestorPositionIterator : public NaryBaseIterator<IsAncestorPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsAncestorPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsAncestorPositionIterator,
+ NaryBaseIterator<IsAncestorPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsAncestorPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsAncestorPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsAncestorPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsAncestorPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsFollowingSiblingPositionIterator : public NaryBaseIterator<IsFollowingSiblingPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsFollowingSiblingPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsFollowingSiblingPositionIterator,
+ NaryBaseIterator<IsFollowingSiblingPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsFollowingSiblingPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsFollowingSiblingPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsFollowingSiblingPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsFollowingSiblingPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsFollowingPositionIterator : public NaryBaseIterator<IsFollowingPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsFollowingPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsFollowingPositionIterator,
+ NaryBaseIterator<IsFollowingPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsFollowingPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsFollowingPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsFollowingPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsFollowingPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsInSubtreeOfPositionIterator : public NaryBaseIterator<IsInSubtreeOfPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsInSubtreeOfPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsInSubtreeOfPositionIterator,
+ NaryBaseIterator<IsInSubtreeOfPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsInSubtreeOfPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsInSubtreeOfPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsInSubtreeOfPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsInSubtreeOfPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsDescendantPositionIterator : public NaryBaseIterator<IsDescendantPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsDescendantPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsDescendantPositionIterator,
+ NaryBaseIterator<IsDescendantPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsDescendantPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsDescendantPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsDescendantPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsDescendantPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsPrecedingSiblingPositionIterator : public NaryBaseIterator<IsPrecedingSiblingPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsPrecedingSiblingPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsPrecedingSiblingPositionIterator,
+ NaryBaseIterator<IsPrecedingSiblingPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsPrecedingSiblingPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsPrecedingSiblingPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsPrecedingSiblingPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsPrecedingSiblingPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsPrecedingPositionIterator : public NaryBaseIterator<IsPrecedingPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsPrecedingPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsPrecedingPositionIterator,
+ NaryBaseIterator<IsPrecedingPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsPrecedingPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsPrecedingPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsPrecedingPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsPrecedingPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsChildPositionIterator : public NaryBaseIterator<IsChildPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsChildPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsChildPositionIterator,
+ NaryBaseIterator<IsChildPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsChildPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsChildPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsChildPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsChildPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsAttributeOfPositionIterator : public NaryBaseIterator<IsAttributeOfPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsAttributeOfPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsAttributeOfPositionIterator,
+ NaryBaseIterator<IsAttributeOfPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsAttributeOfPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsAttributeOfPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsAttributeOfPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsAttributeOfPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsParentPositionIterator : public NaryBaseIterator<IsParentPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsParentPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsParentPositionIterator,
+ NaryBaseIterator<IsParentPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsParentPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsParentPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsParentPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsParentPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsPrecedingInDocumentOrderPositionIterator : public NaryBaseIterator<IsPrecedingInDocumentOrderPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsPrecedingInDocumentOrderPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsPrecedingInDocumentOrderPositionIterator,
+ NaryBaseIterator<IsPrecedingInDocumentOrderPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsPrecedingInDocumentOrderPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsPrecedingInDocumentOrderPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsPrecedingInDocumentOrderPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsPrecedingInDocumentOrderPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsFollowingInDocumentOrderPositionIterator : public NaryBaseIterator<IsFollowingInDocumentOrderPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsFollowingInDocumentOrderPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsFollowingInDocumentOrderPositionIterator,
+ NaryBaseIterator<IsFollowingInDocumentOrderPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsFollowingInDocumentOrderPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsFollowingInDocumentOrderPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsFollowingInDocumentOrderPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsFollowingInDocumentOrderPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class LevelPositionIterator : public NaryBaseIterator<LevelPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(LevelPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(LevelPositionIterator,
+ NaryBaseIterator<LevelPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<LevelPositionIterator, PlanIteratorState>*)this);
+ }
+
+ LevelPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<LevelPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~LevelPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsAttributePositionIterator : public NaryBaseIterator<IsAttributePositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsAttributePositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsAttributePositionIterator,
+ NaryBaseIterator<IsAttributePositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsAttributePositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsAttributePositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsAttributePositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsAttributePositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsCommentPositionIterator : public NaryBaseIterator<IsCommentPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsCommentPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsCommentPositionIterator,
+ NaryBaseIterator<IsCommentPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsCommentPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsCommentPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsCommentPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsCommentPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsDocumentPositionIterator : public NaryBaseIterator<IsDocumentPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsDocumentPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsDocumentPositionIterator,
+ NaryBaseIterator<IsDocumentPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsDocumentPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsDocumentPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsDocumentPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsDocumentPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsElementPositionIterator : public NaryBaseIterator<IsElementPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsElementPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsElementPositionIterator,
+ NaryBaseIterator<IsElementPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsElementPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsElementPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsElementPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsElementPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsProcessingInstructionPositionIterator : public NaryBaseIterator<IsProcessingInstructionPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsProcessingInstructionPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsProcessingInstructionPositionIterator,
+ NaryBaseIterator<IsProcessingInstructionPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsProcessingInstructionPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsProcessingInstructionPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsProcessingInstructionPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsProcessingInstructionPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsTextPositionIterator : public NaryBaseIterator<IsTextPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsTextPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsTextPositionIterator,
+ NaryBaseIterator<IsTextPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsTextPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsTextPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsTextPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsTextPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class IsSiblingPositionIterator : public NaryBaseIterator<IsSiblingPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(IsSiblingPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(IsSiblingPositionIterator,
+ NaryBaseIterator<IsSiblingPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<IsSiblingPositionIterator, PlanIteratorState>*)this);
+ }
+
+ IsSiblingPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<IsSiblingPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~IsSiblingPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class InSameTreePositionIterator : public NaryBaseIterator<InSameTreePositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(InSameTreePositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(InSameTreePositionIterator,
+ NaryBaseIterator<InSameTreePositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<InSameTreePositionIterator, PlanIteratorState>*)this);
+ }
+
+ InSameTreePositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<InSameTreePositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~InSameTreePositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class InCollectionPositionIterator : public NaryBaseIterator<InCollectionPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(InCollectionPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(InCollectionPositionIterator,
+ NaryBaseIterator<InCollectionPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<InCollectionPositionIterator, PlanIteratorState>*)this);
+ }
+
+ InCollectionPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<InCollectionPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~InCollectionPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ *
+ * Author: Federico Cavalieri
+ */
+class InSameCollectionPositionIterator : public NaryBaseIterator<InSameCollectionPositionIterator, PlanIteratorState>
+{
+public:
+ SERIALIZABLE_CLASS(InSameCollectionPositionIterator);
+
+ SERIALIZABLE_CLASS_CONSTRUCTOR2T(InSameCollectionPositionIterator,
+ NaryBaseIterator<InSameCollectionPositionIterator, PlanIteratorState>);
+
+ void serialize( ::zorba::serialization::Archiver& ar)
+ {
+ serialize_baseclass(ar,
+ (NaryBaseIterator<InSameCollectionPositionIterator, PlanIteratorState>*)this);
+ }
+
+ InSameCollectionPositionIterator(
+ static_context* sctx,
+ const QueryLoc& loc,
+ std::vector<PlanIter_t>& children)
+ :
+ NaryBaseIterator<InSameCollectionPositionIterator, PlanIteratorState>(sctx, loc, children)
+ {}
+
+ virtual ~InSameCollectionPositionIterator();
+
+ void accept(PlanIterVisitor& v) const;
+
+ bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+}
+#endif
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */
=== modified file 'src/runtime/qnames/qnames_impl.cpp'
--- src/runtime/qnames/qnames_impl.cpp 2011-07-19 19:35:04 +0000
+++ src/runtime/qnames/qnames_impl.cpp 2011-11-04 19:40:32 +0000
@@ -1,12 +1,12 @@
/*
* Copyright 2006-2008 The FLWOR Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -52,7 +52,7 @@
PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
- if (consumeNext(itemQName, theChild0.getp(), planState ))
+ if (consumeNext(itemQName, theChild0.getp(), planState ))
{
itemQName->getStringValue2(qname);
@@ -60,7 +60,7 @@
index = qname.find(":", 0, 1);
- if (index != zstring::npos)
+ if (index != zstring::npos)
{
resPre = qname.substr(0, index);
resLocal = qname.substr(index+1, qname.size() - index);
@@ -70,7 +70,7 @@
throw XQUERY_EXCEPTION(
err::FOCA0002, ERROR_PARAMS( qname ), ERROR_LOC(loc)
);
- }
+ }
else
{
resLocal = qname;
@@ -80,8 +80,8 @@
err::FOCA0002, ERROR_PARAMS( qname ), ERROR_LOC(loc)
);
}
-
- if (consumeNext(itemElem, theChild1, planState ))
+
+ if (consumeNext(itemElem, theChild1, planState ))
{
itemElem->getNamespaceBindings(NamespaceBindings);
@@ -104,7 +104,7 @@
err::FONS0004, ERROR_PARAMS( resPre ), ERROR_LOC( loc )
);
}
-
+
GENV_ITEMFACTORY->createQName(result, resNs, resPre, resLocal);
STACK_PUSH(true, state);
@@ -128,7 +128,7 @@
PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
- if (consumeNext(itemURI, theChild0.getp(), planState ))
+ if (consumeNext(itemURI, theChild0.getp(), planState ))
{
itemURI->getStringValue2(resNs);
@@ -138,12 +138,12 @@
consumeNext(itemQName, theChild1.getp(), planState );
itemQName->getStringValue2(qname);
-
+
ascii::trim_whitespace(qname);
index = qname.find(":", 0, 1);
- if (index != zstring::npos)
+ if (index != zstring::npos)
{
if (resNs.empty())
throw XQUERY_EXCEPTION(
@@ -152,12 +152,12 @@
resPre = qname.substr(0, index);
resLocal = qname.substr(index+1, qname.size() - index);
- }
+ }
else
{
resLocal = qname;
}
-
+
if ((index != zstring::npos && ! GENV_GCAST.castableToNCName(resPre)) ||
! GENV_GCAST.castableToNCName(resLocal))
{
@@ -209,7 +209,7 @@
//11.2.2 fn:prefix-from-QName
bool PrefixFromQNameIterator::nextImpl(
- store::Item_t& result,
+ store::Item_t& result,
PlanState& planState) const
{
store::Item_t item;
@@ -232,8 +232,8 @@
//11.2.3 fn:local-name-from-QName
bool LocalNameFromQNameIterator::nextImpl(
- store::Item_t& result,
- PlanState& planState) const
+ store::Item_t& result,
+ PlanState& planState) const
{
store::Item_t item;
zstring localName;
@@ -253,7 +253,7 @@
//11.2.4 fn:namespace-uri-from-QName
bool NamespaceUriFromQNameIterator::nextImpl(
store::Item_t& result,
- PlanState& planState) const
+ PlanState& planState) const
{
store::Item_t item;
zstring ns;
@@ -277,6 +277,7 @@
{
store::Item_t itemPrefix, itemElem;
zstring resNs;
+ zstring prefix;
bool found = false;
store::NsBindings NamespaceBindings;
store::NsBindings::const_iterator iter;
@@ -284,43 +285,35 @@
PlanIteratorState* state;
DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
-// According to W3C bug #11590 comment #9
-// http://www.w3.org/Bugs/Public/show_bug.cgi?id=11590#c9
-// namespace-uri-for-prefix('', <a/>)
-// and
-// namespace-uri-for-prefix((), <a/>)
-// should return the empty sequence
if (!consumeNext(itemPrefix, theChildren[0].getp(), planState ))
{
- resNs = theSctx->default_elem_type_ns();
- found = true;
- }
- else
- {
- if (!consumeNext(itemElem, theChildren[1].getp(), planState ))
- {
- ZORBA_ASSERT(false);
- }
- else
- {
- itemElem->getNamespaceBindings(NamespaceBindings);
-
- for (iter = NamespaceBindings.begin();
- iter != NamespaceBindings.end();
- ++iter)
- {
- zstring pre;
- itemPrefix->getStringValue2(pre);
-
- ascii::trim_whitespace(pre);
-
- if ((*iter).first == pre)
+ prefix = "";
+ }
+ else
+ {
+ itemPrefix->getStringValue2(prefix);
+ ascii::trim_whitespace(prefix);
+ }
+
+ if (!consumeNext(itemElem, theChildren[1].getp(), planState ))
+ {
+ ZORBA_ASSERT(false);
+ }
+ else
+ {
+ itemElem->getNamespaceBindings(NamespaceBindings);
+
+ for (iter = NamespaceBindings.begin();
+ iter != NamespaceBindings.end();
+ ++iter)
+ {
+ if (((*iter).first == prefix) &&
+ !(*iter).second.empty())
{
resNs = (*iter).second;
found = true;
break;
}
- }
}
}
=== added directory 'src/runtime/spec/full_text'
=== added file 'src/runtime/spec/full_text/ft_module.xml'
--- src/runtime/spec/full_text/ft_module.xml 1970-01-01 00:00:00 +0000
+++ src/runtime/spec/full_text/ft_module.xml 2011-11-04 19:40:32 +0000
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<zorba:iterators
+ xmlns:zorba="http://www.zorba-xquery.com"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd">
+
+<zorba:header>
+ <zorba:include form="Quoted">runtime/full_text/thesaurus.h</zorba:include>
+</zorba:header>
+
+<zorba:source>
+ <zorba:include form="Quoted">store/api/iterator.h</zorba:include>
+</zorba:source>
+
+<zorba:iterator name="HostLangIterator">
+ <zorba:function>
+ <zorba:signature localname="host-lang" prefix="zorba-full-text">
+ <zorba:output>xs:language</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+</zorba:iterator>
+
+<zorba:iterator name="IsStopWordIterator">
+ <zorba:function>
+ <zorba:signature localname="is-stop-word" prefix="zorba-full-text">
+ <zorba:param>xs:string</zorba:param> <!-- word -->
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ <zorba:signature localname="is-stop-word" prefix="zorba-full-text">
+ <zorba:param>xs:string</zorba:param> <!-- word -->
+ <zorba:param>xs:language</zorba:param> <!-- lang -->
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+</zorba:iterator>
+
+<zorba:iterator name="StemIterator">
+ <zorba:function>
+ <zorba:signature localname="stem" prefix="zorba-full-text">
+ <zorba:param>xs:string</zorba:param> <!-- word -->
+ <zorba:output>xs:string</zorba:output>
+ </zorba:signature>
+ <zorba:signature localname="stem" prefix="zorba-full-text">
+ <zorba:param>xs:string</zorba:param> <!-- word -->
+ <zorba:param>xs:language</zorba:param> <!-- lang -->
+ <zorba:output>xs:string</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+</zorba:iterator>
+
+<zorba:iterator name="StripDiacriticsIterator">
+ <zorba:function>
+ <zorba:signature localname="strip-diacritics" prefix="zorba-full-text">
+ <zorba:param>xs:string</zorba:param> <!-- phrase -->
+ <zorba:output>xs:string</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+</zorba:iterator>
+
+<zorba:iterator name="ThesaurusLookupIterator"
+ generateResetImpl="true">
+ <zorba:function>
+ <zorba:signature localname="thesaurus-lookup" prefix="zorba-full-text">
+ <zorba:param>xs:string</zorba:param> <!-- phrase -->
+ <zorba:output>xs:string+</zorba:output>
+ </zorba:signature>
+ <zorba:signature localname="thesaurus-lookup" prefix="zorba-full-text">
+ <zorba:param>xs:string</zorba:param> <!-- URI -->
+ <zorba:param>xs:string</zorba:param> <!-- phrase -->
+ <zorba:output>xs:string+</zorba:output>
+ </zorba:signature>
+ <zorba:signature localname="thesaurus-lookup" prefix="zorba-full-text">
+ <zorba:param>xs:string</zorba:param> <!-- URI -->
+ <zorba:param>xs:string</zorba:param> <!-- phrase -->
+ <zorba:param>xs:language</zorba:param> <!-- lang -->
+ <zorba:output>xs:string+</zorba:output>
+ </zorba:signature>
+ <zorba:signature localname="thesaurus-lookup" prefix="zorba-full-text">
+ <zorba:param>xs:string</zorba:param> <!-- URI -->
+ <zorba:param>xs:string</zorba:param> <!-- phrase -->
+ <zorba:param>xs:language</zorba:param> <!-- lang -->
+ <zorba:param>xs:string</zorba:param> <!-- relationship -->
+ <zorba:output>xs:string+</zorba:output>
+ </zorba:signature>
+ <zorba:signature localname="thesaurus-lookup" prefix="zorba-full-text">
+ <zorba:param>xs:string</zorba:param> <!-- URI -->
+ <zorba:param>xs:string</zorba:param> <!-- phrase -->
+ <zorba:param>xs:language</zorba:param> <!-- lang -->
+ <zorba:param>xs:string</zorba:param> <!-- relationship -->
+ <zorba:param>xs:integer</zorba:param> <!-- level-least -->
+ <zorba:param>xs:integer</zorba:param> <!-- level-most -->
+ <zorba:output>xs:string+</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+ <zorba:state generateInit="use-default">
+ <zorba:member type="zstring" name="phrase_"/>
+ <zorba:member type="zstring" name="relationship_"/>
+ <zorba:member type="internal::Thesaurus::level_type" name="at_least_"/>
+ <zorba:member type="internal::Thesaurus::level_type" name="at_most_"/>
+ <zorba:member type="internal::Thesaurus::ptr" name="thesaurus_"/>
+ <zorba:member type="internal::Thesaurus::iterator::ptr" name="tresult_"/>
+ </zorba:state>
+</zorba:iterator>
+
+<zorba:iterator name="TokenizeIterator"
+ generateResetImpl="true">
+ <zorba:function>
+ <zorba:signature localname="tokenize" prefix="zorba-full-text">
+ <zorba:param>node()</zorba:param> <!-- doc -->
+ <zorba:output>node()*</zorba:output>
+ </zorba:signature>
+ <zorba:signature localname="tokenize" prefix="zorba-full-text">
+ <zorba:param>node()</zorba:param> <!-- doc -->
+ <zorba:param>xs:language</zorba:param> <!-- lang -->
+ <zorba:output>node()*</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+ <zorba:state generateInit="use-default">
+ <zorba:member type="store::Item_t" name="doc_item_"/>
+ <zorba:member type="FTTokenIterator_t" name="doc_tokens_"/>
+ <zorba:member type="store::Item_t" name="token_qname_"/>
+ </zorba:state>
+</zorba:iterator>
+
+<zorba:iterator name="TokenizerPropertiesIterator">
+ <zorba:function>
+ <zorba:signature localname="tokenizer-properties" prefix="zorba-full-text">
+ <zorba:output>node()</zorba:output>
+ </zorba:signature>
+ <zorba:signature localname="tokenizer-properties" prefix="zorba-full-text">
+ <zorba:param>xs:language</zorba:param> <!-- lang -->
+ <zorba:output>node()</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+</zorba:iterator>
+
+</zorba:iterators>
+<!-- vim:set et sw=2 ts=2: -->
=== modified file 'src/runtime/spec/mappings.xml'
--- src/runtime/spec/mappings.xml 2011-09-30 08:08:13 +0000
+++ src/runtime/spec/mappings.xml 2011-11-04 19:40:32 +0000
@@ -22,7 +22,11 @@
<zorba:namespace uri="http://www.zorba-xquery.com/modules/node-reference"
define="ZORBA_NODEREF_FN_NS"
- prefix="fn-zorba-ref"/>
+ prefix="fn-zorba-ref"/>
+
+ <zorba:namespace uri="http://www.zorba-xquery.com/modules/node-position"
+ define="ZORBA_NODEPOS_FN_NS"
+ prefix="fn-zorba-pos"/>
<zorba:namespace uri="http://www.zorba-xquery.com/modules/schema"
define="ZORBA_SCHEMA_FN_NS"
@@ -78,6 +82,11 @@
define="ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS"
prefix="zorba-store-data-structure-unordered-map"/>
+ <zorba:namespace
+ uri="http://www.zorba-xquery.com/modules/full-text"
+ define="ZORBA_FULL_TEXT_FN_NS"
+ prefix="zorba-full-text"/>
+
<zorba:namespace uri="http://www.zorba-xquery.com/modules/xqdoc"
define="ZORBA_XQDOC_FN_NS"
prefix="fn-zorba-xqdoc"/>
=== added file 'src/runtime/spec/nodes/node_position.xml'
--- src/runtime/spec/nodes/node_position.xml 1970-01-01 00:00:00 +0000
+++ src/runtime/spec/nodes/node_position.xml 2011-11-04 19:40:32 +0000
@@ -0,0 +1,439 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+/////////////////////////////////////////////////////////////////////////////////
+// //
+/////////////////////////////////////////////////////////////////////////////////
+-->
+<zorba:iterators
+ xmlns:zorba="http://www.zorba-xquery.com"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd">
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+<zorba:iterator name="NodePositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="node-position" prefix="fn-zorba-pos">
+ <zorba:param>node()</zorba:param>
+ <zorba:output>xs:anyURI</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+</zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsAncestorPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="ancestor-of" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsFollowingSiblingPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="following-sibling-of" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+<!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsFollowingPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="following-of" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsInSubtreeOfPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="in-subtree-of" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsDescendantPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="descendant-of" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsPrecedingSiblingPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="preceding-sibling-of" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsPrecedingPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="preceding-of" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsChildPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="child-of" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsAttributeOfPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="attribute-of" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsParentPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="parent-of" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsPrecedingInDocumentOrderPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="preceding-in-document-order-of" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsFollowingInDocumentOrderPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="following-in-document-order-of" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="LevelPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="level" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:integer</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsAttributePositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="is-attribute" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsCommentPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="is-comment" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsDocumentPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="is-document" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsElementPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="is-element" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsProcessingInstructionPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="is-processing-instruction" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsTextPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="is-text" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="IsSiblingPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="sibling-of" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="InSameTreePositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="in-same-tree-of" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="InCollectionPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="in-collection" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+ <!--
+/*******************************************************************************
+********************************************************************************/
+-->
+ <zorba:iterator name="InSameCollectionPositionIterator">
+
+ <zorba:description author="Federico Cavalieri"></zorba:description>
+
+ <zorba:function>
+ <zorba:signature localname="in-same-collection-of" prefix="fn-zorba-pos">
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:param>xs:anyURI</zorba:param>
+ <zorba:output>xs:boolean</zorba:output>
+ </zorba:signature>
+ </zorba:function>
+
+ </zorba:iterator>
+
+</zorba:iterators>
=== modified file 'src/runtime/store/maps_impl.cpp'
--- src/runtime/store/maps_impl.cpp 2011-08-17 23:04:48 +0000
+++ src/runtime/store/maps_impl.cpp 2011-11-04 19:40:32 +0000
@@ -241,7 +241,11 @@
{
throw XQUERY_EXCEPTION(
zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS,
- ERROR_PARAMS( lQName->getStringValue() ),
+ ERROR_PARAMS(
+ lQName->getStringValue(),
+ "map",
+ theChildren.size() - 1,
+ lSpec.getNumColumns() ),
ERROR_LOC( loc )
);
}
@@ -316,7 +320,11 @@
{
throw XQUERY_EXCEPTION(
zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS,
- ERROR_PARAMS( lQName->getStringValue() ),
+ ERROR_PARAMS(
+ lQName->getStringValue(),
+ "map",
+ theChildren.size() - 2,
+ lSpec.getNumColumns() ),
ERROR_LOC( loc )
);
}
@@ -386,7 +394,12 @@
{
throw XQUERY_EXCEPTION(
zerr::ZDDY0025_INDEX_WRONG_NUMBER_OF_PROBE_ARGS,
- ERROR_PARAMS( lQName->getStringValue() ),
+ ERROR_PARAMS(
+ lQName->getStringValue(),
+ "map",
+ theChildren.size() - 1,
+ lSpec.getNumColumns()
+ ),
ERROR_LOC( loc )
);
}
=== modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h'
--- src/runtime/visitors/pregenerated/planiter_visitor.h 2011-10-19 15:28:51 +0000
+++ src/runtime/visitors/pregenerated/planiter_visitor.h 2011-11-04 19:40:32 +0000
@@ -189,6 +189,20 @@
class FnPutIterator;
+ class HostLangIterator;
+
+ class IsStopWordIterator;
+
+ class StemIterator;
+
+ class StripDiacriticsIterator;
+
+ class ThesaurusLookupIterator;
+
+ class TokenizeIterator;
+
+ class TokenizerPropertiesIterator;
+
class FunctionNameIterator;
class FunctionArityIterator;
@@ -303,6 +317,54 @@
class FrexpIterator;
+ class NodePositionIterator;
+
+ class IsAncestorPositionIterator;
+
+ class IsFollowingSiblingPositionIterator;
+
+ class IsFollowingPositionIterator;
+
+ class IsInSubtreeOfPositionIterator;
+
+ class IsDescendantPositionIterator;
+
+ class IsPrecedingSiblingPositionIterator;
+
+ class IsPrecedingPositionIterator;
+
+ class IsChildPositionIterator;
+
+ class IsAttributeOfPositionIterator;
+
+ class IsParentPositionIterator;
+
+ class IsPrecedingInDocumentOrderPositionIterator;
+
+ class IsFollowingInDocumentOrderPositionIterator;
+
+ class LevelPositionIterator;
+
+ class IsAttributePositionIterator;
+
+ class IsCommentPositionIterator;
+
+ class IsDocumentPositionIterator;
+
+ class IsElementPositionIterator;
+
+ class IsProcessingInstructionPositionIterator;
+
+ class IsTextPositionIterator;
+
+ class IsSiblingPositionIterator;
+
+ class InSameTreePositionIterator;
+
+ class InCollectionPositionIterator;
+
+ class InSameCollectionPositionIterator;
+
class NodeReferenceIterator;
class NodeByReferenceIterator;
@@ -784,6 +846,27 @@
virtual void beginVisit ( const FnPutIterator& ) = 0;
virtual void endVisit ( const FnPutIterator& ) = 0;
+ virtual void beginVisit ( const HostLangIterator& ) = 0;
+ virtual void endVisit ( const HostLangIterator& ) = 0;
+
+ virtual void beginVisit ( const IsStopWordIterator& ) = 0;
+ virtual void endVisit ( const IsStopWordIterator& ) = 0;
+
+ virtual void beginVisit ( const StemIterator& ) = 0;
+ virtual void endVisit ( const StemIterator& ) = 0;
+
+ virtual void beginVisit ( const StripDiacriticsIterator& ) = 0;
+ virtual void endVisit ( const StripDiacriticsIterator& ) = 0;
+
+ virtual void beginVisit ( const ThesaurusLookupIterator& ) = 0;
+ virtual void endVisit ( const ThesaurusLookupIterator& ) = 0;
+
+ virtual void beginVisit ( const TokenizeIterator& ) = 0;
+ virtual void endVisit ( const TokenizeIterator& ) = 0;
+
+ virtual void beginVisit ( const TokenizerPropertiesIterator& ) = 0;
+ virtual void endVisit ( const TokenizerPropertiesIterator& ) = 0;
+
virtual void beginVisit ( const FunctionNameIterator& ) = 0;
virtual void endVisit ( const FunctionNameIterator& ) = 0;
@@ -955,6 +1038,78 @@
virtual void beginVisit ( const FrexpIterator& ) = 0;
virtual void endVisit ( const FrexpIterator& ) = 0;
+ virtual void beginVisit ( const NodePositionIterator& ) = 0;
+ virtual void endVisit ( const NodePositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsAncestorPositionIterator& ) = 0;
+ virtual void endVisit ( const IsAncestorPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsFollowingSiblingPositionIterator& ) = 0;
+ virtual void endVisit ( const IsFollowingSiblingPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsFollowingPositionIterator& ) = 0;
+ virtual void endVisit ( const IsFollowingPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsInSubtreeOfPositionIterator& ) = 0;
+ virtual void endVisit ( const IsInSubtreeOfPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsDescendantPositionIterator& ) = 0;
+ virtual void endVisit ( const IsDescendantPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsPrecedingSiblingPositionIterator& ) = 0;
+ virtual void endVisit ( const IsPrecedingSiblingPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsPrecedingPositionIterator& ) = 0;
+ virtual void endVisit ( const IsPrecedingPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsChildPositionIterator& ) = 0;
+ virtual void endVisit ( const IsChildPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsAttributeOfPositionIterator& ) = 0;
+ virtual void endVisit ( const IsAttributeOfPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsParentPositionIterator& ) = 0;
+ virtual void endVisit ( const IsParentPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsPrecedingInDocumentOrderPositionIterator& ) = 0;
+ virtual void endVisit ( const IsPrecedingInDocumentOrderPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsFollowingInDocumentOrderPositionIterator& ) = 0;
+ virtual void endVisit ( const IsFollowingInDocumentOrderPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const LevelPositionIterator& ) = 0;
+ virtual void endVisit ( const LevelPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsAttributePositionIterator& ) = 0;
+ virtual void endVisit ( const IsAttributePositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsCommentPositionIterator& ) = 0;
+ virtual void endVisit ( const IsCommentPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsDocumentPositionIterator& ) = 0;
+ virtual void endVisit ( const IsDocumentPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsElementPositionIterator& ) = 0;
+ virtual void endVisit ( const IsElementPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsProcessingInstructionPositionIterator& ) = 0;
+ virtual void endVisit ( const IsProcessingInstructionPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsTextPositionIterator& ) = 0;
+ virtual void endVisit ( const IsTextPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const IsSiblingPositionIterator& ) = 0;
+ virtual void endVisit ( const IsSiblingPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const InSameTreePositionIterator& ) = 0;
+ virtual void endVisit ( const InSameTreePositionIterator& ) = 0;
+
+ virtual void beginVisit ( const InCollectionPositionIterator& ) = 0;
+ virtual void endVisit ( const InCollectionPositionIterator& ) = 0;
+
+ virtual void beginVisit ( const InSameCollectionPositionIterator& ) = 0;
+ virtual void endVisit ( const InSameCollectionPositionIterator& ) = 0;
+
virtual void beginVisit ( const NodeReferenceIterator& ) = 0;
virtual void endVisit ( const NodeReferenceIterator& ) = 0;
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
--- src/runtime/visitors/pregenerated/printer_visitor.cpp 2011-10-19 15:28:51 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2011-11-04 19:40:32 +0000
@@ -47,10 +47,12 @@
#include "runtime/errors_and_diagnostics/other_diagnostics.h"
#include "runtime/fetch/fetch.h"
#include "runtime/fnput/fnput.h"
+#include "runtime/full_text/ft_module.h"
#include "runtime/function_item/function_item_iter.h"
#include "runtime/indexing/ic_ddl.h"
#include "runtime/introspection/sctx.h"
#include "runtime/maths/maths.h"
+#include "runtime/nodes/node_position.h"
#include "runtime/nodes/nodes.h"
#include "runtime/numerics/numerics.h"
#include "runtime/parsing_and_serializing/parse_fragment.h"
@@ -1215,6 +1217,104 @@
// </FnPutIterator>
+// <HostLangIterator>
+void PrinterVisitor::beginVisit ( const HostLangIterator& a) {
+ thePrinter.startBeginVisit("HostLangIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const HostLangIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </HostLangIterator>
+
+
+// <IsStopWordIterator>
+void PrinterVisitor::beginVisit ( const IsStopWordIterator& a) {
+ thePrinter.startBeginVisit("IsStopWordIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsStopWordIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsStopWordIterator>
+
+
+// <StemIterator>
+void PrinterVisitor::beginVisit ( const StemIterator& a) {
+ thePrinter.startBeginVisit("StemIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const StemIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </StemIterator>
+
+
+// <StripDiacriticsIterator>
+void PrinterVisitor::beginVisit ( const StripDiacriticsIterator& a) {
+ thePrinter.startBeginVisit("StripDiacriticsIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const StripDiacriticsIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </StripDiacriticsIterator>
+
+
+// <ThesaurusLookupIterator>
+void PrinterVisitor::beginVisit ( const ThesaurusLookupIterator& a) {
+ thePrinter.startBeginVisit("ThesaurusLookupIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const ThesaurusLookupIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </ThesaurusLookupIterator>
+
+
+// <TokenizeIterator>
+void PrinterVisitor::beginVisit ( const TokenizeIterator& a) {
+ thePrinter.startBeginVisit("TokenizeIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const TokenizeIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </TokenizeIterator>
+
+
+// <TokenizerPropertiesIterator>
+void PrinterVisitor::beginVisit ( const TokenizerPropertiesIterator& a) {
+ thePrinter.startBeginVisit("TokenizerPropertiesIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const TokenizerPropertiesIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </TokenizerPropertiesIterator>
+
+
// <FunctionNameIterator>
void PrinterVisitor::beginVisit ( const FunctionNameIterator& a) {
thePrinter.startBeginVisit("FunctionNameIterator", ++theId);
@@ -2013,6 +2113,342 @@
// </FrexpIterator>
+// <NodePositionIterator>
+void PrinterVisitor::beginVisit ( const NodePositionIterator& a) {
+ thePrinter.startBeginVisit("NodePositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const NodePositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </NodePositionIterator>
+
+
+// <IsAncestorPositionIterator>
+void PrinterVisitor::beginVisit ( const IsAncestorPositionIterator& a) {
+ thePrinter.startBeginVisit("IsAncestorPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsAncestorPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsAncestorPositionIterator>
+
+
+// <IsFollowingSiblingPositionIterator>
+void PrinterVisitor::beginVisit ( const IsFollowingSiblingPositionIterator& a) {
+ thePrinter.startBeginVisit("IsFollowingSiblingPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsFollowingSiblingPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsFollowingSiblingPositionIterator>
+
+
+// <IsFollowingPositionIterator>
+void PrinterVisitor::beginVisit ( const IsFollowingPositionIterator& a) {
+ thePrinter.startBeginVisit("IsFollowingPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsFollowingPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsFollowingPositionIterator>
+
+
+// <IsInSubtreeOfPositionIterator>
+void PrinterVisitor::beginVisit ( const IsInSubtreeOfPositionIterator& a) {
+ thePrinter.startBeginVisit("IsInSubtreeOfPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsInSubtreeOfPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsInSubtreeOfPositionIterator>
+
+
+// <IsDescendantPositionIterator>
+void PrinterVisitor::beginVisit ( const IsDescendantPositionIterator& a) {
+ thePrinter.startBeginVisit("IsDescendantPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsDescendantPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsDescendantPositionIterator>
+
+
+// <IsPrecedingSiblingPositionIterator>
+void PrinterVisitor::beginVisit ( const IsPrecedingSiblingPositionIterator& a) {
+ thePrinter.startBeginVisit("IsPrecedingSiblingPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsPrecedingSiblingPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsPrecedingSiblingPositionIterator>
+
+
+// <IsPrecedingPositionIterator>
+void PrinterVisitor::beginVisit ( const IsPrecedingPositionIterator& a) {
+ thePrinter.startBeginVisit("IsPrecedingPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsPrecedingPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsPrecedingPositionIterator>
+
+
+// <IsChildPositionIterator>
+void PrinterVisitor::beginVisit ( const IsChildPositionIterator& a) {
+ thePrinter.startBeginVisit("IsChildPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsChildPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsChildPositionIterator>
+
+
+// <IsAttributeOfPositionIterator>
+void PrinterVisitor::beginVisit ( const IsAttributeOfPositionIterator& a) {
+ thePrinter.startBeginVisit("IsAttributeOfPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsAttributeOfPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsAttributeOfPositionIterator>
+
+
+// <IsParentPositionIterator>
+void PrinterVisitor::beginVisit ( const IsParentPositionIterator& a) {
+ thePrinter.startBeginVisit("IsParentPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsParentPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsParentPositionIterator>
+
+
+// <IsPrecedingInDocumentOrderPositionIterator>
+void PrinterVisitor::beginVisit ( const IsPrecedingInDocumentOrderPositionIterator& a) {
+ thePrinter.startBeginVisit("IsPrecedingInDocumentOrderPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsPrecedingInDocumentOrderPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsPrecedingInDocumentOrderPositionIterator>
+
+
+// <IsFollowingInDocumentOrderPositionIterator>
+void PrinterVisitor::beginVisit ( const IsFollowingInDocumentOrderPositionIterator& a) {
+ thePrinter.startBeginVisit("IsFollowingInDocumentOrderPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsFollowingInDocumentOrderPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsFollowingInDocumentOrderPositionIterator>
+
+
+// <LevelPositionIterator>
+void PrinterVisitor::beginVisit ( const LevelPositionIterator& a) {
+ thePrinter.startBeginVisit("LevelPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const LevelPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </LevelPositionIterator>
+
+
+// <IsAttributePositionIterator>
+void PrinterVisitor::beginVisit ( const IsAttributePositionIterator& a) {
+ thePrinter.startBeginVisit("IsAttributePositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsAttributePositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsAttributePositionIterator>
+
+
+// <IsCommentPositionIterator>
+void PrinterVisitor::beginVisit ( const IsCommentPositionIterator& a) {
+ thePrinter.startBeginVisit("IsCommentPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsCommentPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsCommentPositionIterator>
+
+
+// <IsDocumentPositionIterator>
+void PrinterVisitor::beginVisit ( const IsDocumentPositionIterator& a) {
+ thePrinter.startBeginVisit("IsDocumentPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsDocumentPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsDocumentPositionIterator>
+
+
+// <IsElementPositionIterator>
+void PrinterVisitor::beginVisit ( const IsElementPositionIterator& a) {
+ thePrinter.startBeginVisit("IsElementPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsElementPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsElementPositionIterator>
+
+
+// <IsProcessingInstructionPositionIterator>
+void PrinterVisitor::beginVisit ( const IsProcessingInstructionPositionIterator& a) {
+ thePrinter.startBeginVisit("IsProcessingInstructionPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsProcessingInstructionPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsProcessingInstructionPositionIterator>
+
+
+// <IsTextPositionIterator>
+void PrinterVisitor::beginVisit ( const IsTextPositionIterator& a) {
+ thePrinter.startBeginVisit("IsTextPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsTextPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsTextPositionIterator>
+
+
+// <IsSiblingPositionIterator>
+void PrinterVisitor::beginVisit ( const IsSiblingPositionIterator& a) {
+ thePrinter.startBeginVisit("IsSiblingPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IsSiblingPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </IsSiblingPositionIterator>
+
+
+// <InSameTreePositionIterator>
+void PrinterVisitor::beginVisit ( const InSameTreePositionIterator& a) {
+ thePrinter.startBeginVisit("InSameTreePositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const InSameTreePositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </InSameTreePositionIterator>
+
+
+// <InCollectionPositionIterator>
+void PrinterVisitor::beginVisit ( const InCollectionPositionIterator& a) {
+ thePrinter.startBeginVisit("InCollectionPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const InCollectionPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </InCollectionPositionIterator>
+
+
+// <InSameCollectionPositionIterator>
+void PrinterVisitor::beginVisit ( const InSameCollectionPositionIterator& a) {
+ thePrinter.startBeginVisit("InSameCollectionPositionIterator", ++theId);
+ printCommons( &a, theId );
+ thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const InSameCollectionPositionIterator& ) {
+ thePrinter.startEndVisit();
+ thePrinter.endEndVisit();
+}
+// </InSameCollectionPositionIterator>
+
+
// <NodeReferenceIterator>
void PrinterVisitor::beginVisit ( const NodeReferenceIterator& a) {
thePrinter.startBeginVisit("NodeReferenceIterator", ++theId);
=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.h'
--- src/runtime/visitors/pregenerated/printer_visitor.h 2011-10-19 15:28:51 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.h 2011-11-04 19:40:32 +0000
@@ -286,6 +286,27 @@
void beginVisit( const FnPutIterator& );
void endVisit ( const FnPutIterator& );
+ void beginVisit( const HostLangIterator& );
+ void endVisit ( const HostLangIterator& );
+
+ void beginVisit( const IsStopWordIterator& );
+ void endVisit ( const IsStopWordIterator& );
+
+ void beginVisit( const StemIterator& );
+ void endVisit ( const StemIterator& );
+
+ void beginVisit( const StripDiacriticsIterator& );
+ void endVisit ( const StripDiacriticsIterator& );
+
+ void beginVisit( const ThesaurusLookupIterator& );
+ void endVisit ( const ThesaurusLookupIterator& );
+
+ void beginVisit( const TokenizeIterator& );
+ void endVisit ( const TokenizeIterator& );
+
+ void beginVisit( const TokenizerPropertiesIterator& );
+ void endVisit ( const TokenizerPropertiesIterator& );
+
void beginVisit( const FunctionNameIterator& );
void endVisit ( const FunctionNameIterator& );
@@ -457,6 +478,78 @@
void beginVisit( const FrexpIterator& );
void endVisit ( const FrexpIterator& );
+ void beginVisit( const NodePositionIterator& );
+ void endVisit ( const NodePositionIterator& );
+
+ void beginVisit( const IsAncestorPositionIterator& );
+ void endVisit ( const IsAncestorPositionIterator& );
+
+ void beginVisit( const IsFollowingSiblingPositionIterator& );
+ void endVisit ( const IsFollowingSiblingPositionIterator& );
+
+ void beginVisit( const IsFollowingPositionIterator& );
+ void endVisit ( const IsFollowingPositionIterator& );
+
+ void beginVisit( const IsInSubtreeOfPositionIterator& );
+ void endVisit ( const IsInSubtreeOfPositionIterator& );
+
+ void beginVisit( const IsDescendantPositionIterator& );
+ void endVisit ( const IsDescendantPositionIterator& );
+
+ void beginVisit( const IsPrecedingSiblingPositionIterator& );
+ void endVisit ( const IsPrecedingSiblingPositionIterator& );
+
+ void beginVisit( const IsPrecedingPositionIterator& );
+ void endVisit ( const IsPrecedingPositionIterator& );
+
+ void beginVisit( const IsChildPositionIterator& );
+ void endVisit ( const IsChildPositionIterator& );
+
+ void beginVisit( const IsAttributeOfPositionIterator& );
+ void endVisit ( const IsAttributeOfPositionIterator& );
+
+ void beginVisit( const IsParentPositionIterator& );
+ void endVisit ( const IsParentPositionIterator& );
+
+ void beginVisit( const IsPrecedingInDocumentOrderPositionIterator& );
+ void endVisit ( const IsPrecedingInDocumentOrderPositionIterator& );
+
+ void beginVisit( const IsFollowingInDocumentOrderPositionIterator& );
+ void endVisit ( const IsFollowingInDocumentOrderPositionIterator& );
+
+ void beginVisit( const LevelPositionIterator& );
+ void endVisit ( const LevelPositionIterator& );
+
+ void beginVisit( const IsAttributePositionIterator& );
+ void endVisit ( const IsAttributePositionIterator& );
+
+ void beginVisit( const IsCommentPositionIterator& );
+ void endVisit ( const IsCommentPositionIterator& );
+
+ void beginVisit( const IsDocumentPositionIterator& );
+ void endVisit ( const IsDocumentPositionIterator& );
+
+ void beginVisit( const IsElementPositionIterator& );
+ void endVisit ( const IsElementPositionIterator& );
+
+ void beginVisit( const IsProcessingInstructionPositionIterator& );
+ void endVisit ( const IsProcessingInstructionPositionIterator& );
+
+ void beginVisit( const IsTextPositionIterator& );
+ void endVisit ( const IsTextPositionIterator& );
+
+ void beginVisit( const IsSiblingPositionIterator& );
+ void endVisit ( const IsSiblingPositionIterator& );
+
+ void beginVisit( const InSameTreePositionIterator& );
+ void endVisit ( const InSameTreePositionIterator& );
+
+ void beginVisit( const InCollectionPositionIterator& );
+ void endVisit ( const InCollectionPositionIterator& );
+
+ void beginVisit( const InSameCollectionPositionIterator& );
+ void endVisit ( const InSameCollectionPositionIterator& );
+
void beginVisit( const NodeReferenceIterator& );
void endVisit ( const NodeReferenceIterator& );
=== modified file 'src/store/api/annotation.h'
--- src/store/api/annotation.h 2011-09-12 22:42:28 +0000
+++ src/store/api/annotation.h 2011-11-04 19:40:32 +0000
@@ -23,22 +23,24 @@
namespace zorba { namespace store {
- class Annotation : public RCObject
- {
- protected:
- SYNC_CODE(mutable RCLock theRCLock;)
+
+class Annotation : public RCObject
+{
+protected:
+ SYNC_CODE(mutable RCLock theRCLock;)
- public:
- SYNC_CODE(RCLock* getRCLock() const { return &theRCLock; })
-
- long* getSharedRefCounter() const { return NULL; }
-
- virtual ~Annotation() {}
-
- public:
- Item_t theName;
- std::vector<Item_t> theLiterals;
- };
+public:
+ Item_t theName;
+ std::vector<Item_t> theLiterals;
+
+public:
+ SYNC_CODE(RCLock* getRCLock() const { return &theRCLock; })
+
+ long* getSharedRefCounter() const { return NULL; }
+
+ virtual ~Annotation() {}
+};
+
} /* namespace store */ } /* namespace zorba */
=== modified file 'src/store/api/index.h'
--- src/store/api/index.h 2011-09-30 14:06:33 +0000
+++ src/store/api/index.h 2011-11-04 19:40:32 +0000
@@ -29,8 +29,6 @@
{
class IndexSpecification;
-class IndexKeyCompareFunction;
-class IndexColumnRange;
class IndexEntryCreator;
class Iterator;
@@ -40,26 +38,54 @@
/***************************************************************************//**
Specification for creating a value or general index.
- theNumKeyColumns: The number of columns in each key.
- theKeyTypes : The data types of the key columns. Each type must be a
- builtin atomic type, and for sorted indices, it must have
- an ordering.
- theCollations : The names (uris) of the collations to use when comparing the
- string columns of two keys. The size of this vector is equal
- to theNumKeyColumns; if a type of a key column is not string,
- the associated entry in theCollations is the empty string.
- theTimezone : The timezone is needed to compare date/time key values.
- theIsGeneral : Whether the index is "general" or not.
- theIsUnique : Whether the index is unique, i.e., there is exactly one
- value associated with each key.
- theIsSorted : Whether the index is sorted by its key values or not.
- theIsTemp : Whether the index is temporary or not.
- theIsThreadSafe : Whether the index can be shared among multiple threads or not
- theIsAutomatic : Whether the index must be maintained during/after each apply-
- updates or not.
-
- theSources : The qnames of the collections accessed by the defining exprs
- of this index.
+ theNumKeyColumns:
+ -----------------
+ The number of columns in each key.
+
+ theKeyTypes:
+ ------------
+ The data types of the key columns. Each type must be a builtin atomic type,
+ and for sorted indices, it must have an ordering.
+
+ theCollations:
+ --------------
+ The names (uris) of the collations to use when comparing the string columns
+ of two keys. The size of this vector is equal to theNumKeyColumns; if a type
+ of a key column is not string, the associated entry in theCollations is the
+ empty string.
+
+ theTimezone:
+ ------------
+ The timezone is needed to compare date/time key values.
+
+ theIsGeneral:
+ -------------
+ Whether the index is "general" or not.
+
+ theIsUnique:
+ ------------
+ Whether the index is unique, i.e., there is exactly one value associated with
+ each key.
+
+ theIsSorted:
+ ------------
+ Whether the index is sorted by its key values or not.
+
+ theIsTemp:
+ ----------
+ Whether the index is temporary or not.
+
+ theIsThreadSafe:
+ ----------------
+ Whether the index can be shared among multiple threads or not.
+
+ theIsAutomatic:
+ ---------------
+ Whether the index must be maintained during/after each apply- updates or not.
+
+ theSources:
+ -----------
+ The qnames of the collections accessed by the defining exprs of this index.
********************************************************************************/
class IndexSpecification
{
=== modified file 'src/store/api/item.h'
--- src/store/api/item.h 2011-10-05 17:49:48 +0000
+++ src/store/api/item.h 2011-11-04 19:40:32 +0000
@@ -662,6 +662,12 @@
*
*/
virtual bool
+ isInSubtreeOf(const store::Item_t&) const;
+
+ /**
+ *
+ */
+ virtual bool
isDescendant(const store::Item_t&) const;
/**
@@ -686,17 +692,95 @@
*
*/
virtual bool
+ isAttribute(const store::Item_t&) const;
+
+ /**
+ *
+ */
+ virtual bool
isParent(const store::Item_t&) const;
/**
*
*/
+ virtual bool
+ isPrecedingInDocumentOrder(const store::Item_t&) const;
+
+ /**
+ *
+ */
+ virtual bool
+ isFollowingInDocumentOrder(const store::Item_t&) const;
+
+ /**
+ *
+ */
virtual store::Item_t
getLevel() const;
/**
*
*/
+ virtual bool
+ isSibling(const store::Item_t&) const;
+
+ /**
+ *
+ */
+ virtual bool
+ isAttribute() const;
+
+ /**
+ *
+ */
+ virtual bool
+ isComment() const;
+
+ /**
+ *
+ */
+ virtual bool
+ isDocument() const;
+
+ /**
+ *
+ */
+ virtual bool
+ isElement() const;
+
+ /**
+ *
+ */
+ virtual bool
+ isProcessingInstruction() const;
+
+ /**
+ *
+ */
+ virtual bool
+ isText() const;
+
+ /**
+ *
+ */
+ virtual bool
+ inSameTree(const store::Item_t&) const;
+
+ /**
+ *
+ */
+ virtual bool
+ inCollection() const;
+
+ /**
+ *
+ */
+ virtual bool
+ inSameCollection(const store::Item_t&) const;
+
+ /**
+ *
+ */
virtual store::Item_t
leastCommonAncestor(const store::Item_t&) const;
=== modified file 'src/store/api/store.h'
--- src/store/api/store.h 2011-10-10 12:56:57 +0000
+++ src/store/api/store.h 2011-11-04 19:40:32 +0000
@@ -115,6 +115,15 @@
*/
virtual bool getNodeByReference(store::Item_t& result, const zstring& reference) = 0;
+ /* ------------------ Structural Information Management ----------------------*/
+
+ /**
+ * Computes the structural information of the passed item.
+ *
+ * @param item XDM item
+ * @return Returns an item of type xs:uri
+ */
+ virtual bool getStructuralInformation(Item_t& result, const Item* node) = 0;
/* --------------------------- Node Id Management ---------------------------*/
=== modified file 'src/store/naive/atomic_items.cpp'
--- src/store/naive/atomic_items.cpp 2011-09-30 14:06:33 +0000
+++ src/store/naive/atomic_items.cpp 2011-11-04 19:40:32 +0000
@@ -14,6 +14,7 @@
* limitations under the License.
*/
#include "stdafx.h"
+#include <limits.h>
#include <zorba/internal/unique_ptr.h>
@@ -38,6 +39,7 @@
#include "store/naive/item_iterator.h"
#include "store/naive/node_items.h"
#include "store/naive/atomic_items.h"
+#include "store/naive/ordpath.h"
#include "util/ascii_util.h"
#include "util/string_util.h"
@@ -562,6 +564,18 @@
}
+bool UntypedAtomicItem::equals(
+ const store::Item* other,
+ long timezone,
+ const XQPCollator* collation) const
+{
+ if (collation == NULL || collation->doMemCmp())
+ return theValue == other->getString();
+
+ return (utf8::compare(theValue, other->getString(), collation) == 0);
+}
+
+
store::Item_t UntypedAtomicItem::getEBV() const
{
bool b = ! ( theValue == "" );
@@ -598,11 +612,13 @@
GET_STORE().getQNamePool().remove(this);
}
+
QNameItem* QNameItem::getNormalized() const
{
return (isNormalized() ? const_cast<QNameItem*>(this) : theNormQName.getp());
}
+
uint32_t QNameItem::hash(long timezone, const XQPCollator* aCollation) const
{
const void* tmp = getNormalized();
@@ -618,22 +634,20 @@
store::Item_t QNameItem::getEBV() const
{
- throw XQUERY_EXCEPTION(
- err::FORG0006,
- ERROR_PARAMS(
- ZED( OperationNotDef_23 ), ZED( EffectiveBooleanValue ), "QName"
- )
- );
+ throw XQUERY_EXCEPTION(err::FORG0006,
+ ERROR_PARAMS(ZED(OperationNotDef_23), ZED(EffectiveBooleanValue), "QName"));
}
+
bool QNameItem::equals(
- const store::Item* item,
- long timezone,
- const XQPCollator* aCollation) const
+ const store::Item* item,
+ long timezone,
+ const XQPCollator* aCollation) const
{
return (getNormalized() == static_cast<const QNameItem*>(item)->getNormalized());
}
+
zstring QNameItem::getStringValue() const
{
if (thePrefix.empty())
@@ -742,7 +756,8 @@
long timezone,
const XQPCollator* aCollation) const
{
- return (theQName->getNormalized() == static_cast<const NotationItem*>(item)->theQName->getNormalized());
+ return (theQName->getNormalized() ==
+ static_cast<const NotationItem*>(item)->theQName->getNormalized());
}
@@ -817,6 +832,723 @@
}
+bool AnyUriItem::isAncestor(const store::Item_t& aOther) const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isAncestor(aOther);
+}
+
+
+bool AnyUriItem::isFollowingSibling(const store::Item_t& aOther) const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isFollowingSibling(aOther);
+}
+
+
+bool AnyUriItem::isFollowing(const store::Item_t& aOther) const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isFollowing(aOther);
+}
+
+
+bool AnyUriItem::isDescendant(const store::Item_t& aOther) const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isDescendant(aOther);
+}
+
+
+bool AnyUriItem::isInSubtreeOf(const store::Item_t& aOther) const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isInSubtreeOf(aOther);
+}
+
+
+bool AnyUriItem::isPrecedingSibling(const store::Item_t& aOther) const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isPrecedingSibling(aOther);
+}
+
+
+bool AnyUriItem::isPreceding(const store::Item_t& aOther) const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isPreceding(aOther);
+}
+
+
+bool AnyUriItem::isChild(const store::Item_t& aOther) const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isChild(aOther);
+}
+
+
+bool AnyUriItem::isAttribute(const store::Item_t& aOther) const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isAttribute(aOther);
+}
+
+
+bool AnyUriItem::isParent(const store::Item_t& aOther) const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isParent(aOther);
+}
+
+
+bool AnyUriItem::isPrecedingInDocumentOrder(const store::Item_t& aOther) const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isPrecedingInDocumentOrder(aOther);
+}
+
+
+bool AnyUriItem::isFollowingInDocumentOrder(const store::Item_t& aOther) const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isFollowingInDocumentOrder(aOther);
+}
+
+
+store::Item_t AnyUriItem::getLevel() const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->getLevel();
+}
+
+
+bool AnyUriItem::isAttribute() const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isAttribute();
+}
+
+
+bool AnyUriItem::isComment() const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isComment();
+}
+
+
+bool AnyUriItem::isDocument() const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isDocument();
+}
+
+
+bool AnyUriItem::isElement() const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isElement();
+}
+
+
+bool AnyUriItem::isProcessingInstruction() const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isProcessingInstruction();
+}
+
+
+bool AnyUriItem::isText() const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isText();
+}
+
+
+bool AnyUriItem::isSibling(const store::Item_t& aOther) const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->isSibling(aOther);
+}
+
+
+bool AnyUriItem::inSameTree(const store::Item_t& aOther) const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->inSameTree(aOther);
+}
+
+
+bool AnyUriItem::inCollection() const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return static_cast<StructuralAnyUriItem *>(lThisUri.getp())->inCollection();
+}
+
+
+bool AnyUriItem::inSameCollection(const store::Item_t& aOther) const
+{
+ store::Item_t lThisUri;
+ zstring tempValue=theValue;
+ GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+ return lThisUri->inSameCollection(aOther);
+}
+
+
+/*******************************************************************************
+ class StructuralAnyUriItem
+********************************************************************************/
+
+StructuralAnyUriItem::StructuralAnyUriItem(
+ zstring& encoded,
+ ulong collectionId,
+ ulong treeId,
+ store::StoreConsts::NodeKind nodeKind,
+ const OrdPath& ordPath)
+ :
+ theCollectionId(collectionId),
+ theTreeId(treeId),
+ theNodeKind(nodeKind),
+ theOrdPath(ordPath)
+{
+ theValue.take(encoded);
+}
+
+
+StructuralAnyUriItem::StructuralAnyUriItem(zstring& value)
+{
+ theValue.take(value);
+
+ ulong prefixlen = (ulong)strlen("zorba:");
+
+ if (strncmp(theValue.c_str(), "zorba:", prefixlen))
+ throw ZORBA_EXCEPTION(zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS(theValue));
+
+ const char* start;
+
+ errno = 0;
+
+ //
+ // Decode collection id
+ //
+ start = theValue.c_str() + prefixlen;
+
+ char* next = const_cast<char*>(start);
+
+ theCollectionId = strtoul(start, &next, 10);
+
+ if (errno != 0 || start == next)
+ throw ZORBA_EXCEPTION(zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS(theValue));
+
+ start = next;
+
+ if (*start != '.')
+ throw ZORBA_EXCEPTION(zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS(theValue));
+
+ ++start;
+
+ //
+ // Decode tree id
+ //
+ theTreeId = strtoul(start, &next, 10);
+
+ if (errno != 0 || start == next)
+ throw ZORBA_EXCEPTION(zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS(theValue));
+
+ start = next;
+
+ if (*start != '.')
+ throw ZORBA_EXCEPTION(zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS(theValue));
+
+ ++start;
+
+ //
+ // Parse the node kind
+ //
+ if (*start > '0' && *start <='6')
+ theNodeKind = static_cast<store::StoreConsts::NodeKind>(*start-'0');
+ else
+ throw ZORBA_EXCEPTION(zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS(theValue));
+
+ ++start;
+
+ if (*start != '.')
+ throw ZORBA_EXCEPTION(zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS(theValue));
+
+ ++start;
+
+ //
+ // Decode OrdPath
+ //
+ theOrdPath = OrdPath((unsigned char*)start, (ulong)strlen(start));
+}
+
+
+bool StructuralAnyUriItem::isAncestor(const store::Item_t& aOther) const
+{
+ // Is the "other" an ancestor of "this"?
+
+ AnyUriItem* lOtherUriP = static_cast<AnyUriItem *>(aOther.getp());
+
+ if (lOtherUriP->getAnyUriTypeCode() != STRUCTURAL_INFORMATION_ANY_URI)
+ {
+ store::Item_t lOtherUri;
+ zstring tmp = lOtherUriP->theValue;
+ GET_FACTORY().createStructuralAnyURI(lOtherUri, tmp);
+ return isAncestor(lOtherUri);
+ }
+ else
+ {
+ StructuralAnyUriItem* other = static_cast<StructuralAnyUriItem*>(aOther.getp());
+
+ return
+ (other->theCollectionId == theCollectionId &&
+ other->theTreeId == theTreeId &&
+ theOrdPath.getRelativePosition(other->theOrdPath) == OrdPath::ANCESTOR);
+ }
+}
+
+
+bool StructuralAnyUriItem::isFollowingSibling(const store::Item_t& aOther) const
+{
+ // Is the "other" a following sibling of "this"?
+
+ AnyUriItem* lOtherUriP = static_cast<AnyUriItem *>(aOther.getp());
+
+ if (lOtherUriP->getAnyUriTypeCode() != STRUCTURAL_INFORMATION_ANY_URI)
+ {
+ store::Item_t lOtherUri;
+ zstring tmp = lOtherUriP->theValue;
+ GET_FACTORY().createStructuralAnyURI(lOtherUri, tmp);
+ return isFollowingSibling(lOtherUri);
+ }
+ else
+ {
+ StructuralAnyUriItem* other = static_cast<StructuralAnyUriItem*>(aOther.getp());
+
+ return
+ (other->theCollectionId == theCollectionId &&
+ other->theTreeId == theTreeId &&
+ other->theNodeKind != store::StoreConsts::attributeNode &&
+ theNodeKind != store::StoreConsts::attributeNode &&
+ theOrdPath.getRelativePosition2(other->theOrdPath) == OrdPath::FOLLOWING_SIBLING);
+ }
+}
+
+
+bool StructuralAnyUriItem::isFollowing(const store::Item_t& aOther) const
+{
+ // Is the "other" a following node of "this"?
+
+ AnyUriItem* lOtherUriP = static_cast<AnyUriItem *>(aOther.getp());
+
+ if (lOtherUriP->getAnyUriTypeCode() != STRUCTURAL_INFORMATION_ANY_URI)
+ {
+ store::Item_t lOtherUri;
+ zstring tmp = lOtherUriP->theValue;
+ GET_FACTORY().createStructuralAnyURI(lOtherUri, tmp);
+ return isFollowing(lOtherUri);
+ }
+ else
+ {
+ StructuralAnyUriItem* other = static_cast<StructuralAnyUriItem*>(aOther.getp());
+
+ return
+ (other->theCollectionId == theCollectionId &&
+ other->theTreeId == theTreeId &&
+ theOrdPath.getRelativePosition(other->theOrdPath) == OrdPath::FOLLOWING);
+ }
+}
+
+
+bool StructuralAnyUriItem::isDescendant(const store::Item_t& aOther) const
+{
+ // Is the "other" a descendant of "this"?
+
+ AnyUriItem* lOtherUriP = static_cast<AnyUriItem *>(aOther.getp());
+
+ if (lOtherUriP->getAnyUriTypeCode() != STRUCTURAL_INFORMATION_ANY_URI)
+ {
+ store::Item_t lOtherUri;
+ zstring tmp = lOtherUriP->theValue;
+ GET_FACTORY().createStructuralAnyURI(lOtherUri, tmp);
+ return isDescendant(lOtherUri);
+ }
+ else
+ {
+ StructuralAnyUriItem* other = static_cast<StructuralAnyUriItem*>(aOther.getp());
+ return
+ (other->theCollectionId == theCollectionId &&
+ other->theTreeId == theTreeId &&
+ other->theNodeKind != store::StoreConsts::attributeNode &&
+ theOrdPath.getRelativePosition(other->theOrdPath) == OrdPath::DESCENDANT);
+ }
+}
+
+
+bool StructuralAnyUriItem::isInSubtreeOf(const store::Item_t& aOther) const
+{
+ // Is the "other" in the subtree rooted at "this"?
+
+ AnyUriItem* lOtherUriP = static_cast<AnyUriItem *>(aOther.getp());
+
+ if (lOtherUriP->getAnyUriTypeCode() != STRUCTURAL_INFORMATION_ANY_URI)
+ {
+ store::Item_t lOtherUri;
+ zstring tmp = lOtherUriP->theValue;
+ GET_FACTORY().createStructuralAnyURI(lOtherUri, tmp);
+ return isInSubtreeOf(lOtherUri);
+ }
+ else
+ {
+ StructuralAnyUriItem* other = static_cast<StructuralAnyUriItem*>(aOther.getp());
+ return
+ (other->theCollectionId == theCollectionId &&
+ other->theTreeId == theTreeId &&
+ theOrdPath.getRelativePosition(other->theOrdPath) == OrdPath::DESCENDANT);
+ }
+}
+
+
+bool StructuralAnyUriItem::isPrecedingSibling(const store::Item_t& aOther) const
+{
+ // Is the "other" a preceding sibling of "this"?
+
+ AnyUriItem* lOtherUriP = static_cast<AnyUriItem *>(aOther.getp());
+
+ if (lOtherUriP->getAnyUriTypeCode() != STRUCTURAL_INFORMATION_ANY_URI)
+ {
+ store::Item_t lOtherUri;
+ zstring tmp = lOtherUriP->theValue;
+ GET_FACTORY().createStructuralAnyURI(lOtherUri, tmp);
+ return isPrecedingSibling(lOtherUri);
+ }
+ else
+ {
+ StructuralAnyUriItem* other = static_cast<StructuralAnyUriItem*>(aOther.getp());
+ return
+ (other->theCollectionId == theCollectionId &&
+ other->theTreeId == theTreeId &&
+ other->theNodeKind != store::StoreConsts::attributeNode &&
+ theNodeKind != store::StoreConsts::attributeNode &&
+ theOrdPath.getRelativePosition2(other->theOrdPath) == OrdPath::PRECEDING_SIBLING);
+ }
+}
+
+
+bool StructuralAnyUriItem::isPreceding(const store::Item_t& aOther) const
+{
+ // Is the "other" a preceding node of "this"?
+
+ AnyUriItem* lOtherUriP = static_cast<AnyUriItem *>(aOther.getp());
+
+ if (lOtherUriP->getAnyUriTypeCode() != STRUCTURAL_INFORMATION_ANY_URI)
+ {
+ store::Item_t lOtherUri;
+ zstring tmp = lOtherUriP->theValue;
+ GET_FACTORY().createStructuralAnyURI(lOtherUri, tmp);
+ return isPreceding(lOtherUri);
+ }
+ else
+ {
+ StructuralAnyUriItem* other = static_cast<StructuralAnyUriItem*>(aOther.getp());
+ return
+ (other->theCollectionId == theCollectionId &&
+ other->theTreeId == theTreeId &&
+ theOrdPath.getRelativePosition(other->theOrdPath) == OrdPath::PRECEDING);
+ }
+}
+
+
+bool StructuralAnyUriItem::isChild(const store::Item_t& aOther) const
+{
+ // Is the "other" a child of "this"?
+
+ AnyUriItem* lOtherUriP = static_cast<AnyUriItem *>(aOther.getp());
+
+ if (lOtherUriP->getAnyUriTypeCode() != STRUCTURAL_INFORMATION_ANY_URI)
+ {
+ store::Item_t lOtherUri;
+ zstring tmp = lOtherUriP->theValue;
+ GET_FACTORY().createStructuralAnyURI(lOtherUri, tmp);
+ return isChild(lOtherUri);
+ }
+ else
+ {
+ StructuralAnyUriItem* other = static_cast<StructuralAnyUriItem*>(aOther.getp());
+ return
+ (other->theCollectionId == theCollectionId &&
+ other->theTreeId == theTreeId &&
+ other->theNodeKind != store::StoreConsts::attributeNode &&
+ theOrdPath.getRelativePosition2(other->theOrdPath) == OrdPath::CHILD);
+ }
+}
+
+
+bool StructuralAnyUriItem::isAttribute(const store::Item_t& aOther) const
+{
+ // Is the "other" an attribute of "this"?
+
+ AnyUriItem* lOtherUriP = static_cast<AnyUriItem *>(aOther.getp());
+
+ if (lOtherUriP->getAnyUriTypeCode() != STRUCTURAL_INFORMATION_ANY_URI)
+ {
+ store::Item_t lOtherUri;
+ zstring tmp = lOtherUriP->theValue;
+ GET_FACTORY().createStructuralAnyURI(lOtherUri, tmp);
+ return isAttribute(lOtherUri);
+ }
+ else
+ {
+ StructuralAnyUriItem* other = static_cast<StructuralAnyUriItem*>(aOther.getp());
+ return
+ (other->theCollectionId == theCollectionId &&
+ other->theTreeId == theTreeId &&
+ other->theNodeKind == store::StoreConsts::attributeNode &&
+ theOrdPath.getRelativePosition2(other->theOrdPath) == OrdPath::CHILD);
+ }
+}
+
+
+bool StructuralAnyUriItem::isParent(const store::Item_t& aOther) const
+{
+ // Is the "other" an parent of "this"?
+
+ AnyUriItem* lOtherUriP = static_cast<AnyUriItem *>(aOther.getp());
+
+ if (lOtherUriP->getAnyUriTypeCode() != STRUCTURAL_INFORMATION_ANY_URI)
+ {
+ store::Item_t lOtherUri;
+ zstring tmp = lOtherUriP->theValue;
+ GET_FACTORY().createStructuralAnyURI(lOtherUri, tmp);
+ return isParent(lOtherUri);
+ }
+ else
+ {
+ StructuralAnyUriItem* other = static_cast<StructuralAnyUriItem*>(aOther.getp());
+ return
+ (other->theCollectionId == theCollectionId &&
+ other->theTreeId == theTreeId &&
+ theOrdPath.getRelativePosition2(other->theOrdPath) == OrdPath::PARENT);
+ }
+}
+
+
+bool StructuralAnyUriItem::isPrecedingInDocumentOrder(const store::Item_t& aOther) const
+{
+ AnyUriItem* lOtherUriP = static_cast<AnyUriItem *>(aOther.getp());
+
+ if (lOtherUriP->getAnyUriTypeCode() != STRUCTURAL_INFORMATION_ANY_URI)
+ {
+ store::Item_t lOtherUri;
+ zstring tmp = lOtherUriP->theValue;
+ GET_FACTORY().createStructuralAnyURI(lOtherUri, tmp);
+ return isPrecedingInDocumentOrder(lOtherUri);
+ }
+ else
+ {
+ StructuralAnyUriItem* other = static_cast<StructuralAnyUriItem*>(aOther.getp());
+ return
+ (theCollectionId > other->theCollectionId ||
+ (theCollectionId == other->theCollectionId && theTreeId > other->theTreeId) ||
+ (theCollectionId == other->theCollectionId && other->theTreeId == theTreeId && theOrdPath > other->theOrdPath));
+ }
+}
+
+
+bool StructuralAnyUriItem::isFollowingInDocumentOrder(const store::Item_t& aOther) const
+{
+ AnyUriItem* lOtherUriP = static_cast<AnyUriItem *>(aOther.getp());
+
+ if (lOtherUriP->getAnyUriTypeCode() != STRUCTURAL_INFORMATION_ANY_URI)
+ {
+ store::Item_t lOtherUri;
+ zstring tmp = lOtherUriP->theValue;
+ GET_FACTORY().createStructuralAnyURI(lOtherUri, tmp);
+ return isFollowingInDocumentOrder(lOtherUri);
+ }
+ else
+ {
+ StructuralAnyUriItem* other = static_cast<StructuralAnyUriItem*>(aOther.getp());
+ return
+ (theCollectionId < other->theCollectionId ||
+ (theCollectionId == other->theCollectionId && theTreeId < other->theTreeId) ||
+ (theCollectionId == other->theCollectionId && other->theTreeId == theTreeId && theOrdPath < other->theOrdPath));
+ }
+}
+
+
+store::Item_t StructuralAnyUriItem::getLevel() const
+{
+ store::Item_t lResult;
+ GET_FACTORY().createInteger(lResult, theOrdPath.getLevel());
+ return lResult;
+}
+
+
+bool StructuralAnyUriItem::isAttribute() const
+{
+ return theNodeKind == store::StoreConsts::attributeNode;
+}
+
+
+bool StructuralAnyUriItem::isComment() const
+{
+ return theNodeKind == store::StoreConsts::commentNode;
+}
+
+
+bool StructuralAnyUriItem::isDocument() const
+{
+ return theNodeKind == store::StoreConsts::documentNode;
+}
+
+
+bool StructuralAnyUriItem::isElement() const
+{
+ return theNodeKind == store::StoreConsts::elementNode;
+}
+
+
+bool StructuralAnyUriItem::isProcessingInstruction() const
+{
+ return theNodeKind == store::StoreConsts::piNode;
+}
+
+
+bool StructuralAnyUriItem::isText() const
+{
+ return theNodeKind == store::StoreConsts::textNode;
+}
+
+
+bool StructuralAnyUriItem::isSibling(const store::Item_t& aOther) const
+{
+ AnyUriItem* lOtherUriP = static_cast<AnyUriItem *>(aOther.getp());
+
+ if (lOtherUriP->getAnyUriTypeCode() != STRUCTURAL_INFORMATION_ANY_URI)
+ {
+ store::Item_t lOtherUri;
+ zstring tmp = lOtherUriP->theValue;
+ GET_FACTORY().createStructuralAnyURI(lOtherUri, tmp);
+ return isSibling(lOtherUri);
+ }
+ else
+ {
+ StructuralAnyUriItem* other = static_cast<StructuralAnyUriItem*>(aOther.getp());
+
+ if (other->theCollectionId == theCollectionId &&
+ other->theTreeId == theTreeId &&
+ other->theNodeKind != store::StoreConsts::attributeNode &&
+ theNodeKind != store::StoreConsts::attributeNode)
+ {
+ OrdPath::RelativePosition pos =
+ theOrdPath.getRelativePosition2(other->theOrdPath);
+
+ return (pos == OrdPath::FOLLOWING_SIBLING ||
+ pos==OrdPath::PRECEDING_SIBLING);
+ }
+ else
+ {
+ return false;
+ }
+ }
+}
+
+
+bool StructuralAnyUriItem::inSameTree(const store::Item_t& aOther) const
+{
+ AnyUriItem* lOtherUriP = static_cast<AnyUriItem *>(aOther.getp());
+
+ if (lOtherUriP->getAnyUriTypeCode() != STRUCTURAL_INFORMATION_ANY_URI)
+ {
+ store::Item_t lOtherUri;
+ zstring tmp = lOtherUriP->theValue;
+ GET_FACTORY().createStructuralAnyURI(lOtherUri, tmp);
+ return inSameTree(lOtherUri);
+ }
+ else
+ {
+ StructuralAnyUriItem* other = static_cast<StructuralAnyUriItem*>(aOther.getp());
+ return (theCollectionId == other->theCollectionId &&
+ theTreeId == other->theTreeId);
+ }
+}
+
+
+bool StructuralAnyUriItem::inCollection() const
+{
+ return theCollectionId != 0;
+}
+
+
+bool StructuralAnyUriItem::inSameCollection(const store::Item_t& aOther) const
+{
+ AnyUriItem* lOtherUriP = static_cast<AnyUriItem *>(aOther.getp());
+
+ if (lOtherUriP->getAnyUriTypeCode() != STRUCTURAL_INFORMATION_ANY_URI)
+ {
+ store::Item_t lOtherUri;
+ zstring tmp = lOtherUriP->theValue;
+ GET_FACTORY().createStructuralAnyURI(lOtherUri, tmp);
+ return inSameCollection(lOtherUri);
+ }
+ else
+ {
+ return
+ (
+ theCollectionId !=0 &&
+ theCollectionId == static_cast<StructuralAnyUriItem*>(aOther.getp())->theCollectionId
+ );
+
+ }
+}
+
+
/*******************************************************************************
class StringItem
********************************************************************************/
@@ -849,6 +1581,8 @@
long timezone,
const XQPCollator* aCollation) const
{
+ // Note: utf8::compare does byte comparison if the collation is null or
+ // requires byte comparison.
return utf8::compare(theValue, other->getString(), aCollation);
}
@@ -871,10 +1605,11 @@
}
#ifndef ZORBA_NO_FULL_TEXT
-FTTokenIterator_t
-StringItem::getTokens( TokenizerProvider const &provider,
- Tokenizer::Numbers &numbers, iso639_1::type lang,
- bool wildcards ) const
+FTTokenIterator_t StringItem::getTokens(
+ TokenizerProvider const &provider,
+ Tokenizer::Numbers &numbers,
+ iso639_1::type lang,
+ bool wildcards ) const
{
typedef NaiveFTTokenIterator::container_type tokens_t;
unique_ptr<tokens_t> tokens( new tokens_t );
@@ -893,7 +1628,8 @@
********************************************************************************/
void StreamableStringItem::appendStringValue(zstring& aBuf) const
{
- if (!theIsMaterialized) {
+ if (!theIsMaterialized)
+ {
materialize();
}
aBuf += theValue;
@@ -905,7 +1641,8 @@
long aTimezone,
const XQPCollator* aCollator) const
{
- if (!theIsMaterialized) {
+ if (!theIsMaterialized)
+ {
materialize();
}
return StringItem::compare(aOther, aTimezone, aCollator);
@@ -917,7 +1654,8 @@
long aTimezone,
XQPCollator const* aCollator) const
{
- if (!theIsMaterialized) {
+ if (!theIsMaterialized)
+ {
materialize();
}
return StringItem::equals(aItem, aTimezone, aCollator);
@@ -926,7 +1664,8 @@
store::Item_t StreamableStringItem::getEBV() const
{
- if (!theIsMaterialized) {
+ if (!theIsMaterialized)
+ {
materialize();
}
return StringItem::getEBV();
@@ -935,7 +1674,8 @@
zstring const& StreamableStringItem::getString() const
{
- if (!theIsMaterialized) {
+ if (!theIsMaterialized)
+ {
materialize();
}
return theValue;
@@ -944,7 +1684,8 @@
zstring StreamableStringItem::getStringValue() const
{
- if (!theIsMaterialized) {
+ if (!theIsMaterialized)
+ {
materialize();
}
return theValue;
@@ -953,7 +1694,8 @@
void StreamableStringItem::getStringValue2(zstring &val) const
{
- if (!theIsMaterialized) {
+ if (!theIsMaterialized)
+ {
materialize();
}
val = theValue;
@@ -964,7 +1706,8 @@
long aTimezone,
XQPCollator const* aCollator) const
{
- if (!theIsMaterialized) {
+ if (!theIsMaterialized)
+ {
materialize();
}
return StringItem::hash(aTimezone, aCollator);
@@ -973,7 +1716,8 @@
zstring StreamableStringItem::show() const
{
- if (!theIsMaterialized) {
+ if (!theIsMaterialized)
+ {
materialize();
}
return StringItem::show();
@@ -1016,11 +1760,13 @@
return theIstream;
}
+
StreamReleaser StreamableStringItem::getStreamReleaser()
{
return theStreamReleaser;
}
+
void StreamableStringItem::setStreamReleaser(StreamReleaser aReleaser)
{
theStreamReleaser = aReleaser;
=== modified file 'src/store/naive/atomic_items.h'
--- src/store/naive/atomic_items.h 2011-09-30 14:06:33 +0000
+++ src/store/naive/atomic_items.h 2011-11-04 19:40:32 +0000
@@ -29,6 +29,7 @@
#include "store/api/item.h"
#include "store/api/item_handle.h"
#include "store/naive/store_defs.h"
+#include "store/naive/shared_types.h"
#ifndef ZORBA_NO_FULL_TEXT
#include "store/naive/naive_ft_token_iterator.h"
@@ -38,6 +39,7 @@
#include "zorbatypes/datetime.h"
#include "diagnostics/xquery_diagnostics.h"
+#include "store/naive/ordpath.h"
namespace zorba
@@ -46,6 +48,13 @@
namespace simplestore
{
+
+enum AnyUriTypeCode
+{
+ NON_SPECIALIZED_ANY_URI,
+ STRUCTURAL_INFORMATION_ANY_URI
+};
+
class AtomicItemTokenizerCallback;
class QNameItem;
@@ -83,9 +92,6 @@
};
-typedef store::ItemHandle<AtomicItem> AtomicItem_t;
-
-
/*******************************************************************************
class UserTypedAtomicItem
********************************************************************************/
@@ -308,12 +314,9 @@
bool equals(
const store::Item* other,
long timezone = 0,
- const XQPCollator* aCollation = 0) const
- {
- return theValue == other->getString();
- }
+ const XQPCollator* collation = 0) const;
- store::Item_t getEBV( ) const;
+ store::Item_t getEBV() const;
zstring getStringValue() const { return theValue; }
@@ -483,6 +486,7 @@
class AnyUriItem : public AtomicItem
{
friend class BasicItemFactory;
+ friend class StructuralAnyUriItem;
protected:
zstring theValue;
@@ -493,6 +497,11 @@
AnyUriItem() {}
public:
+ virtual AnyUriTypeCode getAnyUriTypeCode() const
+ {
+ return NON_SPECIALIZED_ANY_URI;
+ }
+
SchemaTypeCode getTypeCode() const { return XS_ANY_URI; }
store::Item* getType( ) const;
@@ -526,6 +535,177 @@
const zstring& getString() const { return theValue; }
zstring show() const;
+
+ virtual bool
+ isAncestor(const store::Item_t&) const;
+
+ virtual bool
+ isFollowingSibling(const store::Item_t&) const;
+
+ virtual bool
+ isFollowing(const store::Item_t&) const;
+
+ virtual bool
+ isInSubtreeOf(const store::Item_t&) const;
+
+ virtual bool
+ isDescendant(const store::Item_t&) const;
+
+ virtual bool
+ isPrecedingSibling(const store::Item_t&) const;
+
+ virtual bool
+ isPreceding(const store::Item_t&) const;
+
+ virtual bool
+ isChild(const store::Item_t&) const;
+
+ virtual bool
+ isAttribute(const store::Item_t&) const;
+
+ virtual bool
+ isParent(const store::Item_t&) const;
+
+ virtual bool
+ isPrecedingInDocumentOrder(const store::Item_t&) const;
+
+ virtual bool
+ isFollowingInDocumentOrder(const store::Item_t&) const;
+
+ virtual store::Item_t
+ getLevel() const;
+
+ virtual bool
+ isAttribute() const;
+
+ virtual bool
+ isComment() const;
+
+ virtual bool
+ isDocument() const;
+
+ virtual bool
+ isElement() const;
+
+ virtual bool
+ isProcessingInstruction() const;
+
+ virtual bool
+ isText() const;
+
+ virtual bool
+ isSibling(const store::Item_t&) const;
+
+ virtual bool
+ inSameTree(const store::Item_t&) const;
+
+ virtual bool
+ inCollection() const;
+
+ virtual bool
+ inSameCollection(const store::Item_t&) const;
+};
+
+
+/*******************************************************************************
+ class StructuralAnyUriItem
+********************************************************************************/
+class StructuralAnyUriItem : public AnyUriItem
+{
+ friend class BasicItemFactory;
+
+protected:
+ ulong theCollectionId;
+ ulong theTreeId;
+ store::StoreConsts::NodeKind theNodeKind;
+ OrdPath theOrdPath;
+
+protected:
+ virtual AnyUriTypeCode getAnyUriTypeCode() const
+ {
+ return STRUCTURAL_INFORMATION_ANY_URI;
+ }
+
+ StructuralAnyUriItem(zstring& value);
+
+ StructuralAnyUriItem(
+ zstring& value,
+ ulong collectionId,
+ ulong treeId,
+ store::StoreConsts::NodeKind nodeKind,
+ const OrdPath& ordPath);
+
+ StructuralAnyUriItem() {}
+
+public:
+ bool
+ isAncestor(const store::Item_t&) const;
+
+ bool
+ isFollowingSibling(const store::Item_t&) const;
+
+ bool
+ isFollowing(const store::Item_t&) const;
+
+ bool
+ isInSubtreeOf(const store::Item_t&) const;
+
+ bool
+ isDescendant(const store::Item_t&) const;
+
+ bool
+ isPrecedingSibling(const store::Item_t&) const;
+
+ bool
+ isPreceding(const store::Item_t&) const;
+
+ bool
+ isChild(const store::Item_t&) const;
+
+ bool
+ isAttribute(const store::Item_t&) const;
+
+ bool
+ isParent(const store::Item_t&) const;
+
+ bool
+ isPrecedingInDocumentOrder(const store::Item_t&) const;
+
+ bool
+ isFollowingInDocumentOrder(const store::Item_t&) const;
+
+ store::Item_t
+ getLevel() const;
+
+ bool
+ isAttribute() const;
+
+ bool
+ isComment() const;
+
+ bool
+ isDocument() const;
+
+ bool
+ isElement() const;
+
+ bool
+ isProcessingInstruction() const;
+
+ bool
+ isText() const;
+
+ bool
+ isSibling(const store::Item_t&) const;
+
+ bool
+ inSameTree(const store::Item_t&) const;
+
+ bool
+ inCollection() const;
+
+ bool
+ inSameCollection(const store::Item_t&) const;
};
@@ -637,7 +817,8 @@
~StreamableStringItem()
{
- if (theStreamReleaser) {
+ if (theStreamReleaser)
+ {
theStreamReleaser(&theIstream);
}
}
@@ -1095,7 +1276,7 @@
class DecimalItem : public AtomicItem
{
friend class BasicItemFactory;
- friend class IndexBoxCondition;
+ friend class IndexConditionImpl;
friend class AtomicItem;
protected:
=== modified file 'src/store/naive/item.cpp'
--- src/store/naive/item.cpp 2011-09-27 20:45:01 +0000
+++ src/store/naive/item.cpp 2011-11-04 19:40:32 +0000
@@ -1027,6 +1027,15 @@
}
bool
+Item::isInSubtreeOf(const store::Item_t&) const
+{
+ throw ZORBA_EXCEPTION(
+ zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+ ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+ );
+}
+
+bool
Item::isDescendant(const store::Item_t&) const
{
throw ZORBA_EXCEPTION(
@@ -1063,6 +1072,15 @@
}
bool
+Item::isAttribute(const store::Item_t&) const
+{
+ throw ZORBA_EXCEPTION(
+ zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+ ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+ );
+}
+
+bool
Item::isParent(const store::Item_t&) const
{
throw ZORBA_EXCEPTION(
@@ -1071,6 +1089,24 @@
);
}
+bool
+Item::isPrecedingInDocumentOrder(const store::Item_t&) const
+{
+ throw ZORBA_EXCEPTION(
+ zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+ ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+ );
+}
+
+bool
+Item::isFollowingInDocumentOrder(const store::Item_t&) const
+{
+ throw ZORBA_EXCEPTION(
+ zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+ ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+ );
+}
+
store::Item_t
Item::getLevel() const
{
@@ -1080,6 +1116,97 @@
);
}
+bool
+Item::isSibling(const store::Item_t&) const
+{
+ throw ZORBA_EXCEPTION(
+ zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+ ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+ );
+}
+
+bool
+Item::isAttribute() const
+{
+ throw ZORBA_EXCEPTION(
+ zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+ ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+ );
+}
+
+bool
+Item::isComment() const
+{
+ throw ZORBA_EXCEPTION(
+ zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+ ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+ );
+}
+
+bool
+Item::isDocument() const
+{
+ throw ZORBA_EXCEPTION(
+ zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+ ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+ );
+}
+
+
+bool
+Item::isElement() const
+{
+ throw ZORBA_EXCEPTION(
+ zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+ ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+ );
+}
+
+bool
+Item::isProcessingInstruction() const
+{
+ throw ZORBA_EXCEPTION(
+ zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+ ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+ );
+}
+
+bool
+Item::isText() const
+{
+ throw ZORBA_EXCEPTION(
+ zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+ ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+ );
+}
+
+bool
+Item::inSameTree(const store::Item_t&) const
+{
+ throw ZORBA_EXCEPTION(
+ zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+ ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+ );
+}
+
+bool
+Item::inCollection() const
+{
+ throw ZORBA_EXCEPTION(
+ zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+ ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+ );
+}
+
+bool
+Item::inSameCollection(const store::Item_t&) const
+{
+ throw ZORBA_EXCEPTION(
+ zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+ ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+ );
+}
+
store::Item_t
Item::leastCommonAncestor(const store::Item_t&) const
{
=== modified file 'src/store/naive/loader_dtd.cpp'
--- src/store/naive/loader_dtd.cpp 2011-07-15 16:39:51 +0000
+++ src/store/naive/loader_dtd.cpp 2011-11-04 19:40:32 +0000
@@ -104,10 +104,12 @@
theSaxHandler.entityDecl = &FragmentXmlLoader::entityDecl;
}
+
FragmentXmlLoader::~FragmentXmlLoader()
{
}
+
store::Item_t FragmentXmlLoader::loadXml(
const zstring& baseUri,
const zstring& docUri,
@@ -117,6 +119,8 @@
xmlSubstituteEntitiesDefault(1);
+ theBaseUri = baseUri;
+
if (docUri.empty())
{
std::ostringstream uristream;
@@ -130,9 +134,6 @@
thePathStack.push(PathStepInfo(NULL, baseUri));
- theTree->setDocUri(theDocUri);
- theTree->setBaseUri(baseUri);
-
try
{
theFragmentStream = static_cast<FragmentIStream*>(&stream);
@@ -147,17 +148,24 @@
theFragmentStream->theBuffer = new char[static_cast<unsigned int>(fileSize+1)];
theFragmentStream->theBuffer[fileSize] = 0;
- std::streamsize numChars = readPacket(*theFragmentStream->theStream, theFragmentStream->theBuffer, fileSize);
+ std::streamsize numChars = readPacket(*theFragmentStream->theStream,
+ theFragmentStream->theBuffer,
+ fileSize);
theFragmentStream->buffer_size = numChars;
if (numChars < 0)
{
- theXQueryDiagnostics->add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0020_LOADER_IO_ERROR));
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0020_LOADER_IO_ERROR));
+
abortload();
return NULL;
}
else if (numChars == 0)
{
- theXQueryDiagnostics->add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0020_LOADER_IO_ERROR, ERROR_PARAMS(ZED(NoInputData))));
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0020_LOADER_IO_ERROR,
+ ERROR_PARAMS(ZED(NoInputData))));
+
abortload();
return NULL;
}
@@ -168,7 +176,10 @@
// ctxt = xmlCreate
if (ctxt == NULL)
{
- theXQueryDiagnostics->add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( ParserInitFailed ) )));
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,
+ ERROR_PARAMS(ZED(ParserInitFailed))));
+
abortload();
return NULL;
}
@@ -180,7 +191,10 @@
xmlParserInputPtr input = xmlNewInputStream(ctxt);
if (input == NULL)
{
- theXQueryDiagnostics->add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( ParserInitFailed ) )));
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,
+ ERROR_PARAMS(ZED(ParserInitFailed))));
+
abortload();
return NULL;
}
@@ -199,7 +213,10 @@
// Finally call the parser
if (xmlParseExtParsedEnt(ctxt)==-1)
{
- theXQueryDiagnostics->add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,ERROR_PARAMS( ZED( ParserNoCreateTree ) )));
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,
+ ERROR_PARAMS(ZED(ParserNoCreateTree))));
+
abortload();
return NULL;
}
@@ -223,11 +240,15 @@
{
if (!theDocUri.empty())
{
- theXQueryDiagnostics->add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( BadXMLDocument_2o ), theDocUri )));
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,
+ ERROR_PARAMS(ZED(BadXMLDocument_2o), theDocUri)));
}
else
{
- theXQueryDiagnostics->add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( BadXMLDocument_2o ) )));
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,
+ ERROR_PARAMS(ZED(BadXMLDocument_2o))));
}
abortload();
return NULL;
@@ -237,7 +258,10 @@
if ( ctxt->lastError.code == XML_NS_ERR_UNDEFINED_NAMESPACE ||
ctxt->lastError.code != XML_ERR_NO_DTD )
{
- theXQueryDiagnostics->add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( BadXMLDocument_2o ) )));
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,
+ ERROR_PARAMS(ZED(BadXMLDocument_2o))));
+
abortload();
return NULL;
}
@@ -256,6 +280,7 @@
return resultNode;
}
+
void FragmentXmlLoader::checkStopParsing(void* ctx)
{
FragmentXmlLoader& loader = *(static_cast<FragmentXmlLoader*>(ctx));
@@ -271,6 +296,8 @@
xmlStopParser(loader.ctxt);
}
}
+
+
void FragmentXmlLoader::startElement(
void * ctx,
const xmlChar * localname,
@@ -289,6 +316,7 @@
loader.element_depth++;
}
+
void FragmentXmlLoader::endElement(
void * ctx,
const xmlChar * localname,
@@ -314,6 +342,7 @@
checkStopParsing(ctx);
}
+
void FragmentXmlLoader::comment(
void * ctx,
const xmlChar * value)
@@ -322,6 +351,7 @@
checkStopParsing(ctx);
}
+
void FragmentXmlLoader::cdataBlock(
void * ctx,
const xmlChar * value,
@@ -331,6 +361,7 @@
checkStopParsing(ctx);
}
+
void FragmentXmlLoader::processingInstruction(
void * ctx,
const xmlChar * target,
@@ -480,7 +511,10 @@
Return the number of bytes actually read, throw an exception if any I/O
error occured.
********************************************************************************/
-std::streamsize DtdXmlLoader::readPacket(std::istream& stream, char* buf, std::streamoff size)
+std::streamsize DtdXmlLoader::readPacket(
+ std::istream& stream,
+ char* buf,
+ std::streamoff size)
{
try
{
@@ -527,6 +561,8 @@
xmlSubstituteEntitiesDefault(1);
+ theBaseUri = baseUri;
+
if (docUri.empty())
{
std::ostringstream uristream;
@@ -541,9 +577,6 @@
thePathStack.push(PathStepInfo(NULL, baseUri));
- theTree->setDocUri(theDocUri);
- theTree->setBaseUri(baseUri);
-
try
{
stream.seekg(0, std::ios::end);
@@ -601,7 +634,9 @@
if ( xmlParseDocument(ctxt)==-1 )
{
// std::cout << " xmlParseDocument: Error: Unable to create tree: " << ctxt->lastError.message << std::endl;
- theXQueryDiagnostics->add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,ERROR_PARAMS( ZED( ParserNoCreateTree ) )));
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,
+ ERROR_PARAMS(ZED(ParserNoCreateTree))));
abortload();
return NULL;
}
@@ -626,21 +661,15 @@
{
if (!theDocUri.empty())
{
- theXQueryDiagnostics->add_error(
- NEW_ZORBA_EXCEPTION(
- zerr::ZSTR0021_LOADER_PARSING_ERROR,
- ERROR_PARAMS( ZED( BadXMLDocument_2o ), theDocUri )
- )
- );
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,
+ ERROR_PARAMS(ZED(BadXMLDocument_2o), theDocUri)));
}
else
{
- theXQueryDiagnostics->add_error(
- NEW_ZORBA_EXCEPTION(
- zerr::ZSTR0021_LOADER_PARSING_ERROR,
- ERROR_PARAMS( ZED( BadXMLDocument_2o ) )
- )
- );
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,
+ ERROR_PARAMS(ZED(BadXMLDocument_2o))));
}
abortload();
@@ -656,12 +685,9 @@
if ( ctxt->lastError.code == XML_NS_ERR_UNDEFINED_NAMESPACE ||
ctxt->lastError.code != XML_ERR_NO_DTD )
{
- theXQueryDiagnostics->add_error(
- NEW_ZORBA_EXCEPTION(
- zerr::ZSTR0021_LOADER_PARSING_ERROR,
- ERROR_PARAMS( ZED( BadXMLDocument_2o ) )
- )
- );
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,
+ ERROR_PARAMS(ZED(BadXMLDocument_2o))));
abortload();
return NULL;
@@ -672,12 +698,10 @@
xmlDoc *doc = ctxt->myDoc;
if (doc == NULL)
{
- theXQueryDiagnostics->add_error(
- NEW_ZORBA_EXCEPTION(
- zerr::ZSTR0021_LOADER_PARSING_ERROR,
- ERROR_PARAMS( ZED( ParserNoCreateTree ) )
- )
- );
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,
+ ERROR_PARAMS(ZED(ParserNoCreateTree))));
+
abortload();
return NULL;
}
@@ -700,6 +724,7 @@
return resultNode;
}
+
void DtdXmlLoader::loadDocument(xmlDoc *doc)
{
startDocument(this);
@@ -712,6 +737,7 @@
endDocument(this);
}
+
void DtdXmlLoader::loadNode(xmlNode *a_node)
{
xmlNode *cur_node = NULL;
@@ -784,6 +810,8 @@
}
}
}
+
+
/*******************************************************************************
SAX2 callback when the start of document has been detected by the parser.
@@ -796,7 +824,7 @@
try
{
- XmlNode* docNode = GET_STORE().getNodeFactory().createDocumentNode();
+ DocumentNode* docNode = GET_STORE().getNodeFactory().createDocumentNode();
loader.setRoot(docNode);
loader.theNodeStack.push(docNode);
@@ -812,6 +840,8 @@
}
#endif
+ docNode->setBaseUri(loader.theBaseUri);
+ docNode->setDocUri(loader.theDocUri);
docNode->setId(loader.theTree, &loader.theOrdPath);
loader.theOrdPath.pushChild();
@@ -823,9 +853,8 @@
}
catch (...)
{
- loader.theXQueryDiagnostics->add_error(
- NEW_ZORBA_EXCEPTION( zerr::ZXQP0003_INTERNAL_ERROR )
- );
+ loader.theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZXQP0003_INTERNAL_ERROR));
}
}
=== modified file 'src/store/naive/loader_fast.cpp'
--- src/store/naive/loader_fast.cpp 2011-07-15 16:39:51 +0000
+++ src/store/naive/loader_fast.cpp 2011-11-04 19:40:32 +0000
@@ -216,11 +216,9 @@
if (stream.bad())
{
- theXQueryDiagnostics->add_error(
- NEW_ZORBA_EXCEPTION(
- zerr::ZSTR0020_LOADER_IO_ERROR, ERROR_PARAMS( ZED( BadStreamState ) )
- )
- );
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0020_LOADER_IO_ERROR,
+ ERROR_PARAMS(ZED(BadStreamState))));
}
return stream.gcount();
@@ -257,6 +255,8 @@
xmlSubstituteEntitiesDefault(1);
+ theBaseUri = baseUri;
+
if (docUri.empty())
{
std::ostringstream uristream;
@@ -271,28 +271,23 @@
thePathStack.push(PathStepInfo(NULL, baseUri));
- theTree->setDocUri(theDocUri);
- theTree->setBaseUri(baseUri);
-
try
{
std::streamsize numChars = readPacket(stream, theBuffer, INPUT_CHUNK_SIZE);
if (numChars < 0)
{
- theXQueryDiagnostics->add_error(
- NEW_ZORBA_EXCEPTION( zerr::ZSTR0020_LOADER_IO_ERROR )
- );
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0020_LOADER_IO_ERROR));
+
abortload();
return NULL;
}
else if (numChars == 0)
{
- theXQueryDiagnostics->add_error(
- NEW_ZORBA_EXCEPTION(
- zerr::ZSTR0020_LOADER_IO_ERROR, ERROR_PARAMS( ZED( NoInputData ) )
- )
- );
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0020_LOADER_IO_ERROR,
+ ERROR_PARAMS(ZED(NoInputData))));
abortload();
return NULL;
}
@@ -305,8 +300,9 @@
if (ctxt == NULL)
{
- theXQueryDiagnostics->add_error(
- NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,ERROR_PARAMS( ZED( ParserInitFailed ) )));
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,
+ ERROR_PARAMS(ZED(ParserInitFailed))));
abortload();
return NULL;
}
@@ -324,7 +320,9 @@
if (numChars < 0)
{
- theXQueryDiagnostics->add_error(NEW_ZORBA_EXCEPTION( zerr::ZSTR0020_LOADER_IO_ERROR ));
+ theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0020_LOADER_IO_ERROR));
+
abortload();
return NULL;
}
@@ -356,20 +354,14 @@
if (!theDocUri.empty())
{
theXQueryDiagnostics->add_error(
- NEW_ZORBA_EXCEPTION(
- zerr::ZSTR0021_LOADER_PARSING_ERROR,
- ERROR_PARAMS( ZED( BadXMLDocument_2o ), theDocUri )
- )
- );
+ NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,
+ ERROR_PARAMS(ZED(BadXMLDocument_2o), theDocUri)));
}
else
{
theXQueryDiagnostics->add_error(
- NEW_ZORBA_EXCEPTION(
- zerr::ZSTR0021_LOADER_PARSING_ERROR,
- ERROR_PARAMS( ZED( BadXMLDocument_2o ) )
- )
- );
+ NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR,
+ ERROR_PARAMS(ZED(BadXMLDocument_2o))));
}
abortload();
return NULL;
@@ -397,7 +389,7 @@
try
{
- XmlNode* docNode = GET_STORE().getNodeFactory().createDocumentNode();
+ DocumentNode* docNode = GET_STORE().getNodeFactory().createDocumentNode();
loader.setRoot(docNode);
loader.theNodeStack.push(docNode);
@@ -413,6 +405,8 @@
}
#endif
+ docNode->setBaseUri(loader.theBaseUri);
+ docNode->setDocUri(loader.theDocUri);
docNode->setId(loader.theTree, &loader.theOrdPath);
loader.theOrdPath.pushChild();
@@ -424,9 +418,8 @@
}
catch (...)
{
- loader.theXQueryDiagnostics->add_error(
- NEW_ZORBA_EXCEPTION( zerr::ZXQP0003_INTERNAL_ERROR )
- );
+ loader.theXQueryDiagnostics->
+ add_error(NEW_ZORBA_EXCEPTION(zerr::ZXQP0003_INTERNAL_ERROR));
}
}
=== modified file 'src/store/naive/node_factory.cpp'
--- src/store/naive/node_factory.cpp 2011-06-14 17:26:33 +0000
+++ src/store/naive/node_factory.cpp 2011-11-04 19:40:32 +0000
@@ -57,8 +57,8 @@
DocumentNode* NodeFactory::createDocumentNode(
XmlTree* tree,
- zstring& baseUri,
- zstring& docUri)
+ const zstring& baseUri,
+ const zstring& docUri)
{
return new DocumentNode(tree, baseUri, docUri);
}
=== modified file 'src/store/naive/node_factory.h'
--- src/store/naive/node_factory.h 2011-06-14 17:26:33 +0000
+++ src/store/naive/node_factory.h 2011-11-04 19:40:32 +0000
@@ -68,8 +68,8 @@
virtual DocumentNode* createDocumentNode(
XmlTree* tree,
- zstring& baseUri,
- zstring& docUri);
+ const zstring& baseUri,
+ const zstring& docUri);
virtual ElementNode* createElementNode(
store::Item_t& nodeName,
=== modified file 'src/store/naive/node_items.cpp'
--- src/store/naive/node_items.cpp 2011-10-10 12:56:57 +0000
+++ src/store/naive/node_items.cpp 2011-11-04 19:40:32 +0000
@@ -68,7 +68,9 @@
thePos(0),
theCollection(NULL),
theRootNode(NULL),
+#ifdef DATAGUIDE
theDataGuideRootNode(NULL),
+#endif
theIsValidated(false),
theIsRecursive(false)
#ifndef EMBEDED_TYPE
@@ -86,7 +88,9 @@
thePos(0),
theCollection(NULL),
theRootNode(root),
+#ifdef DATAGUIDE
theDataGuideRootNode(NULL),
+#endif
theIsValidated(false),
theIsRecursive(false)
#ifndef EMBEDED_TYPE
@@ -137,11 +141,13 @@
theRootNode = NULL;
}
+#ifdef DATAGUIDE
if (theDataGuideRootNode != NULL)
{
theDataGuideRootNode->deleteTree();
theDataGuideRootNode = NULL;
}
+#endif
#ifndef EMBEDED_TYPE
if (theTypesMap)
@@ -739,9 +745,6 @@
if (parent == NULL)
{
theOrdPath.setAsRoot();
-
- if (nodeKind != store::StoreConsts::documentNode)
- theOrdPath.appendComp(1);
}
else
{
@@ -1141,7 +1144,7 @@
Return the position of the given node among the children of "this". If the
given node is not a child of "this", return the number of children of "this".
********************************************************************************/
-csize InternalNode::findChild(XmlNode* child) const
+csize InternalNode::findChild(const XmlNode* child) const
{
const_iterator begin = childrenBegin();
const_iterator end = childrenEnd();
@@ -1331,16 +1334,13 @@
********************************************************************************/
DocumentNode::DocumentNode(
XmlTree* tree,
- zstring& baseUri,
- zstring& docUri)
+ const zstring& baseUri,
+ const zstring& docUri)
:
- InternalNode(tree, NULL, false, 0, store::StoreConsts::documentNode)
+ InternalNode(tree, NULL, false, 0, store::StoreConsts::documentNode),
+ theBaseUri(baseUri),
+ theDocUri(docUri)
{
- if (!baseUri.empty())
- tree->setBaseUri(baseUri);
-
- tree->setDocUri(docUri);
-
NODE_TRACE1("{\nConstructing doc node " << this << " tree = "
<< getTree()->getId() << ":" << getTree()
<< " doc uri = " << docUri);
@@ -1366,10 +1366,7 @@
{
tree = NodeFactory::instance().createXmlTree();
- zstring baseuri = getBaseUri();
- zstring docuri = getDocUri();
-
- copyNode = NodeFactory::instance().createDocumentNode(tree, baseuri, docuri);
+ copyNode = NodeFactory::instance().createDocumentNode(tree, theBaseUri, theDocUri);
const_iterator ite = childrenBegin();
const_iterator end = childrenEnd();
@@ -1403,7 +1400,7 @@
void DocumentNode::getBaseURIInternal(zstring& uri, bool& local) const
{
local = true;
- uri = getBaseUri();
+ uri = theBaseUri;
}
@@ -1507,8 +1504,8 @@
strStream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl
<< "<document";
- strStream << " baseUri = \"" << getBaseUri() << "\"";
- strStream << " docUri = \"" << getDocUri();
+ strStream << " baseUri = \"" << theBaseUri << "\"";
+ strStream << " docUri = \"" << theDocUri;
strStream << "\">" << std::endl;
store::Iterator_t iter = getChildren();
@@ -3604,6 +3601,78 @@
}
+#ifndef TEXT_ORDPATH
+/*******************************************************************************
+
+********************************************************************************/
+void TextNode::getOrdPath(OrdPath& ordPath) const
+{
+ InternalNode* parent = static_cast<InternalNode*>(getParent());
+
+ if (parent == NULL)
+ {
+ // The text node is the root
+ ordPath.setAsRoot();
+ return;
+ }
+
+ ZORBA_FATAL(parent->theOrdPath.isValid(),"Parent ordpath is invalid.");
+
+ csize pos = parent->findChild(this);
+ csize numChildren = parent->numChildren();
+ csize numAttrs = parent->numAttrs();
+
+ if (numChildren == 1 && numAttrs == 0)
+ {
+ // Parent has no other children and no attributes
+ ordPath = parent->theOrdPath;
+ ordPath.appendComp(1);
+ }
+ else
+ {
+ // Parent has either children or attributes
+
+ // The smallest Ordpath at the same level of the textNode which must
+ // be greater than the OrdPath of the textNode
+ const OrdPath* upperOrdPath = NULL;
+
+ // The biggest Ordpath at the same level of the textNode which must
+ // be smaller than the OrdPath of the textNode
+ const OrdPath* lowerOrdPath = NULL;
+
+ if (pos < numChildren-1)
+ {
+ //There could be an upperOrdPath
+ upperOrdPath = parent->getFirstChildOrdPathAfter(pos);
+ }
+
+ if (pos > 0)
+ {
+ //There could be a lowerOrdPath in the children
+ lowerOrdPath = parent->getFirstChildOrdPathBefore(pos-1);
+ }
+
+ if (lowerOrdPath == NULL && numAttrs > 0)
+ {
+ //There is a lowerOrdPath in the attributes
+ lowerOrdPath = &parent->getAttr(numAttrs-1)->theOrdPath;
+ }
+
+ if (upperOrdPath != NULL && lowerOrdPath != NULL)
+ OrdPath::insertInto(parent->theOrdPath, *lowerOrdPath, *upperOrdPath, ordPath);
+
+ else if (upperOrdPath == NULL && lowerOrdPath != NULL)
+ OrdPath::insertAfter(parent->theOrdPath, *lowerOrdPath, ordPath);
+
+ else if (upperOrdPath != NULL && lowerOrdPath == NULL)
+ OrdPath::insertBefore(parent->theOrdPath, *upperOrdPath, ordPath);
+
+ else
+ ZORBA_FATAL(0,"Adjacent text nodes.");
+ }
+}
+#endif
+
/*******************************************************************************
=== modified file 'src/store/naive/node_items.h'
--- src/store/naive/node_items.h 2011-10-10 12:56:57 +0000
+++ src/store/naive/node_items.h 2011-11-04 19:40:32 +0000
@@ -180,14 +180,13 @@
ulong theId;
ulong thePos;
- zstring theDocUri;
- zstring theBaseUri;
-
SimpleCollection * theCollection;
XmlNode * theRootNode;
+#ifdef DATAGUIDE
GuideNode * theDataGuideRootNode;
+#endif
bool theIsValidated;
bool theIsRecursive;
@@ -220,14 +219,6 @@
ulong getId() const { return theId; }
- const zstring& getDocUri() const { return theDocUri; }
-
- void setDocUri(const zstring& uri) { theDocUri = uri; }
-
- const zstring& getBaseUri() const { return theBaseUri; }
-
- void setBaseUri(const zstring& uri) { theBaseUri = uri; }
-
ulong getCollectionId() const;
const SimpleCollection* getCollection() const { return theCollection; }
@@ -250,9 +241,11 @@
bool isRecursive() const { return theIsRecursive; }
+#ifdef DATAGUIDE
GuideNode* getDataGuide() const { return theDataGuideRootNode; }
void setDataGuide(GuideNode* root) { theDataGuideRootNode = root; }
+#endif
#ifndef EMBEDED_TYPE
store::Item* getType(const XmlNode* n) const;
@@ -491,15 +484,9 @@
void setParent(InternalNode* p) { theParent = p; }
+#ifdef DATAGUIDE
GuideNode* getDataGuide() const { return getTree()->getDataGuide(); }
-
- const zstring& getBaseUri() const { return getTree()->getBaseUri(); }
-
- void setBaseUri(const zstring& uri) { getTree()->setBaseUri(uri); }
-
- const zstring& getDocUri() const { return getTree()->getDocUri(); }
-
- void setDocUri(const zstring& uri) { getTree()->setDocUri(uri); }
+#endif
virtual XmlNode* copyInternal(
InternalNode* rootParent,
@@ -660,6 +647,7 @@
friend class CommentNode;
friend class UpdPut;
friend class CollectionPul;
+ friend class SimpleStore;
public:
typedef std::vector<XmlNode*> NodeVector;
@@ -757,7 +745,7 @@
void finalizeNode();
protected:
- csize findChild(XmlNode* child) const;
+ csize findChild(const XmlNode* child) const;
void insertChild(XmlNode* child, csize pos);
@@ -793,10 +781,14 @@
friend class NodeFactory;
protected:
+ zstring theBaseUri;
+ zstring theDocUri;
+
+protected:
DocumentNode(
XmlTree* tree,
- zstring& baseUri,
- zstring& docUri);
+ const zstring& baseUri,
+ const zstring& docUri);
DocumentNode();
@@ -807,7 +799,7 @@
store::Item* getType() const;
- void getDocumentURI(zstring& uri) const { uri = getDocUri(); }
+ void getDocumentURI(zstring& uri) const { uri = theDocUri; }
store::Iterator_t getChildren() const;
@@ -838,6 +830,12 @@
const XmlNode* rootCopy,
const store::CopyMode& copyMode) const;
+ const zstring& getBaseUri() const { return theBaseUri; }
+
+ void setBaseUri(const zstring& uri) { theBaseUri = uri; }
+
+ void setDocUri(const zstring& uri) { theDocUri = uri; }
+
protected:
void getBaseURIInternal(zstring& uri, bool& local) const;
};
@@ -1255,6 +1253,10 @@
const XmlNode* rootCopy,
const store::CopyMode& copymode) const;
+#ifndef TEXT_ORDPATH
+ void getOrdPath(OrdPath& ordPath) const;
+#endif
+
bool isTyped() const;
void setTypedValue(store::Item_t& value);
=== modified file 'src/store/naive/ordpath.cpp'
--- src/store/naive/ordpath.cpp 2011-06-14 17:26:33 +0000
+++ src/store/naive/ordpath.cpp 2011-11-04 19:40:32 +0000
@@ -614,6 +614,76 @@
}
}
+/*******************************************************************************
+ Determine the position of the "other" ordpath relative to "this" ordpath.
+ The result is one of: PRECEDING_SIBLING, FOLLOWING_SIBLING, PARENT, CHILD or OTHER
+********************************************************************************/
+OrdPath::RelativePosition OrdPath::getRelativePosition2(const OrdPath& other) const
+{
+ int32_t dewey1[MAX_NUM_COMPS], dewey2[MAX_NUM_COMPS];
+ ulong offsets1[MAX_NUM_COMPS], offsets2[MAX_NUM_COMPS];
+ ulong numComps1 = 0, numComps2 = 0;
+ ulong bitLen1 = 0, bitLen2 = 0;
+ bool thisFirst;
+
+ decompress(0, dewey1, offsets1, numComps1, bitLen1);
+ other.decompress(0, dewey2, offsets2, numComps2, bitLen2);
+
+ // curr will be the first non-shared component
+ ulong curr = 0;
+
+ if (numComps1 < numComps2)
+ {
+ while (curr < numComps1 && dewey1[curr] == dewey2[curr])
+ ++curr;
+ }
+ else
+ {
+ while (curr < numComps2 && dewey1[curr] == dewey2[curr])
+ ++curr;
+
+ if (curr == numComps1 && numComps1 == numComps2)
+ return OTHER; //The two ordpaths are the same
+ }
+
+ if (curr < numComps1 && curr < numComps2 && dewey1[curr] < dewey2[curr])
+ thisFirst = true;
+ else
+ thisFirst = false;
+
+ ulong extraLevels1 = 0, extraLevels2 = 0;
+
+ for (ulong i = curr; i < numComps1; ++i)
+ {
+ if (dewey1[i] % 2 == 1)
+ ++extraLevels1;
+ }
+
+ for (ulong i = curr; i < numComps2; ++i)
+ {
+ if (dewey2[i] % 2 == 1)
+ ++extraLevels2;
+ }
+
+ // extraLevels1/2 == 0 means that we exhausted ordpath1/2, i.e. one ordpath
+ // is a prefix of the other ordpath.
+
+ if (extraLevels1 > 1 || extraLevels2 > 1)
+ return OTHER;
+
+ else if (extraLevels1 == 1 && extraLevels2 == 0)
+ return PARENT;
+
+ else if (extraLevels1 == 0 && extraLevels2 == 1)
+ return CHILD;
+
+ else if (extraLevels1 == 1 && extraLevels2 == 1)
+ return thisFirst ? FOLLOWING_SIBLING : PRECEDING_SIBLING;
+
+ ZORBA_FATAL(0,"");//The last component of an OrdPath is odd.
+ //Since the two labels were different at least one
+ //of the two must have a odd component left.
+}
/*******************************************************************************
Compress a dewey id into an ordpath.
@@ -1467,6 +1537,30 @@
/*******************************************************************************
+
+********************************************************************************/
+ulong OrdPath::getLevel() const
+{
+ int32_t dewey[MAX_NUM_COMPS];
+ ulong offsets[MAX_NUM_COMPS];
+ ulong numComps = 0;
+ ulong bitLen = 0;
+
+ decompress(0, dewey, offsets, numComps, bitLen);
+
+ ulong level = 0;
+
+ for (ulong i = 0; i < numComps; ++i)
+ {
+ if (dewey[i] % 2 == 1)
+ ++level;
+ }
+
+ return level;
+}
+
+
+/*******************************************************************************
Decompress all the components that appear after a given starting offset
within the ordpath data buffer (it is assumed that startOffset points to
the start of some component).
=== modified file 'src/store/naive/ordpath.h'
--- src/store/naive/ordpath.h 2011-06-14 17:26:33 +0000
+++ src/store/naive/ordpath.h 2011-11-04 19:40:32 +0000
@@ -34,9 +34,8 @@
/*******************************************************************************
-
+ only exported for unit testing
********************************************************************************/
-// only exported for unit testing
class ZORBA_DLL_PUBLIC OrdPath
{
friend class OrdPathStack;
@@ -48,11 +47,15 @@
ANCESTOR,
SELF,
DESCENDANT,
- FOLLOWING
+ FOLLOWING,
+ PRECEDING_SIBLING,
+ FOLLOWING_SIBLING,
+ PARENT,
+ CHILD,
+ OTHER
}
RelativePosition;
-
typedef std::vector<int32_t> DeweyID;
public:
@@ -182,6 +185,10 @@
RelativePosition getRelativePosition(const OrdPath& other) const;
+ RelativePosition getRelativePosition2(const OrdPath& other) const;
+
+ ulong getLevel() const;
+
void compress(const DeweyID& dewey);
void appendComp(int32_t value);
=== modified file 'src/store/naive/pul_primitives.cpp'
--- src/store/naive/pul_primitives.cpp 2011-10-13 19:44:33 +0000
+++ src/store/naive/pul_primitives.cpp 2011-11-04 19:40:32 +0000
@@ -795,6 +795,9 @@
{
SimpleStore* store = &GET_STORE();
+ zstring targetUri;
+ theTargetUri->getStringValue2(targetUri);
+
try
{
// Have to copy because addNode() will set the doc uri of target tree to
@@ -805,33 +808,32 @@
// a parent already.
store::CopyMode copymode;
copymode.set(true, true, true, true);
- theTarget = theTarget->copy(NULL, copymode);
if (theTarget->getNodeKind() != store::StoreConsts::documentNode)
{
- XmlNode* target = BASE_NODE(theTarget);
-
- DocumentNode* doc = GET_STORE().getNodeFactory().createDocumentNode();
- doc->setId(target->getTree(), NULL);
- doc->insertChild(target, 0);
- doc->getTree()->setRoot(doc);
-
- store::Item_t docItem(doc);
-
- theTarget = docItem;
- }
-
- store->addNode(theTargetUri->getStringValue(), theTarget);
+ store::Item_t docItem;
+ GET_FACTORY().createDocumentNode(docItem, targetUri, targetUri);
+
+ theTarget = theTarget->copy(docItem.getp(), copymode);
+
+ theTarget.transfer(docItem);
+ }
+ else
+ {
+ theTarget = theTarget->copy(NULL, copymode);
+ }
+
+ store->addNode(targetUri, theTarget);
}
catch(ZorbaException const& e)
{
if (e.diagnostic() == zerr::ZAPI0020_DOCUMENT_ALREADY_EXISTS)
{
- theOldDocument = store->getDocument(theTargetUri->getStringValue());
-
- store->deleteDocument(theTargetUri->getStringValue());
-
- store->addNode(theTargetUri->getStringValue(), theTarget);
+ theOldDocument = store->getDocument(targetUri);
+
+ store->deleteDocument(targetUri);
+
+ store->addNode(targetUri, theTarget);
}
else
{
@@ -1767,14 +1769,11 @@
if (!lMap)
{
- throw ZORBA_EXCEPTION(
- zerr::ZDDY0023_INDEX_DOES_NOT_EXIST,
- ERROR_PARAMS( theQName->getStringValue() )
- );
+ throw ZORBA_EXCEPTION(zerr::ZDDY0023_INDEX_DOES_NOT_EXIST,
+ ERROR_PARAMS(theQName->getStringValue()));
}
- simplestore::IndexImpl* lImpl =
- static_cast<simplestore::IndexImpl*>(lMap.getp());
+ ValueIndex* lImpl = static_cast<ValueIndex*>(lMap.getp());
theValue->open();
store::Item_t lValue;
@@ -1791,7 +1790,7 @@
}
store::IndexKey* lKeyPtr = lKey.get();
- if (!lImpl->insert(lKeyPtr, lValue, lKey->size() > 1))
+ if (!lImpl->insert(lKeyPtr, lValue))
{
// the index took the ownership over the key if the index
// did _not_ already contain an entry with the same key
=== modified file 'src/store/naive/shared_types.h'
--- src/store/naive/shared_types.h 2011-09-22 21:50:20 +0000
+++ src/store/naive/shared_types.h 2011-11-04 19:40:32 +0000
@@ -30,6 +30,9 @@
namespace simplestore
{
+class AtomicItem;
+typedef store::ItemHandle<AtomicItem> AtomicItem_t;
+
class CollectionSet;
class CollectionIterator;
typedef rchandle<CollectionIterator> CollectionIterator_t;
=== modified file 'src/store/naive/simple_index.cpp'
--- src/store/naive/simple_index.cpp 2011-09-30 14:06:33 +0000
+++ src/store/naive/simple_index.cpp 2011-11-04 19:40:32 +0000
@@ -17,12 +17,13 @@
#include "diagnostics/assert.h"
#include "zorbautils/hashfun.h"
-#include "zorbatypes/collation_manager.h"
+
+#include "diagnostics/util_macros.h"
#include "store/api/item.h"
#include "store/naive/store_defs.h"
#include "store/naive/simple_index.h"
-#include "store/naive/simple_index_general.h"
+//#include "store/naive/simple_index_general.h"
#include "store/naive/atomic_items.h"
#include "store/naive/simple_store.h"
@@ -35,114 +36,6 @@
{
-/////////////////////////////////////////////////////////////////////////////////
-// //
-// IndexCompareFunction //
-// //
-/////////////////////////////////////////////////////////////////////////////////
-
-
-/******************************************************************************
-
-********************************************************************************/
-uint32_t IndexCompareFunction::hash(const store::IndexKey* key) const
-{
- uint32_t hval = FNV_32_INIT;
-
- for (ulong i = 0; i < theNumColumns; ++i)
- {
- if ((*key)[i] == NULL)
- continue;
-
- hval = hashfun::h32<uint32_t>((*key)[i]->hash(theTimezone, theCollators[i]),
- hval);
- }
-
- return hval;
-}
-
-
-/******************************************************************************
-
-********************************************************************************/
-bool IndexCompareFunction::equal(
- const store::IndexKey* key1,
- const store::IndexKey* key2) const
-{
- for (ulong i = 0; i < theNumColumns; ++i)
- {
- const store::Item_t& i1 = (*key1)[i];
- const store::Item_t& i2 = (*key2)[i];
-
- if (i1 == NULL && i2 == NULL)
- continue;
-
- if (i1 == NULL || i2 == NULL)
- return false;
-
- if (! (*key1)[i]->equals((*key2)[i].getp(), theTimezone, theCollators[i]))
- return false;
- }
-
- return true;
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-long IndexCompareFunction::compare(
- const store::IndexKey* key1,
- const store::IndexKey* key2) const
-{
- long result;
-
-#ifndef WIN32
- ulong size = std::min(key1->size(), key2->size());
-#else
- ulong size = std::min(key1->size(), key2->size());
-#endif
-
- for (ulong i = 0; i < size; i++)
- {
- const store::Item_t& i1 = (*key1)[i];
- const store::Item_t& i2 = (*key2)[i];
-
- if (i1 == NULL)
- {
- if (i2 != NULL)
- return -1;
- }
- else if (i2 == NULL)
- {
- if (i1 != NULL)
- return +1;
- }
- else if (i1 == IndexBoxCondition::theNegInf)
- {
- return -1;
- }
- else if (i1 == IndexBoxCondition::thePosInf)
- {
- return +1;
- }
- else if (i2 == IndexBoxCondition::theNegInf)
- {
- return +1;
- }
- else if (i2 == IndexBoxCondition::thePosInf)
- {
- return -1;
- }
- else if ((result = i1->compare(i2, theTimezone, theCollators[i])))
- {
- return result;
- }
- }
-
- return 0;
-}
-
/////////////////////////////////////////////////////////////////////////////////
// //
@@ -161,19 +54,6 @@
theQname(qname),
theSpec(spec)
{
- theCollators.resize(theSpec.getNumColumns());
-
- for (ulong i = 0; i < theSpec.getNumColumns(); ++i)
- {
- if (!spec.theCollations[i].empty())
- {
- theCollators[i] = CollationFactory::createCollator(spec.theCollations[i]);
- }
- else
- {
- theCollators[i] = NULL;
- }
- }
}
@@ -182,11 +62,6 @@
********************************************************************************/
IndexImpl::~IndexImpl()
{
- for (size_t i = 0; i < theCollators.size(); ++i)
- {
- if (theCollators[i])
- delete theCollators[i];
- }
}
@@ -195,25 +70,317 @@
********************************************************************************/
store::IndexCondition_t IndexImpl::createCondition(store::IndexCondition::Kind k)
{
+ if (!isSorted() &&
+ (k == store::IndexCondition::BOX_VALUE ||
+ k == store::IndexCondition::BOX_GENERAL))
+ {
+ RAISE_ERROR_NO_LOC(zerr::ZSTR0007_INDEX_UNSUPPORTED_PROBE_CONDITION,
+ ERROR_PARAMS(IndexConditionImpl::getKindString(k), getName()->getStringValue()));
+ }
+
+ if (isGeneral())
+ {
+ return new GeneralIndexCondition(this, k);
+ }
+ else if (k == store::IndexCondition::POINT_VALUE)
+ {
+ return new IndexPointCondition(this, k);
+ }
+ else if (k == store::IndexCondition::BOX_VALUE)
+ {
+ return new IndexBoxValueCondition(this, k);
+ }
+ else
+ {
+ RAISE_ERROR_NO_LOC(zerr::ZSTR0007_INDEX_UNSUPPORTED_PROBE_CONDITION,
+ ERROR_PARAMS(IndexConditionImpl::getKindString(k), getName()->getStringValue()));
+
+ ZORBA_ASSERT(false);
+ }
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////
+// //
+// IndexConditionImpl //
+// //
+/////////////////////////////////////////////////////////////////////////////////
+
+
+/*******************************************************************************
+ TODO: proper initialization order is not guaranteed => use factory instead
+********************************************************************************/
+store::Item_t IndexConditionImpl::theNegInf(new DecimalItem);
+store::Item_t IndexConditionImpl::thePosInf(new DecimalItem);
+
+
+/*******************************************************************************
+ Static method
+********************************************************************************/
+std::string IndexConditionImpl::getKindString(store::IndexCondition::Kind k)
+{
switch (k)
{
- case store::IndexCondition::POINT_VALUE:
- return new IndexPointValueCondition(this);
-
- case store::IndexCondition::POINT_GENERAL:
- return new IndexPointGeneralCondition(this);
-
- case store::IndexCondition::BOX_VALUE:
- return new IndexBoxValueCondition(this);
-
- case store::IndexCondition::BOX_GENERAL:
- return new IndexBoxGeneralCondition(this);
-
- default:
- ZORBA_ASSERT(false);
- }
-}
-
+ case POINT_VALUE:
+ return "POINT_VALUE";
+ case POINT_GENERAL:
+ return "POINT_GENERAL";
+ case BOX_VALUE:
+ return "BOX_VALUE";
+ case BOX_GENERAL:
+ return "BOX_GENERAL";
+ }
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+IndexConditionImpl::IndexConditionImpl(
+ IndexImpl* idx,
+ store::IndexCondition::Kind kind)
+ :
+ theIndex(idx),
+ theKind(kind)
+{
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+void IndexConditionImpl::pushItem(store::Item_t& item)
+{
+ ZORBA_ASSERT(false);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+void IndexConditionImpl::pushRange(
+ store::Item_t& lower,
+ store::Item_t& upper,
+ bool haveLower,
+ bool haveUpper,
+ bool lowerIncl,
+ bool upperIncl)
+{
+ ZORBA_ASSERT(false);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+void IndexConditionImpl::pushBound(
+ store::Item_t& bound,
+ bool isLower,
+ bool boundIncl)
+{
+ ZORBA_ASSERT(false);
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////
+// //
+// GeneralIndexCondition //
+// //
+/////////////////////////////////////////////////////////////////////////////////
+
+
+/*******************************************************************************
+
+********************************************************************************/
+GeneralIndexCondition::GeneralIndexCondition(
+ IndexImpl* idx,
+ store::IndexCondition::Kind kind)
+ :
+ IndexConditionImpl(idx, kind),
+ theIsSet(false)
+{
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+std::string GeneralIndexCondition::toString() const
+{
+ std::ostringstream str;
+ str << *this;
+ return str.str();
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+std::ostream& operator<<(std::ostream& os, const GeneralIndexCondition& cond)
+{
+ os << "{ " << cond.getKindString() << " : ";
+
+ if (!cond.theIsSet)
+ {
+ os << "not set" << std::endl;
+ return os;
+ }
+
+ if (cond.theKind == store::IndexCondition::BOX_VALUE ||
+ cond.theKind == store::IndexCondition::BOX_GENERAL)
+ {
+ if (!cond.theRangeFlags.theHaveLowerBound)
+ {
+ os << "[-INF";
+ }
+ else
+ {
+ if (cond.theRangeFlags.theLowerBoundIncl)
+ os << "[" << cond.theLowerBound->getStringValue();
+ else
+ os << "(" << cond.theLowerBound->getStringValue();
+ }
+
+ os << ", ";
+
+
+ if (!cond.theRangeFlags.theHaveUpperBound)
+ {
+ os << "+INF] ";
+ }
+ else
+ {
+ if (cond.theRangeFlags.theUpperBoundIncl)
+ os << cond.theUpperBound->getStringValue() << "] ";
+ else
+ os << cond.theUpperBound->getStringValue() << ") ";
+ }
+ }
+ else
+ {
+ os << "[" << cond.theKey->getStringValue() << "]";
+ }
+
+ os << std::endl;
+ return os;
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+void GeneralIndexCondition::clear()
+{
+ theIsSet = false;
+ theKey = NULL;
+ theLowerBound = NULL;
+ theUpperBound = NULL;
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+void GeneralIndexCondition::pushItem(store::Item_t& item)
+{
+ assert(theKind == POINT_VALUE || theKind == POINT_GENERAL);
+ assert(!theIsSet);
+ assert(item && item->isAtomic());
+
+ theKey.transfer(item);
+
+ store::Item* baseItem = theKey->getBaseItem();
+ if (baseItem != NULL)
+ theKey = baseItem;
+
+ theIsSet = true;
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+void GeneralIndexCondition::pushRange(
+ store::Item_t& lower,
+ store::Item_t& upper,
+ bool haveLower,
+ bool haveUpper,
+ bool lowerIncl,
+ bool upperIncl)
+{
+ assert(theKind == BOX_VALUE);
+ assert(!theIsSet);
+ assert(!haveLower || (lower && lower->isAtomic()));
+ assert(!haveUpper || (upper && upper->isAtomic()));
+
+ theRangeFlags.theHaveLowerBound = haveLower;
+ theRangeFlags.theHaveUpperBound = haveUpper;
+ theRangeFlags.theLowerBoundIncl = lowerIncl;
+ theRangeFlags.theUpperBoundIncl = upperIncl;
+
+ if (haveLower)
+ {
+ theLowerBound.transfer(lower);
+
+ store::Item* baseItem = theLowerBound->getBaseItem();
+ if (baseItem != NULL)
+ theLowerBound = baseItem;
+ }
+
+ if (haveUpper)
+ {
+ theUpperBound.transfer(upper);
+
+ store::Item* baseItem = theUpperBound->getBaseItem();
+ if (baseItem != NULL)
+ theUpperBound = baseItem;
+ }
+
+ theIsSet = true;
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+void GeneralIndexCondition::pushBound(
+ store::Item_t& bound,
+ bool isLower,
+ bool boundIncl)
+{
+ assert(theKind == BOX_GENERAL);
+ assert(!theIsSet);
+
+ assert(bound != NULL);
+
+ if (isLower)
+ {
+ theRangeFlags.theHaveLowerBound = true;
+ theRangeFlags.theHaveUpperBound = false;
+
+ theLowerBound.transfer(bound);
+
+ store::Item* baseItem = theLowerBound->getBaseItem();
+ if (baseItem != NULL)
+ theLowerBound = baseItem;
+ }
+ else
+ {
+ theRangeFlags.theHaveLowerBound = false;
+ theRangeFlags.theHaveUpperBound = true;
+
+ theUpperBound.transfer(bound);
+
+ store::Item* baseItem = theUpperBound->getBaseItem();
+ if (baseItem != NULL)
+ theUpperBound = baseItem;
+ }
+
+ theRangeFlags.theLowerBoundIncl = boundIncl;
+ theRangeFlags.theUpperBoundIncl = boundIncl;
+
+ theIsSet = true;
+}
/////////////////////////////////////////////////////////////////////////////////
@@ -244,33 +411,6 @@
/*******************************************************************************
********************************************************************************/
-void IndexPointCondition::pushRange(
- store::Item_t& lower,
- store::Item_t& upper,
- bool haveLower,
- bool haveUpper,
- bool lowerIncl,
- bool upperIncl)
-{
- ZORBA_ASSERT(false);
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-void IndexPointCondition::pushBound(
- store::Item_t& bound,
- bool isLower,
- bool boundIncl)
-{
- ZORBA_ASSERT(false);
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
bool IndexPointCondition::test(const store::IndexKey& key) const
{
ulong numCols = theKey.size();
@@ -312,51 +452,6 @@
/////////////////////////////////////////////////////////////////////////////////
// //
-// IndexBoxCondition //
-// //
-/////////////////////////////////////////////////////////////////////////////////
-
-
-// TODO: proper initialization order is not guaranteed => use factory instead
-store::Item_t IndexBoxCondition::theNegInf(new DecimalItem);
-store::Item_t IndexBoxCondition::thePosInf(new DecimalItem);
-
-
-/*******************************************************************************
-
-********************************************************************************/
-void IndexBoxCondition::pushItem(store::Item_t& item)
-{
- ZORBA_ASSERT(false);
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-void IndexBoxCondition::pushRange(
- store::Item_t& lower,
- store::Item_t& upper,
- bool haveLower,
- bool haveUpper,
- bool lowerIncl,
- bool upperIncl)
-{
- ZORBA_ASSERT(false);
-}
-
-
-void IndexBoxCondition::pushBound(
- store::Item_t& bound,
- bool isLower,
- bool boundIncl)
-{
- ZORBA_ASSERT(false);
-}
-
-
-/////////////////////////////////////////////////////////////////////////////////
-// //
// IndexBoxValueCondition //
// //
/////////////////////////////////////////////////////////////////////////////////
@@ -490,91 +585,6 @@
}
-
-/////////////////////////////////////////////////////////////////////////////////
-// //
-// IndexBoxGeneralCondition //
-// //
-/////////////////////////////////////////////////////////////////////////////////
-
-
-/*******************************************************************************
-
-********************************************************************************/
-IndexBoxGeneralCondition::IndexBoxGeneralCondition(IndexImpl* idx)
- :
- IndexBoxCondition(idx)
-{
- theRangeFlags.theHaveLowerBound = false;
- theRangeFlags.theHaveUpperBound = false;
- theRangeFlags.theLowerBoundIncl = true;
- theRangeFlags.theUpperBoundIncl = true;
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-void IndexBoxGeneralCondition::clear()
-{
- theBound.clear();
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-void IndexBoxGeneralCondition::pushBound(
- store::Item_t& bound,
- bool isLower,
- bool boundIncl)
-{
- theRangeFlags.theHaveLowerBound = isLower;
- theRangeFlags.theHaveUpperBound = !isLower;
- theRangeFlags.theLowerBoundIncl = boundIncl;
- theRangeFlags.theUpperBoundIncl = boundIncl;
-
- assert(bound != NULL);
-
- theBound.transfer_back(bound);
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-bool IndexBoxGeneralCondition::test(const store::IndexKey& key) const
-{
- ZORBA_ASSERT(false);
- return true;
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-std::ostream& operator<<(std::ostream& os, const IndexBoxGeneralCondition& cond)
-{
- os << "{ ";
-
- os << "}";
-
- return os;
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-std::string IndexBoxGeneralCondition::toString() const
-{
- std::ostringstream str;
- str << *this;
- return str.str();
-}
-
-
-
}
}
=== modified file 'src/store/naive/simple_index.h'
--- src/store/naive/simple_index.h 2011-10-07 21:23:03 +0000
+++ src/store/naive/simple_index.h 2011-11-04 19:40:32 +0000
@@ -20,6 +20,8 @@
#include "store/api/index.h"
#include "store/api/iterator.h"
+#include "store/naive/shared_types.h"
+
#include "zorbautils/hashmap.h"
namespace zorba
@@ -35,51 +37,11 @@
/******************************************************************************
********************************************************************************/
-class IndexCompareFunction
-{
- friend class HashIndex;
-
-private:
- ulong theNumColumns;
- long theTimezone;
- const std::vector<XQPCollator*>& theCollators;
-
-public:
- IndexCompareFunction(
- ulong numCols,
- long timezone,
- const std::vector<XQPCollator*>& collators)
- :
- theNumColumns(numCols),
- theTimezone(timezone),
- theCollators(collators)
- {
- }
-
- uint32_t hash(const store::IndexKey* key) const;
-
- bool equal(const store::IndexKey* key1, const store::IndexKey* key2) const;
-
- long compare(const store::IndexKey* key1, const store::IndexKey* key2) const;
-
- bool operator()(const store::IndexKey* key1, const store::IndexKey* key2) const
- {
- return compare(key1, key2) < 0;
- }
-};
-
-
-/******************************************************************************
-
-********************************************************************************/
class IndexImpl : public store::Index
{
protected:
store::Item_t theQname;
store::IndexSpecification theSpec;
- std::vector<XQPCollator*> theCollators;
-
- std::vector<store::Item_t> theSources;
public:
IndexImpl(const store::Item_t& qname, const store::IndexSpecification& spec);
@@ -101,20 +63,18 @@
long getTimezone() const { return theSpec.theTimezone; }
- const XQPCollator* getCollator(ulong i) const { return theCollators[i]; }
-
- store::IndexCondition_t createCondition(store::IndexCondition::Kind k);
+ const std::vector<std::string>& getCollations() const { return theSpec.theCollations; }
virtual ulong size() const = 0;
virtual KeyIterator_t keys() const = 0;
+ store::IndexCondition_t createCondition(store::IndexCondition::Kind k);
+
//
// Simplestore methods
//
- const std::vector<XQPCollator*>& getCollators() const { return theCollators; }
-
bool isUnique() const { return theSpec.theIsUnique; }
bool isSorted() const { return theSpec.theIsSorted; }
@@ -124,136 +84,186 @@
bool isThreadSafe() const { return theSpec.theIsThreadSafe; }
bool isGeneral() const { return theSpec.theIsGeneral; }
-
- virtual bool insert(
- store::IndexKey*& key,
- store::Item_t& item,
- bool multikey = false) = 0;
-
- virtual bool remove(
- const store::IndexKey* key,
- store::Item_t& item,
- bool all = false) = 0;
};
/*******************************************************************************
********************************************************************************/
-class IndexPointCondition : public store::IndexCondition
+class IndexConditionImpl : public store::IndexCondition
{
friend class ProbeValueTreeIndexIterator;
friend class ProbeValueHashIndexIterator;
+ friend class ProbeGeneralIndexIterator;
friend class ProbeGeneralHashIndexIterator;
friend class ProbeGeneralTreeIndexIterator;
protected:
- rchandle<IndexImpl> theIndex;
- store::IndexKey theKey;
- ulong theNumColumns;
-
-public:
- IndexPointCondition(IndexImpl* idx)
- :
- theIndex(idx),
- theNumColumns(idx->getNumColumns())
- {
- }
-
- const store::IndexKey& getKey() const { return theKey; }
-
- void clear();
-
- void pushItem(store::Item_t& item);
-
- void pushRange(
- store::Item_t& lower,
- store::Item_t& upper,
- bool haveLower,
- bool haveUpper,
- bool lowerIncl,
- bool upperIncl);
-
- void pushBound(store::Item_t& bound, bool isLower, bool boundIncl);
-
- bool test(const store::IndexKey& key) const;
-
- std::string toString() const;
-};
-
-
-std::ostream& operator<<(std::ostream& os, const IndexPointCondition& cond);
-
-
-/*******************************************************************************
-
-********************************************************************************/
-class IndexPointValueCondition : public IndexPointCondition
-{
-public:
- IndexPointValueCondition(IndexImpl* idx) : IndexPointCondition(idx) { }
-
- store::IndexCondition::Kind getKind() const { return POINT_VALUE; }
-
- std::string getKindString() const { return "POINT_VALUE"; }
-};
-
-
-/*******************************************************************************
-
-********************************************************************************/
-class IndexPointGeneralCondition : public IndexPointCondition
-{
-public:
- IndexPointGeneralCondition(IndexImpl* idx) : IndexPointCondition(idx) { }
-
- store::IndexCondition::Kind getKind() const { return POINT_GENERAL; }
-
- std::string getKindString() const { return "POINT_GENERAL"; }
-};
-
-
-/*******************************************************************************
-
-********************************************************************************/
-class IndexBoxCondition : public store::IndexCondition
-{
- friend class ValueTreeIndex;
- friend class ProbeValueTreeIndexIterator;
-
-public:
- static store::Item_t theNegInf;
- static store::Item_t thePosInf;
-
-protected:
struct RangeFlags
{
bool theHaveLowerBound;
bool theHaveUpperBound;
bool theLowerBoundIncl;
bool theUpperBoundIncl;
+
+ RangeFlags()
+ :
+ theHaveLowerBound(false),
+ theHaveUpperBound(false),
+ theLowerBoundIncl(true),
+ theUpperBoundIncl(true)
+ {
+ }
};
- rchandle<IndexImpl> theIndex;
-
-public:
- IndexBoxCondition(IndexImpl* idx) : theIndex(idx) { }
-
- void pushItem(store::Item_t& item);
+public:
+ static store::Item_t theNegInf;
+ static store::Item_t thePosInf;
+
+protected:
+ rchandle<IndexImpl> theIndex;
+
+ store::IndexCondition::Kind theKind;
+
+public:
+ static std::string getKindString(store::IndexCondition::Kind k);
+
+public:
+ IndexConditionImpl(IndexImpl* idx, store::IndexCondition::Kind kind);
+
+ store::IndexCondition::Kind getKind() const { return theKind; }
+
+ std::string getKindString() const { return getKindString(theKind); }
+
+ virtual void pushItem(store::Item_t& item);
virtual void pushRange(
- store::Item_t& lower,
- store::Item_t& upper,
- bool haveLower,
- bool haveUpper,
- bool lowerIncl,
- bool upperIncl);
-
+ store::Item_t& lower,
+ store::Item_t& upper,
+ bool haveLower,
+ bool haveUpper,
+ bool lowerIncl,
+ bool upperIncl);
+
virtual void pushBound(store::Item_t& bound, bool isLower, bool boundIncl);
};
/*******************************************************************************
+ Repesents a search condition on a general index.
+
+ theKind:
+ --------
+ The kind of the condition (one of POINT_VALUE, POINT_GENERAL, BOX_VALUE, or
+ BOX_GENERAL).
+
+ theIsSet:
+ ---------
+ Set to true the 1st time one of the pushXXX methods is called and reset to
+ false by the clear() method. Used to check that the user is not trying to
+ push more than once.
+
+ theKey:
+ ------------
+ The search key for the POINT conditions. It is non-NULL and points to an
+ atomic item.
+
+ theRangeFlags:
+ --------------
+ Use only for the BOX conditions. Specifies the kind of operator and whether
+ the lower/upper bound is INFINITY or not.
+
+ theLowerBound:
+ --------------
+ The search key that serves as the lower bound for the BOX conditions. If,
+ according to theRangeFlags, the bound is not -INFINITY, theLowerBound is
+ not NULL and points to an atomicitem; otherwise, the value of theLowerBound
+ is irrelevant (is not used).
+
+ theUpperBound:
+ --------------
+ The search key that serves as the upper bound for the BOX conditions. If,
+ according to theRangeFlags, the bound is not +INFINITY, theUpperBound is
+ not NULL and points to an atomic item; otherwise, the value of theUpperBound
+ is irrelevant (is not used).
+********************************************************************************/
+class GeneralIndexCondition : public IndexConditionImpl
+{
+ friend class ProbeGeneralIndexIterator;
+ friend class ProbeGeneralHashIndexIterator;
+ friend class ProbeGeneralTreeIndexIterator;
+
+ friend std::ostream& operator<<(std::ostream& os, const GeneralIndexCondition& c);
+
+protected:
+ bool theIsSet;
+
+ AtomicItem_t theKey;
+
+ RangeFlags theRangeFlags;
+ AtomicItem_t theLowerBound;
+ AtomicItem_t theUpperBound;
+
+public:
+ GeneralIndexCondition(IndexImpl* idx, store::IndexCondition::Kind);
+
+ std::string toString() const;
+
+ void clear();
+
+ void pushItem(store::Item_t& item);
+
+ void pushRange(
+ store::Item_t& lower,
+ store::Item_t& upper,
+ bool haveLower,
+ bool haveUpper,
+ bool lowerIncl,
+ bool upperIncl);
+
+ void pushBound(store::Item_t& bound, bool isLower, bool boundIncl);
+};
+
+
+std::ostream& operator<<(std::ostream& os, const GeneralIndexCondition& cond);
+
+
+/*******************************************************************************
+
+********************************************************************************/
+class IndexPointCondition : public IndexConditionImpl
+{
+ friend class ProbeValueTreeIndexIterator;
+ friend class ProbeValueHashIndexIterator;
+ friend class ProbeGeneralHashIndexIterator;
+ friend class ProbeGeneralTreeIndexIterator;
+
+protected:
+ store::IndexKey theKey;
+
+public:
+ IndexPointCondition(IndexImpl* idx, store::IndexCondition::Kind kind)
+ :
+ IndexConditionImpl(idx, kind)
+ {
+ }
+
+ const store::IndexKey& getKey() const { return theKey; }
+
+ void clear();
+
+ void pushItem(store::Item_t& item);
+
+ bool test(const store::IndexKey& key) const;
+
+ std::string toString() const;
+};
+
+
+std::ostream& operator<<(std::ostream& os, const IndexPointCondition& cond);
+
+
+/*******************************************************************************
It represents a condition that is satisfied by the index keys inside a
user-specified "box".
@@ -266,7 +276,7 @@
The lower bound may be -INFINITY and the upper bound may be +INFINTY.
********************************************************************************/
-class IndexBoxValueCondition : public IndexBoxCondition
+class IndexBoxValueCondition : public IndexConditionImpl
{
friend class ValueTreeIndex;
friend class ProbeValueTreeIndexIterator;
@@ -280,11 +290,11 @@
store::IndexKey theUpperBounds;
public:
- IndexBoxValueCondition(IndexImpl* idx) : IndexBoxCondition(idx) { }
-
- store::IndexCondition::Kind getKind() const { return BOX_VALUE; }
-
- std::string getKindString() const { return "BOX_VALUE"; }
+ IndexBoxValueCondition(IndexImpl* idx, store::IndexCondition::Kind kind)
+ :
+ IndexConditionImpl(idx, kind)
+ {
+ }
ulong numRanges() const { return theLowerBounds.size(); }
@@ -307,57 +317,6 @@
std::ostream& operator<<(std::ostream& os, const IndexBoxValueCondition& cond);
-/*******************************************************************************
- It represents the following condition:
-
- bound op? K, where
-
- (a) op? is one of <, <=, >, or >=,
- (b) K is a key value, and
- (c) bound is either an atomic item or -INFINITY or +INFINITY.
-
- theRangeFlags:
- --------------
- Specify the kind of operator and whether the bound is INFINITY or not
-
- theBound:
- ---------
- The search key that serves as either a lower bound or an upper bound. If,
- according to theRangeFlags, the bound is not INFINITY, theBound contains
- exactly one non-NULL atomic item; otherwise, it is empty.
-********************************************************************************/
-class IndexBoxGeneralCondition : public IndexBoxCondition
-{
- friend class GeneralTreeIndex;
- friend class ProbeGeneralTreeIndexIterator;
-
- friend std::ostream& operator<<(std::ostream& os, const IndexBoxGeneralCondition& c);
-
-protected:
- RangeFlags theRangeFlags;
- store::IndexKey theBound;
-
-public:
- IndexBoxGeneralCondition(IndexImpl* idx);
-
- store::IndexCondition::Kind getKind() const { return BOX_GENERAL; }
-
- std::string getKindString() const { return "BOX_GENERAL"; }
-
- void clear();
-
- void pushBound(store::Item_t& bound, bool isLower, bool boundIncl);
-
- bool test(const store::IndexKey& key) const;
-
- std::string toString() const;
-};
-
-
-std::ostream& operator<<(std::ostream& os, const IndexBoxGeneralCondition& cond);
-
-
-
}
}
=== modified file 'src/store/naive/simple_index_general.cpp'
--- src/store/naive/simple_index_general.cpp 2011-10-04 05:28:07 +0000
+++ src/store/naive/simple_index_general.cpp 2011-11-04 19:40:32 +0000
@@ -31,24 +31,156 @@
namespace simplestore
{
-const int64_t GeneralTreeIndex::theMaxLong = 99999999999LL;
-const int64_t GeneralTreeIndex::theMinLong = -99999999999LL;
-const double GeneralTreeIndex::theDoubleMaxLong = 99999999999.0;
-const double GeneralTreeIndex::theDoubleMinLong = -99999999999.0;
+/////////////////////////////////////////////////////////////////////////////////
+// //
+// GeneralIndexCompareFunction //
+// //
+/////////////////////////////////////////////////////////////////////////////////
+
+
+/******************************************************************************
+
+********************************************************************************/
+GeneralIndexCompareFunction::GeneralIndexCompareFunction(
+ long timezone,
+ const std::string& collation)
+ :
+ theTimezone(timezone)
+{
+ if (!collation.empty())
+ {
+ theCollator = CollationFactory::createCollator(collation);
+ }
+ else
+ {
+ theCollator = NULL;
+ }
+}
+
+
+/******************************************************************************
+
+********************************************************************************/
+GeneralIndexCompareFunction::~GeneralIndexCompareFunction()
+{
+ if (theCollator)
+ delete theCollator;
+}
+
+
+/******************************************************************************
+
+********************************************************************************/
+uint32_t GeneralIndexCompareFunction::hash(const store::Item_t& key) const
+{
+ uint32_t hval = FNV_32_INIT;
+
+ if (key == NULL)
+ return hval;
+
+ return hashfun::h32<uint32_t>(key->hash(theTimezone, theCollator), hval);
+}
+
+
+/******************************************************************************
+
+********************************************************************************/
+bool GeneralIndexCompareFunction::equal(
+ const store::Item_t& key1,
+ const store::Item_t& key2) const
+{
+ if (key1 == NULL && key2 == NULL)
+ return true;
+
+ if (key1 == NULL || key2 == NULL)
+ return false;
+
+ if (! key1->equals(key2.getp(), theTimezone, theCollator))
+ return false;
+
+ return true;
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+long GeneralIndexCompareFunction::compare(
+ const store::Item_t& key1,
+ const store::Item_t& key2) const
+{
+ long result;
+
+ if (key1 == NULL)
+ {
+ if (key2 != NULL)
+ return -1;
+ }
+ else if (key2 == NULL)
+ {
+ if (key1 != NULL)
+ return +1;
+ }
+ else if (key1 == IndexConditionImpl::theNegInf)
+ {
+ return -1;
+ }
+ else if (key1 == IndexConditionImpl::thePosInf)
+ {
+ return +1;
+ }
+ else if (key2 == IndexConditionImpl::theNegInf)
+ {
+ return +1;
+ }
+ else if (key2 == IndexConditionImpl::thePosInf)
+ {
+ return -1;
+ }
+ else if ((result = key1->compare(key2, theTimezone, theCollator)))
+ {
+ return result;
+ }
+
+ return 0;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////
+// //
+// GeneralIndexValue //
+// //
+/////////////////////////////////////////////////////////////////////////////////
+
/******************************************************************************
*******************************************************************************/
-void GeneralIndexValue::addNode(store::Item_t& node, bool multikey, bool untyped)
+void GeneralIndexValue::addNode(store::Item_t& node, bool untyped)
{
- size_t numNodes = theNodes.size();
+ csize numNodes = theNodes.size();
theNodes.resize(numNodes + 1);
theNodes[numNodes].theNode.transfer(node);
- //theNodes[numNodes].theMultiKey = multikey;
theNodes[numNodes].theUntyped = untyped;
}
+/////////////////////////////////////////////////////////////////////////////////
+// //
+// GeneralIndex //
+// //
+/////////////////////////////////////////////////////////////////////////////////
+
+
+/******************************************************************************
+
+*******************************************************************************/
+const int64_t GeneralIndex::theMaxLong = 99999999999LL;
+const int64_t GeneralIndex::theMinLong = -99999999999LL;
+const double GeneralIndex::theDoubleMaxLong = 99999999999.0;
+const double GeneralIndex::theDoubleMinLong = -99999999999.0;
+
+
/******************************************************************************
*******************************************************************************/
@@ -57,147 +189,63 @@
const store::IndexSpecification& spec)
:
IndexImpl(qname, spec),
- theCompFunction(getNumColumns(), spec.theTimezone, theCollators),
+ theKeyTypeCode(XS_LAST),
+ theCompFunction(spec.theTimezone, spec.theCollations[0]),
theUntypedFlag(false),
theMultiKeyFlag(false)
{
-}
-
-
-/******************************************************************************
- Macro used during the population of both hash and tree general indexes.
-*******************************************************************************/
-#define ADD_IN_MAP(MAP_ID, untyped) \
-if (castItem != NULL) \
-{ \
- if (key == NULL) key = new store::IndexKey(1); \
- (*key)[0].transfer(castItem); \
- found = found || insertInMap(key, node, theMaps[MAP_ID], multikey, untyped); \
- node = node2; \
-}
-
-
-/////////////////////////////////////////////////////////////////////////////////
-// //
-// Hash Map General Index //
-// //
-/////////////////////////////////////////////////////////////////////////////////
-
-
-/******************************************************************************
-
-*******************************************************************************/
-GeneralHashIndex::KeyIterator::~KeyIterator()
-{
-}
-
-
-void GeneralHashIndex::KeyIterator::open()
-{
- assert(false);
-}
-
-
-bool GeneralHashIndex::KeyIterator::next(store::IndexKey&)
-{
- assert(false);
- return false;
-}
-
-
-void GeneralHashIndex::KeyIterator::close()
-{
- assert(false);
-}
-
-
-/******************************************************************************
-
-*******************************************************************************/
-GeneralHashIndex::GeneralHashIndex(
- const store::Item_t& qname,
- const store::IndexSpecification& spec)
- :
- GeneralIndex(qname, spec),
- theSingleMap(NULL)
-{
- assert(getNumColumns() == 1);
-
- memset(reinterpret_cast<void*>(theMaps), 0, XS_LAST * sizeof(IndexMap*));
-
store::Item* typeName = spec.theKeyTypes[0].getp();
if (typeName != NULL &&
typeName != GET_STORE().theSchemaTypeNames[XS_UNTYPED_ATOMIC] &&
typeName != GET_STORE().theSchemaTypeNames[XS_ANY_ATOMIC])
{
- theSingleMap = new IndexMap(theCompFunction, 1024, spec.theIsThreadSafe);
-
- theMaps[GET_STORE().theSchemaTypeCodes[spec.theKeyTypes[0].getp()]] = theSingleMap;
- }
-}
-
-
-/******************************************************************************
-
-*******************************************************************************/
-GeneralHashIndex::~GeneralHashIndex()
-{
- for (ulong i = 0; i < XS_LAST; ++i)
- {
- if (theMaps[i] == NULL)
- continue;
-
- IndexMap::iterator ite = theMaps[i]->begin();
- IndexMap::iterator end = theMaps[i]->end();
-
- for (; ite != end; ++ite)
- {
- //std::cout << "Index Entry Delete [" << (*ite).first << ","
- // << (*ite).second << "]" << std::endl;
-
- delete (*ite).first;
- delete (*ite).second;
- }
-
- delete theMaps[i];
- }
-}
-
-
-/******************************************************************************
-
-*******************************************************************************/
-ulong GeneralHashIndex::size() const
-{
- assert(false);
- return 0;
-}
-
-
-/******************************************************************************
-
-*******************************************************************************/
-store::Index::KeyIterator_t GeneralHashIndex::keys() const
-{
- assert(false);
- return 0;
-}
-
-
-/******************************************************************************
-
-*******************************************************************************/
-bool GeneralHashIndex::insert(
- store::IndexKey*& key,
- store::Item_t& node,
- bool multikey)
-{
+ theKeyTypeCode = GET_STORE().theSchemaTypeCodes[spec.theKeyTypes[0].getp()];
+ }
+}
+
+
+/******************************************************************************
+
+*******************************************************************************/
+GeneralIndex::~GeneralIndex()
+{
+}
+
+
+/******************************************************************************
+
+*******************************************************************************/
+const XQPCollator* GeneralIndex::getCollator(ulong i) const
+{
+ ZORBA_ASSERT(i == 0);
+ return theCompFunction.getCollator();
+}
+
+
+/******************************************************************************
+
+*******************************************************************************/
+ulong GeneralIndex::size() const
+{
+ assert(false);
+ return 0;
+}
+
+
+/******************************************************************************
+
+*******************************************************************************/
+bool GeneralIndex::insert(store::Item_t& key, store::Item_t& node)
+{
+ bool lossy = false;
bool found = false;
store::Item_t castItem;
store::Item_t node2;
- AtomicItem* keyItem = static_cast<AtomicItem*>((*key)[0].getp());
+ bool sorted = isSorted();
+
+ AtomicItem* keyItem = static_cast<AtomicItem*>(key.getp());
if (keyItem == NULL)
{
@@ -210,41 +258,50 @@
if (keyItem->getBaseItem() != NULL)
{
keyItem = static_cast<AtomicItem*>(keyItem->getBaseItem());
- (*key)[0] = keyItem;
+ key = keyItem;
}
SchemaTypeCode keyType = keyItem->getTypeCode();
if (isTyped())
{
- return insertInMap(key, node, theSingleMap, multikey, false);
+ return insertInMap(key, node, theKeyTypeCode, false);
}
switch (keyType)
{
- case XS_ANY_URI:
+ case XS_BASE64BINARY:
+ case XS_HEXBINARY:
+
case XS_QNAME:
case XS_NOTATION:
- case XS_DATETIME:
- case XS_DATE:
- case XS_TIME:
+
case XS_GYEAR_MONTH:
case XS_GYEAR:
case XS_GMONTH_DAY:
case XS_GDAY:
case XS_GMONTH:
- case XS_BASE64BINARY:
- case XS_HEXBINARY:
+ {
+ assert(!sorted);
+ // falth through
+ }
+
+ case XS_ANY_URI:
+
case XS_BOOLEAN:
+
+ case XS_DATETIME:
+ case XS_DATE:
+ case XS_TIME:
{
- return insertInMap(key, node, theMaps[keyType], multikey, false);
+ return insertInMap(key, node, keyType, false);
}
case XS_DURATION:
case XS_YM_DURATION:
case XS_DT_DURATION:
{
- return insertInMap(key, node, theMaps[XS_DURATION], multikey, false);
+ return insertInMap(key, node, XS_DURATION, false);
}
case XS_STRING:
@@ -258,13 +315,13 @@
case XS_IDREF:
case XS_ENTITY:
{
- return insertInMap(key, node, theMaps[XS_STRING], multikey, false);
+ return insertInMap(key, node, XS_STRING, false);
}
case XS_DOUBLE:
case XS_FLOAT:
{
- return insertInMap(key, node, theMaps[XS_DOUBLE], multikey, false);
+ return insertInMap(key, node, XS_DOUBLE, false);
}
case XS_DECIMAL:
@@ -275,32 +332,67 @@
case XS_POSITIVE_INTEGER:
case XS_UNSIGNED_LONG:
{
+ // try lossless cast to xs:long
keyItem->castToLong(castItem);
if (castItem != NULL)
{
keyItem = static_cast<AtomicItem*>(castItem.getp());
- (*key)[0].transfer(castItem);
+ key.transfer(castItem);
goto longmap;
}
- bool lossy;
+ // Coerce to xs:double
keyItem->coerceToDouble(castItem, true, lossy);
+ found = insertInMap(key, node, XS_DOUBLE, false);
+
if (lossy)
{
node2 = node;
- found = insertInMap(key, node2, theMaps[XS_DECIMAL], multikey, false);
+ found = found || insertInMap(castItem, node2, XS_DECIMAL, false);
}
- if (key == NULL) key = new store::IndexKey(1);
- (*key)[0].transfer(castItem);
-
- found = found || insertInMap(key, node, theMaps[XS_DOUBLE], multikey, false);
-
return found;
}
case XS_LONG:
+ {
+longmap:
+ xs_long longValue = static_cast<LongItem*>(keyItem)->getLongValue();
+
+ if (longValue > theMaxLong || longValue < theMinLong)
+ {
+ if (sorted)
+ {
+ lossy = true;
+ xs_double doubleValue(longValue);
+ GET_FACTORY().createDouble(castItem, doubleValue);
+ }
+ else
+ {
+ keyItem->coerceToDouble(castItem, false, lossy);
+ }
+
+ if (lossy)
+ {
+ node2 = node;
+ found = insertInMap(key, node2, XS_LONG, false);
+
+ found = found || insertInMap(castItem, node, XS_DOUBLE, false);
+ }
+ else
+ {
+ found = insertInMap(key, node, XS_LONG, false);
+ }
+ }
+ else
+ {
+ found = insertInMap(key, node, XS_LONG, false);
+ }
+
+ return found;
+ }
+
case XS_INT:
case XS_SHORT:
case XS_BYTE:
@@ -308,68 +400,75 @@
case XS_UNSIGNED_SHORT:
case XS_UNSIGNED_BYTE:
{
-longmap:
- bool lossy;
- keyItem->coerceToDouble(castItem, false, lossy);
-
- if (lossy)
- {
- node2 = node;
- found = insertInMap(key, node2, theMaps[XS_LONG], multikey, false);
-
- if (key == NULL) key = new store::IndexKey(1);
- (*key)[0].transfer(castItem);
-
- found = found || insertInMap(key, node, theMaps[XS_DOUBLE], multikey, false);
- }
- else
- {
- found = insertInMap(key, node, theMaps[XS_LONG], multikey, false);
- }
-
- return found;
+ return insertInMap(key, node, XS_LONG, false);
}
case XS_UNTYPED_ATOMIC:
{
- bool found = false;
-
store::ItemHandle<UntypedAtomicItem> untypedItem =
- static_cast<UntypedAtomicItem*>((*key)[0].getp());
-
- node2 = node;
+ static_cast<UntypedAtomicItem*>(key.getp());
// cast to xs:string
untypedItem->castToString(castItem);
- ADD_IN_MAP(XS_STRING, false);
-
- // no reason to cast to xs:anyUri, because when we probe with xs:string or with
- // xs:anyUri, or with xs:untypedAtomic, we unconditionally probe both the
- // STRING and the ANY_URI tables.
+
+ node2 = node;
+ found = insertInMap(castItem, node2, XS_STRING, false);
+
+ // No reason to cast to xs:anyUri, because when we probe with xs:string or
+ // with xs:anyUri, or with xs:untypedAtomic, we unconditionally probe both
+ // the STRING and the ANY_URI tables.
// try casting to xs:long
if (untypedItem->castToLong(castItem))
{
store::ItemHandle<LongItem> longItem = static_cast<LongItem*>(castItem.getp());
- ADD_IN_MAP(XS_LONG, true);
-
- bool lossy;
- longItem->coerceToDouble(castItem, false, lossy);
- if (lossy)
+ xs_long longValue = longItem->getLongValue();
+
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_LONG, true);
+
+ if (longValue > theMaxLong || longValue < theMinLong)
{
- ADD_IN_MAP(XS_DOUBLE, true);
+ if (sorted)
+ {
+ lossy = true;
+ xs_double doubleValue(longValue);
+ GET_FACTORY().createDouble(castItem, doubleValue);
+ }
+ else
+ {
+ longItem->coerceToDouble(castItem, false, lossy);
+ }
+
+ if (lossy)
+ {
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_DOUBLE, true);
+ }
}
// may also be gYear, hexBinary, base64Binary, or boolean
- if (untypedItem->castToGYear(castItem))
- ADD_IN_MAP(XS_GYEAR, true);
-
- if (untypedItem->castToHexBinary(castItem))
- ADD_IN_MAP(XS_HEXBINARY, true);
-
- if (untypedItem->castToBase64Binary(castItem))
- ADD_IN_MAP(XS_BASE64BINARY, true);
+ if (!sorted)
+ {
+ if (untypedItem->castToGYear(castItem))
+ {
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_GYEAR, true);
+ }
+
+ if (untypedItem->castToHexBinary(castItem))
+ {
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_HEXBINARY, true);
+ }
+
+ if (untypedItem->castToBase64Binary(castItem))
+ {
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_BASE64BINARY, true);
+ }
+ }
}
// try casting to xs:decimal
@@ -378,87 +477,110 @@
store::ItemHandle<DecimalItem> decimalItem =
static_cast<DecimalItem*>(castItem.getp());
- ADD_IN_MAP(XS_DOUBLE, true);
-
- bool lossy;
decimalItem->coerceToDouble(castItem, true, lossy);
+
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_DOUBLE, true);
+
if (lossy)
{
- ADD_IN_MAP(XS_DECIMAL, true);
+ castItem.transfer(decimalItem);
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_DECIMAL, true);
}
// may also be hexBinary or base64Binary
- if (untypedItem->castToHexBinary(castItem))
- ADD_IN_MAP(XS_HEXBINARY, true);
+ if (sorted)
+ {
+ if (untypedItem->castToHexBinary(castItem))
+ {
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_HEXBINARY, true);
+ }
- if (untypedItem->castToBase64Binary(castItem))
- ADD_IN_MAP(XS_BASE64BINARY, true);
+ if (untypedItem->castToBase64Binary(castItem))
+ {
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_BASE64BINARY, true);
+ }
+ }
}
// try casting to xs:double
else if (untypedItem->castToDouble(castItem))
{
- ADD_IN_MAP(XS_DOUBLE, true);
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_DOUBLE, true);
}
// try casting to xs:datetime
else if (untypedItem->castToDateTime(castItem))
{
- ADD_IN_MAP(XS_DATETIME, true);
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_DATETIME, true);
}
// try casting to xs:date
else if (untypedItem->castToDate(castItem))
{
- ADD_IN_MAP(XS_DATE, true);
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_DATE, true);
}
// try casting to xs:time
else if (untypedItem->castToTime(castItem))
{
- ADD_IN_MAP(XS_TIME, true);
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_TIME, true);
}
// try casting to xs:gYearMonth
- else if (untypedItem->castToGYearMonth(castItem))
+ if (!sorted && untypedItem->castToGYearMonth(castItem))
{
- ADD_IN_MAP(XS_GYEAR_MONTH, true);
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_GYEAR_MONTH, true);
}
// try casting to xs:gMonthDay
- else if (untypedItem->castToGMonthDay(castItem))
+ else if (!sorted && untypedItem->castToGMonthDay(castItem))
{
- ADD_IN_MAP(XS_GMONTH_DAY, true);
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_GMONTH_DAY, true);
}
// try casting to xs:gDay
- else if (untypedItem->castToGDay(castItem))
+ else if (!sorted && untypedItem->castToGDay(castItem))
{
- ADD_IN_MAP(XS_GDAY, true);
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_GDAY, true);
}
// try casting to xs:gMonth
- else if (untypedItem->castToGMonth(castItem))
+ else if (!sorted && untypedItem->castToGMonth(castItem))
{
- ADD_IN_MAP(XS_GMONTH, true);
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_GMONTH, true);
}
// try casting to xs:duration
else if (untypedItem->castToDuration(castItem))
{
- ADD_IN_MAP(XS_DURATION, true);
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_DURATION, true);
}
// try casting to xs:hexBinary
- else if (untypedItem->castToHexBinary(castItem))
+ else if (!sorted && untypedItem->castToHexBinary(castItem))
{
- ADD_IN_MAP(XS_HEXBINARY, true);
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_HEXBINARY, true);
}
// try casting to xs:base64Binary
- else if (untypedItem->castToBase64Binary(castItem))
+ else if (!sorted && untypedItem->castToBase64Binary(castItem))
{
- ADD_IN_MAP(XS_BASE64BINARY, true);
+ node2 = node;
+ found = found || insertInMap(castItem, node2, XS_BASE64BINARY, true);
}
return found;
@@ -466,7 +588,8 @@
default:
{
- ZORBA_ASSERT(false);
+ RAISE_ERROR_NO_LOC(zerr::ZDTY0012_INDEX_KEY_TYPE_ERROR,
+ ERROR_PARAMS(getName()->getStringValue()));
return false;
}
}
@@ -476,11 +599,102 @@
/******************************************************************************
*******************************************************************************/
+bool GeneralIndex::insertInMap(
+ store::Item_t& key,
+ store::Item_t& node,
+ SchemaTypeCode targetMap,
+ bool untyped)
+{
+ if (untyped)
+ theUntypedFlag = true;
+
+ if (isSorted())
+ {
+ GeneralTreeIndex* idx = static_cast<GeneralTreeIndex*>(this);
+ return idx->insertInMap(key, node, idx->theMaps[targetMap], untyped);
+ }
+ else
+ {
+ GeneralHashIndex* idx = static_cast<GeneralHashIndex*>(this);
+ return idx->insertInMap(key, node, idx->theMaps[targetMap], untyped);
+ }
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////
+// //
+// Hash Map General Index //
+// //
+/////////////////////////////////////////////////////////////////////////////////
+
+
+/******************************************************************************
+
+*******************************************************************************/
+GeneralHashIndex::GeneralHashIndex(
+ const store::Item_t& qname,
+ const store::IndexSpecification& spec)
+ :
+ GeneralIndex(qname, spec),
+ theSingleMap(NULL)
+{
+ assert(getNumColumns() == 1);
+
+ memset(reinterpret_cast<void*>(theMaps), 0, XS_LAST * sizeof(IndexMap*));
+
+ if (isTyped())
+ {
+ theSingleMap = new IndexMap(theCompFunction, 1024, spec.theIsThreadSafe);
+
+ theMaps[theKeyTypeCode] = theSingleMap;
+ }
+}
+
+
+/******************************************************************************
+
+*******************************************************************************/
+GeneralHashIndex::~GeneralHashIndex()
+{
+ for (ulong i = 0; i < XS_LAST; ++i)
+ {
+ if (theMaps[i] == NULL)
+ continue;
+
+ IndexMap::iterator ite = theMaps[i]->begin();
+ IndexMap::iterator end = theMaps[i]->end();
+
+ for (; ite != end; ++ite)
+ {
+ //std::cout << "Index Entry Delete [" << (*ite).first << ","
+ // << (*ite).second << "]" << std::endl;
+
+ (*ite).first->removeReference();
+ delete (*ite).second;
+ }
+
+ delete theMaps[i];
+ }
+}
+
+
+/******************************************************************************
+
+*******************************************************************************/
+store::Index::KeyIterator_t GeneralHashIndex::keys() const
+{
+ assert(false);
+ return 0;
+}
+
+
+/******************************************************************************
+
+*******************************************************************************/
bool GeneralHashIndex::insertInMap(
- store::IndexKey*& key,
+ store::Item_t& key,
store::Item_t& node,
IndexMap*& targetMap,
- bool multikey,
bool untyped)
{
GeneralIndexValue* valueSet = NULL;
@@ -488,36 +702,27 @@
if (targetMap == NULL)
targetMap = new IndexMap(theCompFunction, 1024, theSpec.theIsThreadSafe);
- if (untyped)
- theUntypedFlag = true;
-
- if (multikey)
- theMultiKeyFlag = true;
-
if (targetMap->get(key, valueSet))
{
if (isUnique())
{
- throw ZORBA_EXCEPTION(
- zerr::ZDDY0024_INDEX_UNIQUE_VIOLATION,
- ERROR_PARAMS( theQname->getStringValue() )
- );
+ RAISE_ERROR_NO_LOC(zerr::ZDDY0024_INDEX_UNIQUE_VIOLATION,
+ ERROR_PARAMS(theQname->getStringValue()));
}
- valueSet->addNode(node, multikey, untyped);
+ valueSet->addNode(node, untyped);
return true;
}
valueSet = new GeneralIndexValue();
- valueSet->addNode(node, multikey, untyped);
+ valueSet->addNode(node, untyped);
//std::cout << "Index Entry Insert [" << key << ","
// << valueSet << "]" << std::endl;
- const store::IndexKey* key2 = key;
- targetMap->insert(key2, valueSet);
- key = NULL; // ownership of the key obj passes to the index.
+ targetMap->insert(key.getp(), valueSet);
+ key.release(); // ownership of the key passes to the index.
return false;
}
@@ -527,7 +732,7 @@
*******************************************************************************/
bool GeneralHashIndex::remove(
- const store::IndexKey* key,
+ const store::Item_t& key,
store::Item_t& item,
bool all)
{
@@ -538,533 +743,47 @@
/////////////////////////////////////////////////////////////////////////////////
// //
-// ProbeHashGeneralIndexIterator //
-// //
-// Iterator to probe a general, hash-based index. The probe itself may be a //
-// value probe or a general probe. //
+// GeneralHashIndex::KeyIterator //
// //
/////////////////////////////////////////////////////////////////////////////////
/******************************************************************************
- Create an
-********************************************************************************/
-ProbeGeneralHashIndexIterator::ProbeGeneralHashIndexIterator(
- const store::Index_t& index)
- :
- theIsUntypedProbe(false),
- theResultSets(1)
-{
- theIndex = static_cast<GeneralHashIndex*>(index.getp());
-
- theResultSets[0] = NULL;
-}
-
-
-#define PROBE_MAP(MAP_ID) \
-{ \
- altKey[0].transfer(castItem); \
- theResultSets.push_back(NULL); \
- theIndex->theMaps[MAP_ID]->get(&altKey, theResultSets[theResultSets.size() - 1]); \
-}
-
-
-/******************************************************************************
-
-********************************************************************************/
-void ProbeGeneralHashIndexIterator::init(const store::IndexCondition_t& cond)
-{
- theProbeKind = cond->getKind();
-
- if (theProbeKind != store::IndexCondition::POINT_VALUE &&
- theProbeKind != store::IndexCondition::POINT_GENERAL)
- {
- RAISE_ERROR_NO_LOC(zerr::ZSTR0007_INDEX_UNSUPPORTED_PROBE_CONDITION,
- ERROR_PARAMS(cond->getKindString(), theIndex->getName()->getStringValue()));
- }
-
- theCondition = reinterpret_cast<IndexPointCondition*>(cond.getp());
-
- store::IndexKey* key = &(theCondition->theKey);
-
- if (key->size() != theIndex->getNumColumns())
- {
- RAISE_ERROR_NO_LOC(zerr::ZSTR0005_INDEX_PARTIAL_KEY_PROBE,
- ERROR_PARAMS(key->toString(), theIndex->getName()->getStringValue()));
- }
-
- if (theProbeKind == store::IndexCondition::POINT_VALUE)
- {
- if (theIndex->theMultiKeyFlag)
- {
- RAISE_ERROR_NO_LOC(err::XPTY0004,
- ERROR_PARAMS(ZED(NoMultiKeyNodeValues_2), theIndex->getName()->getStringValue()));
- }
-
- if (theIndex->theUntypedFlag)
- {
- AtomicItem* keyItem = static_cast<AtomicItem*>((*key)[0].getp());
-
- if (keyItem->getBaseItem() != NULL)
- keyItem = static_cast<AtomicItem*>(keyItem->getBaseItem());
-
- SchemaTypeCode keyType = keyItem->getTypeCode();
-
- if (keyType != XS_UNTYPED_ATOMIC &&
- keyType != XS_ANY_URI &&
- keyType != XS_STRING &&
- keyType != XS_NORMALIZED_STRING &&
- keyType != XS_TOKEN &&
- keyType != XS_NMTOKEN &&
- keyType != XS_LANGUAGE &&
- keyType != XS_NAME &&
- keyType != XS_NCNAME &&
- keyType != XS_ID &&
- keyType != XS_IDREF &&
- keyType != XS_ENTITY)
- {
- RAISE_ERROR_NO_LOC(err::XPTY0004,
- ERROR_PARAMS(ZED(NoUntypedKeyNodeValue_2),
- theIndex->getName()->getStringValue()));
- }
- }
- }
-
- theResultSets.resize(1);
- theResultSets[0] = NULL;
-
- if (theIndex->isTyped())
- {
- // Note: the runtime (or compiler) makes sure that the search key is a
- // subtype of the index key type.
-
- theIndex->theSingleMap->get(key, theResultSets[0]);
- }
- else
- {
- bool lossy;
- store::Item_t castItem;
- store::IndexKey altKey(1);
- AtomicItem* keyItem = static_cast<AtomicItem*>((*key)[0].getp());
-
- if (keyItem->getBaseItem() != NULL)
- {
- keyItem = static_cast<AtomicItem*>(keyItem->getBaseItem());
- (*key)[0] = keyItem;
- }
-
- SchemaTypeCode keyType = keyItem->getTypeCode();
-
- switch (keyType)
- {
- case XS_ANY_URI:
- {
- if (theIndex->theMaps[XS_ANY_URI])
- {
- theIndex->theMaps[XS_ANY_URI]->get(key, theResultSets[0]);
- }
-
- if (theIndex->theMaps[XS_STRING] != NULL)
- {
- store::Item_t castItem;
- zstring tmp;
- keyItem->getStringValue2(tmp);
- GET_FACTORY().createString(castItem, tmp);
-
- PROBE_MAP(XS_STRING);
- }
-
- break;
- }
-
- case XS_QNAME:
- case XS_NOTATION:
- case XS_BASE64BINARY:
- case XS_HEXBINARY:
- case XS_BOOLEAN:
- case XS_DATETIME:
- case XS_DATE:
- case XS_TIME:
- case XS_GYEAR_MONTH:
- case XS_GYEAR:
- case XS_GMONTH_DAY:
- case XS_GDAY:
- case XS_GMONTH:
- {
- if (theIndex->theMaps[keyType] != NULL)
- {
- theIndex->theMaps[keyType]->get(key, theResultSets[0]);
- }
-
- break;
- }
-
- case XS_DURATION:
- case XS_YM_DURATION:
- case XS_DT_DURATION:
- {
- if (theIndex->theMaps[XS_DURATION])
- {
- theIndex->theMaps[XS_DURATION]->get(key, theResultSets[0]);
- }
-
- break;
- }
-
- case XS_STRING:
- case XS_NORMALIZED_STRING:
- case XS_TOKEN:
- case XS_NMTOKEN:
- case XS_LANGUAGE:
- case XS_NAME:
- case XS_NCNAME:
- case XS_ID:
- case XS_IDREF:
- case XS_ENTITY:
- {
- if (theIndex->theMaps[XS_STRING])
- {
- theIndex->theMaps[XS_STRING]->get(key, theResultSets[0]);
- }
-
- if (theIndex->theMaps[XS_ANY_URI])
- {
- store::Item_t castItem;
- zstring tmp;
- keyItem->getStringValue2(tmp);
- GET_FACTORY().createAnyURI(castItem, tmp);
-
- PROBE_MAP(XS_ANY_URI);
- }
-
- break;
- }
-
- case XS_DOUBLE:
- case XS_FLOAT:
- {
- if (theIndex->theMaps[XS_DOUBLE])
- {
- theIndex->theMaps[XS_DOUBLE]->get(key, theResultSets[0]);
- }
-
- if (theIndex->theMaps[XS_LONG] && keyItem->castToLong(castItem))
- {
- PROBE_MAP(XS_LONG);
- }
-
- break;
- }
-
- case XS_DECIMAL:
- case XS_INTEGER:
- case XS_NON_POSITIVE_INTEGER:
- case XS_NEGATIVE_INTEGER:
- case XS_NON_NEGATIVE_INTEGER:
- case XS_POSITIVE_INTEGER:
- case XS_UNSIGNED_LONG:
- {
- keyItem->coerceToDouble(castItem, true, lossy);
-
- if (lossy && theIndex->theMaps[XS_DECIMAL])
- {
- theIndex->theMaps[XS_DECIMAL]->get(key, theResultSets[0]);
- }
-
- if (theIndex->theMaps[XS_DOUBLE])
- {
- PROBE_MAP(XS_DOUBLE);
- }
-
- if (theIndex->theMaps[XS_LONG] && keyItem->castToLong(castItem))
- {
- PROBE_MAP(XS_LONG);
- }
-
- break;
- }
-
- case XS_LONG:
- case XS_INT:
- case XS_SHORT:
- case XS_BYTE:
- case XS_UNSIGNED_INT:
- case XS_UNSIGNED_SHORT:
- case XS_UNSIGNED_BYTE:
- {
- if (theIndex->theMaps[XS_LONG])
- {
- theIndex->theMaps[XS_LONG]->get(key, theResultSets[0]);
- }
-
- if (theIndex->theMaps[XS_DOUBLE])
- {
- keyItem->coerceToDouble(castItem, true, lossy);
- PROBE_MAP(XS_DOUBLE);
- }
-
- break;
- }
-
- case XS_UNTYPED_ATOMIC:
- {
- theIsUntypedProbe = true;
-
- store::ItemHandle<UntypedAtomicItem> untypedItem =
- static_cast<UntypedAtomicItem*>(keyItem);
-
- // cast to xs:string
- if (theIndex->theMaps[XS_STRING])
- {
- untypedItem->castToString(castItem);
- PROBE_MAP(XS_STRING);
- }
-
- // cast to xs:anyURI
- if (theIndex->theMaps[XS_ANY_URI] &&
- untypedItem->castToUri(castItem))
- {
- PROBE_MAP(XS_ANY_URI);
- }
-
- if (theProbeKind == store::IndexCondition::POINT_VALUE)
- return;
-
- // try casting to xs:long
- if ((theIndex->theMaps[XS_LONG] ||
- theIndex->theMaps[XS_DOUBLE]) &&
- (untypedItem->castToLong(castItem), castItem != NULL))
- {
- store::ItemHandle<LongItem> longItem =
- static_cast<LongItem*>(castItem.getp());
-
- if (theIndex->theMaps[XS_LONG])
- PROBE_MAP(XS_LONG);
-
- if (theIndex->theMaps[XS_DOUBLE])
- {
- longItem->coerceToDouble(castItem, true, lossy);
- PROBE_MAP(XS_DOUBLE);
- }
-
- // may also be gYear, hexBinary, or boolean
- if (theIndex->theMaps[XS_GYEAR])
- {
- untypedItem->castToGYear(castItem);
- PROBE_MAP(XS_GYEAR);
- }
-
- if (theIndex->theMaps[XS_HEXBINARY])
- {
- untypedItem->castToHexBinary(castItem);
- PROBE_MAP(XS_HEXBINARY);
- }
- }
-
- // try casting to xs:decimal
- else if ((theIndex->theMaps[XS_DECIMAL] ||
- theIndex->theMaps[XS_LONG] ||
- theIndex->theMaps[XS_DOUBLE]) &&
- untypedItem->castToDecimal(castItem))
- {
- store::ItemHandle<DecimalItem> decimalItem =
- static_cast<DecimalItem*>(castItem.getp());
-
- decimalItem->coerceToDouble(castItem, true, lossy);
-
- if (theIndex->theMaps[XS_DOUBLE])
- {
- PROBE_MAP(XS_DOUBLE);
- }
-
- if (theIndex->theMaps[XS_LONG] && decimalItem->castToLong(castItem))
- {
- PROBE_MAP(XS_LONG);
- }
-
- if (lossy && theIndex->theMaps[XS_DECIMAL])
- {
- castItem.transfer(decimalItem);
- PROBE_MAP(XS_DOUBLE);
- }
-
- // may also be hexBinary
- if (theIndex->theMaps[XS_HEXBINARY])
- {
- untypedItem->castToHexBinary(castItem);
- PROBE_MAP(XS_HEXBINARY);
- }
- }
-
- // try casting to xs:double
- else if ((theIndex->theMaps[XS_LONG] || theIndex->theMaps[XS_DOUBLE]) &&
- untypedItem->castToDouble(castItem))
- {
- store::ItemHandle<DoubleItem> doubleItem =
- static_cast<DoubleItem*>(castItem.getp());
-
- if (theIndex->theMaps[XS_DOUBLE])
- PROBE_MAP(XS_DOUBLE);
-
- if (theIndex->theMaps[XS_LONG] && doubleItem->castToLong(castItem))
- {
- PROBE_MAP(XS_LONG);
- }
- }
-
- // try casting to xs:datetime
- else if (theIndex->theMaps[XS_DATETIME] &&
- untypedItem->castToDateTime(castItem))
- {
- PROBE_MAP(XS_DATETIME);
- }
-
- // try casting to xs:date
- else if (theIndex->theMaps[XS_DATE] &&
- untypedItem->castToDate(castItem))
- {
- PROBE_MAP(XS_DATE);
- }
-
- // try casting to xs:time
- else if (theIndex->theMaps[XS_TIME] &&
- untypedItem->castToTime(castItem))
- {
- PROBE_MAP(XS_TIME);
- }
-
- // try casting to xs:gYearMonth
- else if (theIndex->theMaps[XS_GYEAR_MONTH] &&
- untypedItem->castToGYearMonth(castItem))
- {
- PROBE_MAP(XS_GYEAR_MONTH);
- }
-
- // try casting to xs:gMonthDay
- else if (theIndex->theMaps[XS_GMONTH_DAY] &&
- untypedItem->castToGMonthDay(castItem))
- {
- PROBE_MAP(XS_GMONTH_DAY);
- }
-
- // try casting to xs:gDay
- else if (theIndex->theMaps[XS_GDAY] &&
- untypedItem->castToGDay(castItem))
- {
- PROBE_MAP(XS_GDAY);
- }
-
- // try casting to xs:gMonth
- else if (theIndex->theMaps[XS_GMONTH] &&
- untypedItem->castToGMonth(castItem))
- {
- PROBE_MAP(XS_GMONTH);
- }
-
- // try casting to xs:duration
- else if (theIndex->theMaps[XS_DURATION] &&
- untypedItem->castToDuration(castItem))
- {
- PROBE_MAP(XS_DURATION);
- }
-
- // try casting to xs:hexBinary
- else if (theIndex->theMaps[XS_HEXBINARY] &&
- untypedItem->castToHexBinary(castItem))
- {
- PROBE_MAP(XS_HEXBINARY);
- }
-
- // try casting to xs:base64Binary
- else if (theIndex->theMaps[XS_BASE64BINARY] &&
- untypedItem->castToBase64Binary(castItem))
- {
- PROBE_MAP(XS_BASE64BINARY);
- }
-
- break;
- }
-
- default:
- {
- ZORBA_ASSERT(false);
- }
- }
- }
-}
-
-
-/******************************************************************************
-
-********************************************************************************/
-void ProbeGeneralHashIndexIterator::open()
-{
- theResultSetsEnd = theResultSets.end();
- theResultSetsIte = theResultSets.begin();
-
- for (; theResultSetsIte != theResultSetsEnd; ++theResultSetsIte)
- {
- if (*theResultSetsIte != NULL)
- {
- theIte = (*theResultSetsIte)->begin();
- theEnd = (*theResultSetsIte)->end();
-
- break;
- }
- }
-}
-
-
-/******************************************************************************
-
-********************************************************************************/
-void ProbeGeneralHashIndexIterator::reset()
-{
- open();
-}
-
-
-/******************************************************************************
-
-********************************************************************************/
-void ProbeGeneralHashIndexIterator::close()
-{
-}
-
-
-/******************************************************************************
- TODO : need sync on result vector
-********************************************************************************/
-bool ProbeGeneralHashIndexIterator::next(store::Item_t& result)
-{
- while (theResultSetsIte != theResultSetsEnd)
- {
- while (theIte != theEnd)
- {
- if (theIsUntypedProbe && (*theIte).theUntyped)
- {
- ++theIte;
- continue;
- }
-
- result = (*theIte).theNode;
- ++theIte;
- return true;
- }
-
- ++theResultSetsIte;
-
- if (theResultSetsIte != theResultSetsEnd && *theResultSetsIte != NULL)
- {
- theIte = (*theResultSetsIte)->begin();
- theEnd = (*theResultSetsIte)->end();
- }
- }
-
+
+*******************************************************************************/
+GeneralHashIndex::KeyIterator::~KeyIterator()
+{
+}
+
+
+/******************************************************************************
+
+*******************************************************************************/
+void GeneralHashIndex::KeyIterator::open()
+{
+ assert(false);
+}
+
+
+/******************************************************************************
+
+*******************************************************************************/
+bool GeneralHashIndex::KeyIterator::next(store::IndexKey&)
+{
+ assert(false);
return false;
}
+/******************************************************************************
+
+*******************************************************************************/
+void GeneralHashIndex::KeyIterator::close()
+{
+ assert(false);
+}
+
+
/////////////////////////////////////////////////////////////////////////////////
// //
// Tree General Index //
@@ -1086,15 +805,11 @@
memset(reinterpret_cast<void*>(theMaps), 0, XS_LAST * sizeof(IndexMap*));
- store::Item* typeName = spec.theKeyTypes[0].getp();
-
- if (typeName != NULL &&
- typeName != GET_STORE().theSchemaTypeNames[XS_UNTYPED_ATOMIC] &&
- typeName != GET_STORE().theSchemaTypeNames[XS_ANY_ATOMIC])
+ if (isTyped())
{
theSingleMap = new IndexMap(theCompFunction);
- theMaps[GET_STORE().theSchemaTypeCodes[spec.theKeyTypes[0].getp()]] = theSingleMap;
+ theMaps[theKeyTypeCode] = theSingleMap;
}
}
@@ -1117,7 +832,7 @@
//std::cout << "Index Entry Delete [" << (*ite).first << ","
// << (*ite).second << "]" << std::endl;
- delete (*ite).first;
+ (*ite).first->removeReference();
delete (*ite).second;
}
@@ -1129,240 +844,10 @@
/******************************************************************************
*******************************************************************************/
-bool GeneralTreeIndex::insert(
- store::IndexKey*& key,
- store::Item_t& node,
- bool multikey)
-{
- bool found = false;
- store::Item_t castItem;
- store::Item_t node2;
- bool lossy;
-
- AtomicItem* keyItem = static_cast<AtomicItem*>((*key)[0].getp());
-
- if (keyItem == NULL)
- {
- csize numNodes = theEmptyKeyNodes.size();
- theEmptyKeyNodes.resize(numNodes + 1);
- theEmptyKeyNodes[numNodes].transfer(node);
- return true;
- }
-
- if (keyItem->getBaseItem() != NULL)
- {
- keyItem = static_cast<AtomicItem*>(keyItem->getBaseItem());
- (*key)[0] = keyItem;
- }
-
- SchemaTypeCode keyType = keyItem->getTypeCode();
-
- if (isTyped())
- {
- return insertInMap(key, node, theSingleMap, multikey, false);
- }
-
- switch (keyType)
- {
- case XS_ANY_URI:
- case XS_DATETIME:
- case XS_DATE:
- case XS_TIME:
- case XS_BOOLEAN:
- {
- return insertInMap(key, node, theMaps[keyType], multikey, false);
- }
-
- case XS_DURATION:
- case XS_YM_DURATION:
- case XS_DT_DURATION:
- {
- return insertInMap(key, node, theMaps[XS_DURATION], multikey, false);
- }
-
- case XS_STRING:
- case XS_NORMALIZED_STRING:
- case XS_TOKEN:
- case XS_NMTOKEN:
- case XS_LANGUAGE:
- case XS_NAME:
- case XS_NCNAME:
- case XS_ID:
- case XS_IDREF:
- case XS_ENTITY:
- {
- return insertInMap(key, node, theMaps[XS_STRING], multikey, false);
- }
-
- case XS_DOUBLE:
- case XS_FLOAT:
- {
- return insertInMap(key, node, theMaps[XS_DOUBLE], multikey, false);
- }
-
- case XS_DECIMAL:
- case XS_INTEGER:
- case XS_NON_POSITIVE_INTEGER:
- case XS_NEGATIVE_INTEGER:
- case XS_NON_NEGATIVE_INTEGER:
- case XS_POSITIVE_INTEGER:
- case XS_UNSIGNED_LONG:
- {
- keyItem->castToLong(castItem);
- if (castItem != NULL)
- {
- keyItem = static_cast<AtomicItem*>(castItem.getp());
- (*key)[0].transfer(castItem);
- goto longmap;
- }
-
- keyItem->coerceToDouble(castItem, true, lossy);
-
- if (lossy)
- {
- node2 = node;
- found = insertInMap(key, node2, theMaps[XS_DECIMAL], multikey, false);
- }
-
- if (key == NULL) key = new store::IndexKey(1);
- (*key)[0].transfer(castItem);
-
- found = found || insertInMap(key, node, theMaps[XS_DOUBLE], multikey, false);
-
- return found;
- }
-
- case XS_LONG:
- {
-longmap:
- xs_long longValue = static_cast<LongItem*>(keyItem)->getLongValue();
-
- if (longValue > theMaxLong || longValue < theMinLong)
- {
- node2 = node;
- found = insertInMap(key, node2, theMaps[XS_LONG], multikey, false);
-
- xs_double doubleValue(longValue);
- GET_FACTORY().createDouble(castItem, doubleValue);
-
- if (key == NULL) key = new store::IndexKey(1);
- (*key)[0].transfer(castItem);
-
- found = found || insertInMap(key, node, theMaps[XS_DOUBLE], multikey, false);
- }
- else
- {
- found = insertInMap(key, node, theMaps[XS_LONG], multikey, false);
- }
-
- return found;
- }
-
- case XS_INT:
- case XS_SHORT:
- case XS_BYTE:
- case XS_UNSIGNED_INT:
- case XS_UNSIGNED_SHORT:
- case XS_UNSIGNED_BYTE:
- {
- return insertInMap(key, node, theMaps[XS_LONG], multikey, false);
- }
-
- case XS_UNTYPED_ATOMIC:
- {
- bool found = false;
-
- store::ItemHandle<UntypedAtomicItem> untypedItem =
- static_cast<UntypedAtomicItem*>((*key)[0].getp());
-
- node2 = node;
-
- // cast to xs:string
- untypedItem->castToString(castItem);
- ADD_IN_MAP(XS_STRING, false);
-
- // try casting to xs:long
- if (untypedItem->castToLong(castItem))
- {
- ADD_IN_MAP(XS_LONG, true);
-
- store::ItemHandle<LongItem> longItem = static_cast<LongItem*>(castItem.getp());
- xs_long longValue = longItem->getLongValue();
-
- if (longValue > theMaxLong || longValue < theMinLong)
- {
- xs_double doubleValue(longValue);
- GET_FACTORY().createDouble(castItem, doubleValue);
-
- ADD_IN_MAP(XS_DOUBLE, true);
- }
- }
-
- // try casting to xs:decimal
- else if (untypedItem->castToDecimal(castItem))
- {
- store::ItemHandle<DecimalItem> decimalItem =
- static_cast<DecimalItem*>(castItem.getp());
-
- ADD_IN_MAP(XS_DOUBLE, true);
-
- decimalItem->coerceToDouble(castItem, true, lossy);
- if (lossy)
- {
- ADD_IN_MAP(XS_DECIMAL, true);
- }
- }
-
- // try casting to xs:double
- else if (untypedItem->castToDouble(castItem))
- {
- ADD_IN_MAP(XS_DOUBLE, true);
- }
-
- // try casting to xs:datetime
- else if (untypedItem->castToDateTime(castItem))
- {
- ADD_IN_MAP(XS_DATETIME, true);
- }
-
- // try casting to xs:date
- else if (untypedItem->castToDate(castItem))
- {
- ADD_IN_MAP(XS_DATE, true);
- }
-
- // try casting to xs:time
- else if (untypedItem->castToTime(castItem))
- {
- ADD_IN_MAP(XS_TIME, true);
- }
-
- // try casting to xs:duration
- else if (untypedItem->castToDuration(castItem))
- {
- ADD_IN_MAP(XS_DURATION, true);
- }
-
- return found;
- }
-
- default:
- {
- RAISE_ERROR_NO_LOC(zerr::ZDTY0012_INDEX_KEY_TYPE_ERROR,
- ERROR_PARAMS(getName()->getStringValue()));
- }
- }
-}
-
-
-/******************************************************************************
-
-*******************************************************************************/
bool GeneralTreeIndex::insertInMap(
- store::IndexKey*& key,
+ store::Item_t& key,
store::Item_t& node,
IndexMap*& targetMap,
- bool multikey,
bool untyped)
{
GeneralIndexValue* valueSet = NULL;
@@ -1370,12 +855,6 @@
if (targetMap == NULL)
targetMap = new IndexMap(theCompFunction);
- if (untyped)
- theUntypedFlag = true;
-
- if (multikey)
- theMultiKeyFlag = true;
-
IndexMap::iterator pos = targetMap->find(key);
if (pos != targetMap->end())
@@ -1386,19 +865,19 @@
ERROR_PARAMS(theQname->getStringValue()));
}
- pos->second->addNode(node, multikey, untyped);
+ pos->second->addNode(node, untyped);
return true;
}
valueSet = new GeneralIndexValue();
- valueSet->addNode(node, multikey, untyped);
+ valueSet->addNode(node, untyped);
//std::cout << "Index Entry Insert [" << key << ","
// << valueSet << "]" << std::endl;
- targetMap->insert(IndexMapPair(key, valueSet));
- key = NULL; // ownership of the key obj passes to the index.
+ targetMap->insert(IndexMapPair(key.getp(), valueSet));
+ key.release(); // ownership of the key obj passes to the index.
return false;
}
@@ -1408,7 +887,7 @@
*******************************************************************************/
bool GeneralTreeIndex::remove(
- const store::IndexKey* key,
+ const store::Item_t& key,
store::Item_t& item,
bool all)
{
@@ -1419,15 +898,6 @@
/******************************************
Follow ups