Writing a chunk to an array


#1

Hello,

I’m having trouble putting chunks into an array.
I’ve created an array using:

It is a one-attribute array.

Is this a reasonable approach? I ask since I keep getting a segfault during the write, so I wanted to double-check. I haven’t ruled out my own faulty code that is supposed to fill the chunk.

The array I am writing to has dimensions and attributes as follows:

Does anything seem obviously wrong?

Thanks for your help,
-Daniel


#2

Hello, Daniel.

I’m not the authority on the storage pathway and I’ve forwarded this to the right developer.

In the meantime, the best pattern to look at is the one inside the store operator.

PhysicalStore.cpp says:

                    ConstChunk const& srcChunk = srcArrayIterators[i]->getChunk();
                    Coordinates const& first = srcChunk.getFirstPosition(false);
                    Coordinates const& last = srcChunk.getLastPosition(false);
                    for (size_t j = 0; j < nDims; j++) { 
                        if (last[j] > highBoundary[j]) { 
                            highBoundary[j] = last[j];
                        }
                        if (first[j] < lowBoundary[j]) { 
                            lowBoundary[j] = first[j];
                        }
                    }
                    dstArrayIterators[i]->copyChunk(srcChunk);
                    for (size_t j = step; j != 0 && !srcArrayIterators[i]->end(); ++(*srcArrayIterators[i]), --j);

And it looks like there’s some magic inside copyChunk having to do with the disk chunk versus memory chunk distinction. From Storage.cpp:

    void LocalStorage::DBArrayIterator::copyChunk(ConstChunk const& srcChunk) 
    {
        if (version > 1) { // first version of delta-array should always be allocated - not cloned
            addr.coords = srcChunk.getFirstPosition(false);
            if (storage->patchChunk(addr, srcChunk)) {
                return;
            }
        } else if (version == 0) {   
            DBChunk const* diskChunk = srcChunk.getDiskChunk();
            if (diskChunk != NULL) { 
                AttributeDesc const& srcAttrDesc = diskChunk->getAttributeDesc();
                if (srcAttrDesc.getReserve() == 0 && attrDesc.isNullable() == srcAttrDesc.isNullable()) { 
                    addr.coords = srcChunk.getFirstPosition(false);
                    if (storage->cloneChunk(addr, *diskChunk)) { 
                        return;
                    }
                }
            }
        }
        ArrayIterator::copyChunk(srcChunk);
    }

Hopefully our storage specialist will reply soon as well.


#3

This is what Konstantin, our storage guru had to add: