You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@madlib.apache.org by Harald Bögeholz <ha...@monash.edu> on 2017/04/12 05:24:07 UTC
understanding hello_world module example
Dear MADlib community,
I would like to implement a graph algorithm in the MADlib framework and
was studying the hello_world example
https://cwiki.apache.org/confluence/display/MADLIB/Quick+Start+Guide+for+Developers
I understand that a double array is used as the state type for the user
defined aggregrate for performance reasons although its third element
(numRows) is actually a 64 bit integer.
My question is about the operator+= for merging with another state
object defined in examples/hello_world/non-iterative/avg_var.cpp. It
begins like this:
template <class OtherHandle>
AvgVarTransitionState &operator+=(
const AvgVarTransitionState<OtherHandle> &inOtherState) {
if (mStorage.size() != inOtherState.mStorage.size())
throw std::logic_error("Internal error: Incompatible
transition "
"states");
double avg_ = inOtherState.avg;
double var_ = inOtherState.var;
uint16_t numRows_ = static_cast<uint16_t>(inOtherState.numRows);
double totalNumRows = static_cast<double>(numRows + numRows_);
Why is inOtherState.numRows being typecast to uint16_t here? Shouldn't
it be uint64_t?
I'd like to know if this is some magic I need to understand or simply a bug.
Thanks for any advice
Harald B�geholz
Re: understanding hello_world module example
Posted by Rahul Iyer <ri...@apache.org>.
> Why is inOtherState.numRows being typecast to uint16_t here? Shouldn't
> it be uint64_t?
>
> I'd like to know if this is some magic I need to understand or simply a bug.
That's a bug. Thanks for pointing it out.