Best way to extract all attributes per chunk


#1

Quick question:
In a multi-attribute array, what is the best way to extract all attributes one chunk at a time before moving to the next chunk when reading in an array inside a UDO? I don’t seem to find an easy way to do that using ConstArrayIterator.

Thanks,
-Hamid


#2

Hi Hamid,

Just create a vector of ConstArrayIterator and ConstChunkIterator objects. Approximately like this:

vector<shared_ptr<ConstArrayIterator> > srcArrayIterators (nAttrs);
vector<shared_ptr<ConstChunkIterator> > srcChunkIterators (nAttrs);
for (size_t i = 0; i < nAttrs; i++)
{
    srcArrayIterators[i] = srcArray->getConstIterator(i);
} 
while (!srcArrayIterators[0]->end())
{
    for(size_t i = 0; i < nAttrs; i++)
    {
        srcChunkIterators[i] = srcArrayIterators[i]->getChunk().getConstIterator(...
    }
    while (!srcChunkIterators[0]->end())
    {
        //...
        for (size_t i=0;  i <  nAttrs; i++)
        {
             ++(*srcChunkIterators[i]);
        }
    }
    for (size_t i=0;  i <  nAttrs; i++)
    {
         ++(*srcArrayIterators[i]);
    }
}

There isn’t a more elegant solution at the moment. Also note nAttrs was set carefully - you usually don’t need to iterate over the empty tag (last attribute).


#3

Alex,
Thanks. I will try your suggestion.

-Hamid