Hi Jody,

You're right, the expected output of a GroupBy + Aggregate function is a
list of results. Consider the following example data:

---------------------------------------
| Building Type | Consumption | (...) |
---------------------------------------
| School        | 15.0        |       |
---------------------------------------
| School        | 20.0        |       |
---------------------------------------
| House         | 5.0         |       |
---------------------------------------
| House         | 10.0        |       |
---------------------------------------
| Hospital      | 40.0        |       |
---------------------------------------
| Hospital      | 50.0        |       |
---------------------------------------

As a use case: I want to know the maximum electrical consumption by
building type.

The result should be something like this: [(School, 20.0), (House, 10.0),
(Hospital, 50.0)]

Sorry but I'm not sure how to interpret your feedback: you're telling me
that I should not implement a GroupBy visitor or extend
the current aggregate visitors but instead implement the "group by"
behavior using a series of FeatureCollections or are you give-me
advises about how to implement the GroupBy visitor?

Regarding the first idea: 1) FeatureCollection using GroupBy is similar to
a series of FeatureCollections

Yes is true, the problem is that to build the series of FeatureCollections
I would need to know at the beginning all the existing groups which is not
the case.

Regards,

Nuno Oliveira

2016-02-10 22:42 GMT+00:00 Jody Garnett <jody.garn...@gmail.com>:

