ModeShape
  1. ModeShape
  2. MODE-934

Add support for path, name, local name, depth, and score pseudo-column in JCR-SQL2

    Details

    • Estimated Difficulty:
      Medium
    • Similar Issues:
      Show 10 results 

      Description

      The primary need for this feature comes from MODE-933.

      ModeShape's support for JCR-SQL2 (and perhaps JCR-SQL) should include using pseudo-columns for the path, name, local name, depth and score of a selector. Support should include using these pseudo-columns in the SELECT clause (just as regular properties, and thus would appear in the QueryResult's row values) and in the WHERE clause (where they can be rewritten to use the existing PATH, NAME, LOCALNAME, DEPTH, and SCORE functions). However, they should not be automatically included in the SELECT clause if the query uses "SELECT *"; they must explicitly be specified in order to appear in the results.

      1. MODE-934-fix.patch
        81 kB
        Randall Hauch
      2. MODE-934-fix2.patch
        15 kB
        Randall Hauch
      3. MODE-934-fix3.patch
        20 kB
        Randall Hauch

        Issue Links

          Activity

          Hide
          Randall Hauch
          added a comment -

          I believe this actually will be relatively straightforward.

          1) Support for using these pseudo-column in the SELECT clause can be accomplished by ensuring these columns exist in the schemata for the 'nt:base' and any mixin types that have no supertype.

          2) Support for these columns appear in the result set can be accomplished in one of two ways:
          a) Ensure values for these columns are returned from the Lucene query engine
          b) Add the values for these columns in the QueryResult implementation (which is where the JCR-SQL 'jcr:path' and 'jcr:score' pseudo-columns are supported).

          3) Support for these pseudo-columns in the WHERE clause requires a new optimizer rule that rewrites the corresponding DynamicOperands. For example, all criteria using these pseudo-columns will take the form of a PropertyValue operand, and these can be converted in place into the appropriate NodePath, NodeName, NodeLocalName, NodeDepth, or FullTextSearchScore dynamic operands.

          It is not clear what the names of these pseudo-columns should be. Since they are unique to ModeShape, my initial idea would be to use "mode:path", "mode:name", "mode:localName", "mode:depth" and "mode:score". However, JCR-SQL already has the "jcr:path" and "jcr:score" pseudo-columns, and it might be easier and more natural to simply reuse these. Plus, JCR already uses the notion of "jcr:name" in node type, property and child node definitions.

          Show
          Randall Hauch
          added a comment - I believe this actually will be relatively straightforward. 1) Support for using these pseudo-column in the SELECT clause can be accomplished by ensuring these columns exist in the schemata for the 'nt:base' and any mixin types that have no supertype. 2) Support for these columns appear in the result set can be accomplished in one of two ways: a) Ensure values for these columns are returned from the Lucene query engine b) Add the values for these columns in the QueryResult implementation (which is where the JCR-SQL 'jcr:path' and 'jcr:score' pseudo-columns are supported). 3) Support for these pseudo-columns in the WHERE clause requires a new optimizer rule that rewrites the corresponding DynamicOperands. For example, all criteria using these pseudo-columns will take the form of a PropertyValue operand, and these can be converted in place into the appropriate NodePath, NodeName, NodeLocalName, NodeDepth, or FullTextSearchScore dynamic operands. It is not clear what the names of these pseudo-columns should be. Since they are unique to ModeShape, my initial idea would be to use "mode:path", "mode:name", "mode:localName", "mode:depth" and "mode:score". However, JCR-SQL already has the "jcr:path" and "jcr:score" pseudo-columns, and it might be easier and more natural to simply reuse these. Plus, JCR already uses the notion of "jcr:name" in node type, property and child node definitions.
          Hide
          Randall Hauch
          added a comment -

          Implemented the support for the 'jcr:path', 'jcr:score', 'jcr:name', 'mode:localName', and 'mode:depth' pseudo-columns. The changes include:

          1) Changing the Lucene search engine implementation to support returning data values for these pseudo-columns. This wouldn't have to be done, but it is a bit more complete and does allow using the values in joins.

          2) Changing the schemata representation to enable tracking which columns are used when expanding SELECT * clauses. Additionally, the classes were improved to be more efficient; strictly speaking, this optimization did not need to be done, but it simplified the implementation of the required changes, and it also improved the time required to build the schemata from the set of node types. (Whenever node types are added, removed, or changed, the shared schemata is nulled, and needs to be rebuilt the next time the schemata is needed for processing queries. Thus, performance can be important.)

          3) Added constants for the Name objects in the JCR and ModeShape lexicons.

          4) Added support for getting the pseudo-column values in the JCR QueryResult (and in particular, the Row) implementations. Since these are pseudo-columns, there are no corresponding properties on the nodes, so the values need to be computed using the row's Location and score.

          5) Changed the RepositoryQueryManager to use a new query optimization rule that rewrites join criteria and constraints to use the standard JCR functions (e.g., NAME, LOCALNAME, and SCORE) and the ModeShape functions (e.g., PATH and DEPTH).

          6) Added several new unit tests for these classes and for various JCR-SQL2 queries.

          BTW, by using 'jcr:path' and 'jcr:score' for the names (rather than 'mode:path' and 'mode:score'), these changes also add support for these pseudo-columns to the JCR-SQL query language in ModeShape.

          At this point, all unit and integration tests pass, and ModeShape's support for JCR-SQL2 now handles these pseudo-columns.

          These changes were committed into SVN trunk with r2343 and into the '2.2.x' branch with r2344.

          Show
          Randall Hauch
          added a comment - Implemented the support for the 'jcr:path', 'jcr:score', 'jcr:name', 'mode:localName', and 'mode:depth' pseudo-columns. The changes include: 1) Changing the Lucene search engine implementation to support returning data values for these pseudo-columns. This wouldn't have to be done, but it is a bit more complete and does allow using the values in joins. 2) Changing the schemata representation to enable tracking which columns are used when expanding SELECT * clauses. Additionally, the classes were improved to be more efficient; strictly speaking, this optimization did not need to be done, but it simplified the implementation of the required changes, and it also improved the time required to build the schemata from the set of node types. (Whenever node types are added, removed, or changed, the shared schemata is nulled, and needs to be rebuilt the next time the schemata is needed for processing queries. Thus, performance can be important.) 3) Added constants for the Name objects in the JCR and ModeShape lexicons. 4) Added support for getting the pseudo-column values in the JCR QueryResult (and in particular, the Row) implementations. Since these are pseudo-columns, there are no corresponding properties on the nodes, so the values need to be computed using the row's Location and score. 5) Changed the RepositoryQueryManager to use a new query optimization rule that rewrites join criteria and constraints to use the standard JCR functions (e.g., NAME, LOCALNAME, and SCORE) and the ModeShape functions (e.g., PATH and DEPTH). 6) Added several new unit tests for these classes and for various JCR-SQL2 queries. BTW, by using 'jcr:path' and 'jcr:score' for the names (rather than 'mode:path' and 'mode:score'), these changes also add support for these pseudo-columns to the JCR-SQL query language in ModeShape. At this point, all unit and integration tests pass, and ModeShape's support for JCR-SQL2 now handles these pseudo-columns. These changes were committed into SVN trunk with r2343 and into the '2.2.x' branch with r2344.
          Hide
          Randall Hauch
          added a comment -

          Removed some of the code for QueryResults specific to JCR-SQL that was handling the 'jcr:path' and 'jcr:score' values, since JCR-SQL result sets always have these columns. This same logic was now being handled in the base class as part of the pseudo-column functionality, so it was no longer needed. Also added quite a few JCR-SQL test cases that use pseudo-columns.

          All unit and integration tests pass with these changes.

          See 'MODE-934-fix2.patch' for details. Committed into SVN trunk with r2345 and into the '2.2.x' branch with r2346.

          Show
          Randall Hauch
          added a comment - Removed some of the code for QueryResults specific to JCR-SQL that was handling the 'jcr:path' and 'jcr:score' values, since JCR-SQL result sets always have these columns. This same logic was now being handled in the base class as part of the pseudo-column functionality, so it was no longer needed. Also added quite a few JCR-SQL test cases that use pseudo-columns. All unit and integration tests pass with these changes. See ' MODE-934 -fix2.patch' for details. Committed into SVN trunk with r2345 and into the '2.2.x' branch with r2346.
          Hide
          Randall Hauch
          added a comment -

          Updated the Reference Guide's section on the JCR-SQL2 query language to describe the support for the new pseudo-columns, plus added a new example section to showcase some (basic) forms of useful JCR-SQL2 queries.

          See 'MODE-934-fix3.patch' for details. This was committed into SVN trunk with r2349 and into the '2.2.x' branch with r2350.

          Show
          Randall Hauch
          added a comment - Updated the Reference Guide's section on the JCR-SQL2 query language to describe the support for the new pseudo-columns, plus added a new example section to showcase some (basic) forms of useful JCR-SQL2 queries. See ' MODE-934 -fix3.patch' for details. This was committed into SVN trunk with r2349 and into the '2.2.x' branch with r2350.
          Hide
          Randall Hauch
          added a comment -

          I'm going to mark this as resolved, since this feature has been completely implemented and documented, and has been verified through unit tests.

          Show
          Randall Hauch
          added a comment - I'm going to mark this as resolved, since this feature has been completely implemented and documented, and has been verified through unit tests.

            People

            • Assignee:
              Randall Hauch
              Reporter:
              Randall Hauch
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: