db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Nielsen (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (DERBY-2998) Add support for ROW_NUMBER() window function
Date Mon, 22 Oct 2007 13:50:51 GMT

    [ https://issues.apache.org/jira/browse/DERBY-2998?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12536670
] 

thomanie edited comment on DERBY-2998 at 10/22/07 6:49 AM:
-----------------------------------------------------------------

Here's how it seems to work for indexes for the following simple query on table t where column
a is the primary key.

   select * from t where a <= 2;

During parsing we add a CursorNode and an IndexToBaseRowNode to the QueryTree since we have
an index on 'a'.
Based on the IndexToBaseRowNode we create the accompanying IndexRowToBaseRowResultSet and
feed any restrictions to its constructor. 
In my case the restriction is generated code for '<='.

On opening the IndexRowToBaseRowResultSet we also call its "source" .openCore() method BulkTableScanResultSet.openCore().
BulkTableScanResultSet does just that, it reads a base table or an index in bulk (chunks)
from Store.

The execution then does a do-while loop that calls .getNextRowCore(). For each pass it invokes
the restriction code it got in its constructor by restriction.invoke(). In my case this ends
up invoking SQLInteger.lessOrEqual(). The do-while loop exits once the restriction is met.

The key seems to be the three calls to openCore(), getNextRowCore() and closeCore(), and overrides
of these in the ResultSet subclasses.

      was (Author: thomanie):
    Here's how it seems to work for indexes for the following simple query on table t where
column a is the primary key.

   select * from t where a <= 2;

During parsing we add a CursorNode and an IndexToBaseRowNode to the QueryTree since we have
an index on 'a'.
Based on the IndexToBaseRowNode we create the accompanying IndexRowToBaseRowResultSet and
feed any restrictions to its constructor. 
In my case the restriction is generated code for '<='.

On opening the IndexRowToBaseRowResultSet we also call its "source" .openCore() method BulkTableScanResultSet.openCore().
BulkTableScanResultSet does just that, it reads a base table or an index in bulk (chunks)
from Store.

The execution then does a do-while loop that calls .getNextRowCore(). For each pass it invokes
the restriction code it got its the constructor with restriction.invoke(). In my case this
ends up invoking SQLInteger.lessOrEqual(). The do-while loop exits once the restriction is
met.

The key seems to be the three calls to openCore(), getNextRowCore() and closeCore(), and overrides
of these in the ResultSet subclasses.
  
> Add support for ROW_NUMBER() window function
> --------------------------------------------
>
>                 Key: DERBY-2998
>                 URL: https://issues.apache.org/jira/browse/DERBY-2998
>             Project: Derby
>          Issue Type: Sub-task
>          Components: SQL
>            Reporter: Thomas Nielsen
>            Assignee: Thomas Nielsen
>            Priority: Minor
>         Attachments: row_number_prototype-2c.diff, row_number_prototype-2c.stat
>
>
> As part of implementing the overall OLAP Operations features of SQL (DERBY-581), implement
the ROW_NUMBER() window function.
> More information about this feature is available at http://wiki.apache.org/db-derby/OLAPRowNumber

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message