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

Reply via email to