...
The interface "Aggregator" is descibed described in details in the later section of the document (UDA).
...
E.g.:
select avg( col2) from /portfolio // portfolio Valid
select col1, avg ( col2) from /portfolio portfolio (col1 should not be present in projection attributes) // invalid
Query Types & implementation:
...
Note: As a first cut , we will make it mandatory for the group by column to be part of projection attribute ( Will see if we can make implement in a reasonable period the code to relax this constraint. i.e group by columns not be part of projection columns)
Proposed Syntax for using UDA:
Creation of UDA
Using API:
...
qs.createUDA(“udaAlias”, "com.gemstone.gemfire.cache.query.dunit.UDACreationDUnitTest$SumUDA");
XML based creation:
<uda-manager>
...
<uda
...
name="uda2"
...
class="com.gemstone.gemfire.cache.query.dunit.UDACreationDUnitTest$UDACLass2"/>
...
<uda
...
name="uda3"
...
class="com.gemstone.gemfire.cache.query.dunit.UDACreationDUnitTest$UDACLass3"/>
</uda-manager>
cache-9.0
...
xsd
<xsd:element
...
maxOccurs="1"
...
minOccurs="0"
...
name="uda-manager">
<xsd:complexType>
<xsd:sequence>
<xsd:element
...
maxOccurs="unbounded"
...
minOccurs="0"
...
name="uda">
<xsd:complexType>
<xsd:attribute
...
name="name"
...
type="xsd:string"
...
use="required"
...
/>
<xsd:attribute name="class" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Example of using UDA , after defining:
...
element>
Using UDA in Query:
String queryStr = "select p.status , myUDA(p.ID) from /portfolio p where p.ID > 0 group by p.status order by p.status";
This will require us to maintain a registry of the aggregate functions defined & will also have to ensure that it gets created on newly joining nodes.We piggy back on the infra through which the OQL indexes get created on the peers & I assume that we can also create on newly joining nodes.
UDA Schema exchange:
The UDA schema/definitions are exchanged between cluster nodes via profile exchange mechanism.