Why to RandomAccess and why to redistribute?


#1

Hi, there!
in scidb::PhysicalCrossJoin::execute(src\query\ops\cross_join\PhysicalCrossJoin.cpp)
There is a function called "redistributeToRandomAccess"
std::shared_ptr replicated = redistributeToRandomAccess(input1, query, psReplication,
ALL_INSTANCE_MASK,
std::shared_ptr(),
0,
std::shared_ptr());
I want to know how redistributeToRandomAccess works? Why to RandomAccess and why to redistribute? Thank you!

 std::shared_ptr<Array> execute(
            vector< std::shared_ptr<Array> >& inputArrays,
            std::shared_ptr<Query> query)
    {
        assert(inputArrays.size() == 2);

        std::shared_ptr<Array> input1 = inputArrays[1];
        if (query->getInstancesCount() == 1 )
        {
            input1 = ensureRandomAccess(input1, query);
        }

        size_t lDimsSize = inputArrays[0]->getArrayDesc().getDimensions().size();
        size_t rDimsSize = inputArrays[1]->getArrayDesc().getDimensions().size();

        vector<int> ljd(lDimsSize, -1);
        vector<int> rjd(rDimsSize, -1);

        for (size_t p = 0, np = _parameters.size(); p < np; p += 2)
        {
            const std::shared_ptr<OperatorParamDimensionReference> &lDim =
                (std::shared_ptr<OperatorParamDimensionReference>&)_parameters[p];
            const std::shared_ptr<OperatorParamDimensionReference> &rDim =
                (std::shared_ptr<OperatorParamDimensionReference>&)_parameters[p+1];

            rjd[rDim->getObjectNo()] = lDim->getObjectNo();
        }

        size_t k=0;
        for (size_t i = 0; i < rjd.size(); i++)
        {
            if (rjd[i] != -1)
            {
                ljd [ rjd[i] ] = k;
                k++;
            }
        }
        std::shared_ptr<Array> replicated = redistributeToRandomAccess(input1, query, psReplication,
                                                                  ALL_INSTANCE_MASK,
                                                                  std::shared_ptr<CoordinateTranslator>(),
                                                                  0,
                                                                  std::shared_ptr<PartitioningSchemaData>());
        return make_shared<CrossJoinArray>(_schema, inputArrays[0],
                                           replicated,
                                           ljd, rjd);
    }