/** * @brief Insert data from a map to an array. * * @param[in] query * @param[inout] array the array to receive data * @param[in] m the map of Coordinate --> Value */ void insertMapDataIntoArray( std::shared_ptr<Query>& query, MemArray& array, CoordValueMap const& m) { Coordinates coord(1); coord[0] = 0; vector< std::shared_ptr<ArrayIterator> > arrayIters(array.getArrayDesc().getAttributes(true).size()); vector< std::shared_ptr<ChunkIterator> > chunkIters(arrayIters.size()); for (size_t i = 0; i < arrayIters.size(); i++) { arrayIters[i] = array.getIterator(i); chunkIters[i] = ((MemChunk&)arrayIters[i]->newChunk(coord)).getIterator( query, ChunkIterator::SEQUENTIAL_WRITE); } BOOST_FOREACH(CoordValueMapEntry const& p, m) { coord[0] = p.first; for (size_t i = 0; i < chunkIters.size(); i++) { if (!chunkIters[i]->setPosition(coord)) { chunkIters[i]->flush(); chunkIters[i].reset(); chunkIters[i] = ((MemChunk&)arrayIters[i]->newChunk(coord)).getIterator( query, ChunkIterator::SEQUENTIAL_WRITE); chunkIters[i]->setPosition(coord); } chunkIters[i]->writeItem(p.second); } }
/** * Build array chunk with indicated number of random values of the specified type, using indicated * iteration mode. * @param[in] query * @param[inout] array the array to receive data * @param[in] type the type of values to put into the chunk * @param[in] count the number of values to put into the chunk * @param[in] mode the iteration mode for the chunk iterator */ void buildRandomArrayChunk(std::shared_ptr<Query>& query, MemArray& array, TypeId type, int count, int mode) { Coordinates coord(1); coord[0] = 0; std::shared_ptr<ArrayIterator> arrayIter = array.getIterator(0); std::shared_ptr<ChunkIterator> chunkIter = ((MemChunk&)arrayIter->newChunk(coord)).getIterator(query, mode); if (!chunkIter->setPosition(coord)) { throw SYSTEM_EXCEPTION(SCIDB_SE_INTERNAL, SCIDB_LE_UNITTEST_FAILED) << "UnitTestChunkLimit" << "Failed to set position in chunk"; } for (int j = 0; j < count; j++) { Value v; genRandomValue(type, v, 0, static_cast<Value::reason>(0)); chunkIter->writeItem(v); ++(*chunkIter); } chunkIter->flush(); }
/** * Insert data from a map to an array. * @param[in] query * @param[inout] array the array to receive data * @param[in] m the map of Coordinate --> Value * @param[in] whetherAttachBitmap whether the bitmap itself should be attached to the end of the data chunk */ void insertMapDataIntoArray(shared_ptr<Query>& query, MemArray& array, CoordValueMap const& m, bool whetherAttachBitmap) { shared_ptr<ArrayIterator> arrayIter = array.getIterator(0); Coordinates coord(1), coordZero(1); coordZero[0] = 0; MemChunk& chunk = (MemChunk&)arrayIter->newChunk(coordZero); shared_ptr<ChunkIterator> chunkIter = chunk.getIterator(query, ChunkIterator::SEQUENTIAL_WRITE); BOOST_FOREACH(CoordValueMapEntry const& p, m) { coord[0] = p.first; chunkIter->setPosition(coord); chunkIter->writeItem(p.second); }