> I assume what you want out of a GroupBy + Aggregate function is a list of
> results.
>
> Working with these two ideas:
>
> 1) FeatureCollection using GroupBy is similar to a series of
> FeatureCollections
> 2) Each of the core visitors should be isolating its state into a result
> (this was done so we could go parallel). The results have methods to
> combine two answers, and should also have a copy constructor.
>
> With that in mind we should be able to "reset" the result and the end of
> each group (using a copy constructor or simply a new result).
>
> The above probably only helps for the ContentDataStore superclass, but
> that should get you most of the implementations sorted.
>
> Notes:
> - I tend to prefer copy constructors to clonable, we have some trouble
> with this when duplicating styles / filters / expressions.
>
>
>
>
>
> --
> Jody Garnett
>
> On 8 February 2016 at 01:21, Andrea Aime <andrea.a...@geo-solutions.it>
> wrote:
>
>> Forwarding this one on behalf of Nuno, that is having problems sending
>> this mail directly
>>
>> Cheers
>> Andrea
>>
>> ---------- Forwarded message ----------
>> From: Nuno Miguel Carvalho Oliveira <nmco51...@gmail.com>
>> Date: Fri, Feb 5, 2016 at 6:44 PM
>> Subject: Adding "group by" support to the current aggregation visitors
>> To: geotools-devel@lists.sourceforge.net
>>
>>
>> Hi,
>>
>>
>> The current aggregation visitors (AverageVisitor, CountVisitor,
>> MaxVisitor, MedianVisitor, MinVisitor, StandardDeviationVisitor and
>> SumVisitor) don’t support a “group by” behavior. For example, we are able
>> to compute the average electrical consumption per building. But we are not
>> able to ask the average electrical consumption per building type.
>>
>>
>> We have came up with three solutions to implement this behavior but none
>> of them is perfect.
>>
>>
>> The most straightforward solution would be adding the list of “group by”
>> attributes to each current aggregator visitor implementation. But this will
>> break backward compatibility with custom store implementations that we are
>> not aware of. This solution will also make the current visitors
>> unnecessarily more complex, each of them will need to know how to handle
>> the “group by” behavior (this can also lead to some code duplication).
>>
>>
>> Another solution is to implement  a “group by” visitor that will receive
>> an aggregation visitor as a prototype (basically a visitor that will be
>> cloned) and a list of “group by” attributes. The current visitors have in
>> common the FeatureVisitor interface which is not cloneable. In Java 8 we
>> could make the FeatureVisitor extends Cloneable interface and implement a
>> default method, but this will not work in GeoServer 2.8.x. So if we extend
>> the FeatureVisitor to support Cloneable behavior we are breaking backward
>> compatibility. An (awful) solution for this could be implement the
>> Cloneable interface in every existing visitor and in the “group by” visitor
>> do an “instanceof” checking if the visitor is cloneable. If the visitor is
>> not cloneable we could throw an exception or (let's be crazy) do a deep
>> serialization copy.
>>
>>
>> Another solution is to implement  a “group by” visitor that will receive
>> an aggregation visitor name (this would be an Enum), the name of the
>> attribute that should be used by the aggregation visitor and a list of
>> “group by” attributes. The “group by” visitor will be responsible to
>> instantiate the aggregation visitor using the attribute name. The drawback
>> of this solution is that the list of supported aggregation visitors will be
>> an Enum, which will kill pluggability. So if someone wants to use a new
>> aggregation visitor with the “group by” visitor the implementation needs to
>> be updated.
>>
>>
>> We will also extend the JDBCDataStore current support for aggregation
>> functions to support the "group by" clause.
>>
>>
>> Any feedback on this will be highly appreciated.
>>
>>
>> Regards,
>>
>>
>> Nuno Oliveira
>>
>> --
>> ==
>> GeoServer Professional Services from the experts!
>> Visit http://goo.gl/it488V for more information.
>> ==
>> Nuno Miguel Carvalho Oliveira
>> @nmcoliveira
>> Software Engineer
>>
>> GeoSolutions S.A.S.
>> Via Poggio alle Viti 1187
>> 55054  Massarosa (LU)
>> Italy
>> phone: +39 0584 962313
>> fax:   +39 0584 1660272
>> mob:   +39  333 8128928
>> http://www.geo-solutions.ithttp://twitter.com/geosolutions_it
>>
>> -------------------------------------------------------
>>
>> AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
>> Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i 
>> file/s allegato/i sono
>> da considerarsi strettamente riservate. Il loro utilizzo è consentito 
>> esclusivamente al destinatario del messaggio, per le finalità indicate
>> nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il 
>> destinatario, Vi preghiamo cortesemente di darcene notizia via e
>> -mail e di procedere alla distruzione del messaggio stesso, cancellandolo 
>> dal Vostro sistema. Conservare il messaggio stesso, divulgarlo
>> anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per 
>> finalità diverse, costituisce comportamento contrario ai
>> principi dettati dal D.Lgs. 196/2003.
>>
>> The information in this message and/or attachments, is intended solely for 
>> the attention and use of
>> the named addressee(s) and may be confidential or proprietary in nature or 
>> covered by the provisions of privacy act (Legislative Decree
>> June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in 
>> accord with its purpose, any disclosure, reproduction, copying,
>> distribution, or either dissemination, either whole or partial, is strictly 
>> forbidden except previous formal approval of the named
>> addressee(s). If you are not the intended recipient, please contact 
>> immediately the sender by telephone, fax or e-mail and delete the
>> information in this message that has been received in error. The sender does 
>> not give any warranty or accept liability as the content,
>> accuracy or completeness of sent messages and accepts no responsibility  for 
>> changes made after they were sent or for other risks which
>> arise as a result of e-mail transmission, viruses, etc.
>>
>>
>>
>>
>> --
>> ==
>> GeoServer Professional Services from the experts! Visit
>> http://goo.gl/it488V for more information.
>> ==
>>
>> Ing. Andrea Aime
>> @geowolf
>> Technical Lead
>>
>> GeoSolutions S.A.S.
>> Via Poggio alle Viti 1187
>> 55054  Massarosa (LU)
>> Italy
>> phone: +39 0584 962313
>> fax: +39 0584 1660272
>> mob: +39  339 8844549
>>
>> http://www.geo-solutions.it
>> http://twitter.com/geosolutions_it
>>
>> *AVVERTENZE AI SENSI DEL D.Lgs. 196/2003*
>>
>> Le informazioni contenute in questo messaggio di posta elettronica e/o
>> nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
>> loro utilizzo è consentito esclusivamente al destinatario del messaggio,
>> per le finalità indicate nel messaggio stesso. Qualora riceviate questo
>> messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
>> darcene notizia via e-mail e di procedere alla distruzione del messaggio
>> stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
>> divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
>> utilizzarlo per finalità diverse, costituisce comportamento contrario ai
>> principi dettati dal D.Lgs. 196/2003.
>>
>>
>>
>> The information in this message and/or attachments, is intended solely
>> for the attention and use of the named addressee(s) and may be confidential
>> or proprietary in nature or covered by the provisions of privacy act
>> (Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
>> Code).Any use not in accord with its purpose, any disclosure, reproduction,
>> copying, distribution, or either dissemination, either whole or partial, is
>> strictly forbidden except previous formal approval of the named
>> addressee(s). If you are not the intended recipient, please contact
>> immediately the sender by telephone, fax or e-mail and delete the
>> information in this message that has been received in error. The sender
>> does not give any warranty or accept liability as the content, accuracy or
>> completeness of sent messages and accepts no responsibility  for changes
>> made after they were sent or for other risks which arise as a result of
>> e-mail transmission, viruses, etc.
>>
>> -------------------------------------------------------
>>
>>
>> ------------------------------------------------------------------------------
>> Site24x7 APM Insight: Get Deep Visibility into Application Performance
>> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
>> Monitor end-to-end web transactions and take corrective actions now
>> Troubleshoot faster and improve end-user experience. Signup Now!
>> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
>> _______________________________________________
>> GeoTools-Devel mailing list
>> GeoTools-Devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>>
>>
>
>
> ------------------------------------------------------------------------------
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
> _______________________________________________
> GeoTools-Devel mailing list
> GeoTools-Devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>
>
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to