jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1481846 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/query/ main/java/org/apache/jackrabbit/oak/query/ast/ test/resources/org/apache/jackrabbit/oak/query/
Date Mon, 13 May 2013 13:36:31 GMT
Author: thomasm
Date: Mon May 13 13:36:30 2013
New Revision: 1481846

URL: http://svn.apache.org/r1481846
Log:
OAK-318 Excerpt support

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ColumnImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_index.txt
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java?rev=1481846&r1=1481845&r2=1481846&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
Mon May 13 13:36:30 2013
@@ -185,6 +185,15 @@ public class XPathToSQL2Converter {
             } else if (readIf("@")) {
                 Property p = readProperty();
                 columnList.add(p);
+            } else if (readIf("rep:excerpt")) {
+                read("(");
+                if (!readIf(")")) {
+                    // only rep:excerpt(.) and rep:excerpt() are currently supported
+                    read(".");
+                    read(")");
+                }
+                Property p = new Property(currentSelector, "rep:excerpt");
+                columnList.add(p);
             } else if (readIf("(")) {
                 // special case: ".../(@prop)" is actually not a child node, 
                 // but the same node (selector) as before 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ColumnImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ColumnImpl.java?rev=1481846&r1=1481845&r2=1481846&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ColumnImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ColumnImpl.java
Mon May 13 13:36:30 2013
@@ -58,5 +58,9 @@ public class ColumnImpl extends AstEleme
     public void bindSelector(SourceImpl source) {
         selector = source.getExistingSelector(selectorName);
     }
+    
+    public SelectorImpl getSelector() {
+        return selector;
+    }
 
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java?rev=1481846&r1=1481845&r2=1481846&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
Mon May 13 13:36:30 2013
@@ -198,6 +198,16 @@ public class SelectorImpl extends Source
         if (joinCondition != null) {
             joinCondition.restrict(f);
         }
+        // rep:excerpt handling: create a (fake) restriction
+        // "rep:excerpt is not null" to let the index know that
+        // we will need the excerpt
+        for (ColumnImpl c : query.getColumns()) {
+            if (c.getSelector() == this) {
+                if (c.getColumnName().equals("rep:excerpt")) {
+                    f.restrictProperty("rep:excerpt", Operator.NOT_EQUAL, null);
+                }
+            }
+        }
         
         // all conditions can be pushed to the selectors -
         // except in some cases to "outer joined" selectors,
@@ -257,8 +267,8 @@ public class SelectorImpl extends Source
                 }
             }
         }
-
-        return false; // no matches found
+        // no matches found
+        return false; 
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_index.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_index.txt?rev=1481846&r1=1481845&r2=1481846&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_index.txt
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_index.txt
Mon May 13 13:36:30 2013
@@ -37,6 +37,9 @@ explain select * from [nt:base] as a inn
 explain select * from [nt:base] as a inner join [nt:base] as b on isdescendantnode(b, a)
where a.[jcr:uuid] is not null and b.[x] is not null
 [nt:base] as [a] /* property jcr:uuid where [a].[jcr:uuid] is not null */ inner join [nt:base]
as [b] /* traverse "/path/from/the/join/selector/*" where [b].[x] is not null */ on isdescendantnode([b],
[a])
 
+explain select [rep:excerpt] from [nt:base] where [jcr:uuid] is not null
+[nt:base] as [nt:base] /* property jcr:uuid (rep:excerpt) where [nt:base].[jcr:uuid] is not
null */
+
 commit / + "test": { "jcr:uuid": "xyz", "a": { "jcr:uuid": "123" } }
 
 select [jcr:path] from [nt:base] where [jcr:uuid] is not null

Modified: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt?rev=1481846&r1=1481845&r2=1481846&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
Mon May 13 13:36:30 2013
@@ -50,22 +50,22 @@ xpath2sql /test
 select [jcr:path], [jcr:score], * from [nt:base] as a where name(a) = 'test' and issamenode(a,
'/') /* xpath: /test */
 
 xpath2sql /
-invalid: Query: (*)/; expected: jcr:root, /, *, text, element, @, (, .
+invalid: Query: (*)/; expected: jcr:root, /, *, text, element, @, rep:excerpt, (, .
 
 xpath2sql /[@name='data']
-invalid: Query: /[(*)@name='data']; expected: jcr:root, /, *, text, element, @, (, .
+invalid: Query: /[(*)@name='data']; expected: jcr:root, /, *, text, element, @, rep:excerpt,
(, .
 
 xpath2sql //[@name='data']
-invalid: Query: //[(*)@name='data']; expected: *, text, element, @, (, .
+invalid: Query: //[(*)@name='data']; expected: *, text, element, @, rep:excerpt, (, .
 
 xpath2sql //child/[@id='2.1']
-invalid: Query: //child/[(*)@id='2.1']; expected: jcr:root, /, *, text, element, @, (, .
+invalid: Query: //child/[(*)@id='2.1']; expected: jcr:root, /, *, text, element, @, rep:excerpt,
(, .
 
 xpath2sql //
-invalid: Query: /(*)/; expected: *, text, element, @, (, .
+invalid: Query: /(*)/; expected: *, text, element, @, rep:excerpt, (, .
 
 xpath2sql [@name='data']
-invalid: Query: [(*)@name='data']; expected: /, *, text, element, @, (, .
+invalid: Query: [(*)@name='data']; expected: /, *, text, element, @, rep:excerpt, (, .
 
 xpath2sql test
 select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/test') /* xpath:
test */
@@ -146,7 +146,7 @@ select [jcr:path], [jcr:score], * from [
 
 # TODO support rep:excerpt() and rep:similar()? how?
 xpath2sql /jcr:root/testroot/*[jcr:contains(., 'jackrabbit')]/rep:excerpt(.)
-invalid: Query: /jcr:root/testroot/*[jcr:contains(., 'jackrabbit')]/rep:excerpt((*).); expected:
<end>
+select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.[rep:excerpt] as [rep:excerpt]
from [nt:base] as a inner join [nt:base] as b on ischildnode(b, a) where contains(a.*, 'jackrabbit')
and ischildnode(a, '/testroot') /* xpath: /jcr:root/testroot/*[jcr:contains(., 'jackrabbit')]/rep:excerpt(.)
*/
 
 xpath2sql //testroot/*[@jcr:primaryType='nt:unstructured' and fn:not(@mytext)]
 select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a
inner join [nt:base] as b on ischildnode(b, a) where name(a) = 'testroot' and b.[jcr:primaryType]
= 'nt:unstructured' and b.[mytext] is null /* xpath: //testroot/*[@jcr:primaryType='nt:unstructured'
and fn:not(@mytext)] */
@@ -367,7 +367,7 @@ xpath2sql //element(*, my:type)[jcr:cont
 select [jcr:path], [jcr:score], * from [my:type] as a where contains([my:title], 'jcr') order
by score(a) desc /* xpath: //element(*, my:type)[jcr:contains(@my:title, 'jcr')] order by
jcr:score() descending */
 
 xpath2sql [invalid/query
-invalid: Query: [(*)invalid/query; expected: /, *, text, element, @, (, .
+invalid: Query: [(*)invalid/query; expected: /, *, text, element, @, rep:excerpt, (, .
 
 xpath2sql //element(*, my:type)[@my:value = -'x']
 invalid: Query: //element(*, my:type)[@my:value = -'x'(*)]



Mime
View raw message