[
https://issues.apache.org/jira/browse/DERBY-672?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Rick Hillegas updated DERBY-672:
--------------------------------
Attachment: derby-672-10-af-typeBounds.diff
Attaching derby-672-10-af-typeBounds.diff. This patch implements something akin
to the elegant pattern which Knut suggested in his comment on 2012-07-18. I am
running regression tests now.
With this patch, you can write a single generic Java class:
public class GenericMode<V extends Comparable<V>> implements
Aggregator<V,V,GenericMode<V>> {...}
and bind many type-specific aggregates to it:
create derby aggregate intMode_09 for int external name
'org.apache.derbyTesting.functionTests.tests.lang.GenericMode';
create derby aggregate varcharMode_09 for varchar( 5 ) external name
'org.apache.derbyTesting.functionTests.tests.lang.GenericMode';
create derby aggregate fullNameMode_09 for FullName_09 external name
'org.apache.derbyTesting.functionTests.tests.lang.GenericMode';
To achieve this, I replaced the type inspection code used on the input and
return types of the aggregator. Previously, we were checking for raw types.
With this patch, we are checking that the declared input and return types fit
within the generic aggregator's type bounds.
Touches the following files:
-------------
M
java/engine/org/apache/derby/iapi/services/loader/Java5ClassInspector.java
M java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java
Replaced the tricky discovery of raw types with a simpler scheme for
discovering type bounds.
-------------
M
java/engine/org/apache/derby/impl/sql/compile/UserAggregateDefinition.java
M java/engine/org/apache/derby/loc/messages.xml
Used type bounds rather than raw types to match declared SQL types to
actual Java types.
-------------
M java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
When a type mismatch occurs, report it using the SQL name of the
aggregate rather than its Java name.
-------------
M java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
Bind user-defined types better.
-------------
M
java/testing/org/apache/derbyTesting/functionTests/tests/lang/UserDefinedAggregatesTest.java
Added test cases for generic aggregator classes.
> Re-enable user defined aggregates
> ---------------------------------
>
> Key: DERBY-672
> URL: https://issues.apache.org/jira/browse/DERBY-672
> Project: Derby
> Issue Type: Improvement
> Components: SQL
> Reporter: Rick Hillegas
> Assignee: Rick Hillegas
> Attachments: derby-672-01-aa-ddl.diff,
> derby-672-02-ac-nonDistinct.diff, derby-672-03-aa-distinct.diff,
> derby-672-03-ab-distinct.diff, derby-672-04-aa-fixJSR169test.diff,
> derby-672-05-aa-java7testOrderProblem.diff, derby-672-06-aa-grantRevoke.diff,
> derby-672-07-aa-fixJSR169again.diff, derby-672-08-aa-fixJSR169yetAgain.diff,
> derby-672-09-ab-udtAggregates.diff, derby-672-10-af-typeBounds.diff,
> UserDefinedAggregates.html, UserDefinedAggregates.html
>
>
> Nicolas Dufour in an email thread titled "functions and list" started on
> November 2, 2005 requests the ability to create user defined aggregates.
> This functionality used to be in Cloudscape. It was disabled presumably
> because it was considered non-standard. However, most of the machinery needed
> for this feature is still in the code. We should re-enable user defined
> aggregates after we agree on acceptable syntax.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira