cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Kudryavtsev <kudryavtsev...@bw-sw.com>
Subject Re: How to achieve SUM (N * M) with ACS DAO
Date Wed, 10 Jan 2018 12:45:18 GMT
Hmmm, I don't think the math works that way, multiplication and sum are not
same order operations. Right now the only way I found is to fetch all rows
with required fields from db and do computation in the code, but it doesn't
look efficient though.

10 янв. 2018 г. 19:41 пользователь "Marc-Aurèle Brothier" <marco@exoscale.ch>
написал:

Hmm, yeah that's what I realized after sending the email. With the DAO, you
can only apply function on a single column / entity attribute, therefore it
won't be possible as you want. Another way to achieve this would be to do
SELECT SUM(A), SUM(B) FROM T with the DAO, and on the Java side do the
multiplication. Woud that work for your use-case?


On Wed, Jan 10, 2018 at 1:27 PM, Ivan Kudryavtsev <kudryavtsev_ia@bw-sw.com>
wrote:

> Hello, Marc-Aurele, thank you for the snippet, but it looks like the sum
> usage everywhere in the codebase. It's aggregation over single field. What
> I need is to pass multuplication of two fields (cores x speed) inside the
> sum, but I don't understand how to do it with dao... Thank you.
>
> 10 янв. 2018 г. 19:12 пользователь "Marc-Aurèle Brothier" <
> marco@exoscale.ch>
> написал:
>
> > Have a look here:
> > https://github.com/apache/cloudstack/blob/master/engine/
> > schema/src/com/cloud/storage/dao/VolumeDaoImpl.java#L347
> >
> > Or you can search other example in the code base with this string
> > "Func.SUM": thttps://
> > github.com/apache/cloudstack/blob/master/engine/schema/src/
> > com/cloud/storage/dao/VolumeDaoImpl.java#L347
> >
> > On Wed, Jan 10, 2018 at 9:42 AM, Ivan Kudryavtsev <
> > kudryavtsev_ia@bw-sw.com>
> > wrote:
> >
> > > Hello, colleagues, please could anyone guide me how to implement
> > > aggregation SUM over two fields multiplication? Many thanks in
advance.
> > >
> > > I'm trying to achieve:
> > > SELECT SUM(A * B) FROM T with DAO
> > >
> > >
> > >
> > > --
> > > With best regards, Ivan Kudryavtsev
> > > Bitworks Software, Ltd.
> > > Cell: +7-923-414-1515
> > > WWW: http://bitworks.software/ <http://bw-sw.com/>
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message