/** * @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); } }
bool findMatch( const char* subject, int length, int startoffset, MatchOptions matchOptions, MemArray<int>& ovector ) const { ASSERT(pcre_callout == pcreCalloutCallback); return pcre_exec(re, NULL, subject, length, startoffset, matchOptions.getOptions()|PCRE_NO_UTF8_CHECK, ovector.getPtr(0), ovector.getLength()) > 0; }
/** * 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(); }
bool findMatch(void* object, CalloutFunction* calloutFunctionX, const char* subject, int length, int startoffset, MatchOptions matchOptions, MemArray<int>& ovector) const { ASSERT(pcre_callout == pcreCalloutCallback); CalloutData calloutData; calloutData.object = object; calloutData.calloutFunction = calloutFunctionX; pcre_extra extra; extra.flags = PCRE_EXTRA_CALLOUT_DATA; extra.callout_data = &calloutData; bool rslt = pcre_exec(re, &extra, subject, length, startoffset, matchOptions.getOptions()|PCRE_NO_UTF8_CHECK, ovector.getPtr(0), ovector.getLength()) > 0; return rslt; }
/** * 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); }
bool operator==(const MemArray<T>& rhs) const { return (getLength() == rhs.getLength() && memcmp(getPtr(0), rhs.getPtr(0), getLength() * sizeof(T)) == 0); }