ECL_H3_API void ECL_H3_CALL polyfill(ICodeContext *_ctx, bool &__isAllResult, size32_t &__lenResult, void *&__result, size32_t countBoundary, const byte **boundary, uint32_t resolution) { // Check for special case when points exceed 180 degrees (longtitude) // - https://github.com/uber/h3/issues/210 GeoCoord *poly = static_cast<GeoCoord *>(rtlCalloc(countBoundary, sizeof(GeoCoord))); GeoCoord *wPoly = static_cast<GeoCoord *>(rtlCalloc(countBoundary, sizeof(GeoCoord))); GeoCoord *ePoly = static_cast<GeoCoord *>(rtlCalloc(countBoundary, sizeof(GeoCoord))); double west = 0; double east = 0; for (int i = 0; i < countBoundary; ++i) { const GeoCoord *row = (GeoCoord *)boundary[i]; double lat = ::degsToRads(row->lat); double lon = ::degsToRads(row->lon); poly[i].lat = lat; poly[i].lon = lon; wPoly[i].lat = lat; wPoly[i].lon = lon > 0 ? 0 : lon; ePoly[i].lat = lat; ePoly[i].lon = lon <= 0 ? 0 : lon; if (i == 0) west = east = row->lon; else if (west > row->lon) west = lon; else if (east < row->lon) east = lon; } if (east - west >= 180) { GeoPolygon wPolygon, ePolygon; int wMaxBuff = initPolygon(wPoly, countBoundary, resolution, wPolygon); int eMaxBuff = initPolygon(ePoly, countBoundary, resolution, ePolygon); H3Index *buff = static_cast<H3Index *>(rtlCalloc(wMaxBuff + eMaxBuff, sizeof(H3Index))); ::polyfill(&wPolygon, resolution, buff); ::polyfill(&ePolygon, resolution, buff + wMaxBuff); toSetOf(__isAllResult, __lenResult, __result, buff, wMaxBuff + eMaxBuff); } else { GeoPolygon polygon; int maxBuff = initPolygon(poly, countBoundary, resolution, polygon); H3Index *buff = static_cast<H3Index *>(rtlCalloc(maxBuff, sizeof(H3Index))); ::polyfill(&polygon, resolution, buff); toSetOf(__isAllResult, __lenResult, __result, buff, maxBuff); } rtlFree(ePoly); rtlFree(wPoly); rtlFree(poly); }
virtual void kill() { CSlaveActivity::kill(); xmlParser.clear(); if (searchStr && helper->searchTextNeedsFree()) rtlFree(searchStr); }
// Regions --- ECL_H3_API void ECL_H3_CALL polyfill(ICodeContext *_ctx, bool &__isAllResult, size32_t &__lenResult, void *&__result, size32_t countBoundary, const byte **boundary, uint32_t resolution) { GeoCoord *verts = static_cast<GeoCoord *>(rtlCalloc(countBoundary, sizeof(GeoCoord))); for (int i = 0; i < countBoundary; ++i) { GeoCoord *row = (GeoCoord *)boundary[i]; verts[i].lat = ::degsToRads(row->lat); verts[i].lon = ::degsToRads(row->lon); } Geofence geofence; geofence.numVerts = countBoundary; geofence.verts = verts; GeoPolygon polygon; polygon.geofence = geofence; polygon.numHoles = 0; int maxBuff = ::maxPolyfillSize(&polygon, resolution); H3Index *buff = static_cast<H3Index *>(rtlCalloc(maxBuff, sizeof(H3Index))); ::polyfill(&polygon, resolution, buff); toSetOf(__isAllResult, __lenResult, __result, buff, maxBuff); rtlFree(verts); }
void CSVOutputStream::writeUnicode(size32_t len, const UChar * data) { unsigned utf8Length; char * utf8Data = NULL; rtlUnicodeToCodepageX(utf8Length, utf8Data, len, data, "utf-8"); writeString(utf8Length, utf8Data); rtlFree(utf8Data); }
void processRecord(const void * in) { if (helper->searchTextNeedsFree()) rtlFree(curSearchText); curSearchTextLen = 0; curSearchText = NULL; helper->getSearchText(curSearchTextLen, curSearchText, in); parser->performMatch(*this, in, curSearchTextLen, curSearchText); }
~MySQLBindingArray() { for (int i = 0; i < columns; i++) { rtlFree(bindinfo[i].buffer); } delete [] bindinfo; delete [] is_null; delete [] error; delete [] lengths; }
void buildLayoutMetadata(Owned<IPropertyTree> & metadata) { if(!metadata) metadata.setown(createPTree("metadata")); metadata->setProp("_record_ECL", helper->queryRecordECL()); void * layoutMetaBuff; size32_t layoutMetaSize; if(helper->getIndexLayout(layoutMetaSize, layoutMetaBuff)) { metadata->setPropBin("_record_layout", layoutMetaSize, layoutMetaBuff); rtlFree(layoutMetaBuff); } }
ECLBLAS_CALL void dpotf2(bool & __isAllResult, size32_t & __lenResult, void * & __result, uint8_t tri, uint32_t r, bool isAllA, size32_t lenA, const void * A, bool clear) { unsigned int cells = r*r; __isAllResult = false; __lenResult = cells * sizeof(double); double *new_a = (double*) rtlMalloc(__lenResult); memcpy(new_a, A, __lenResult); double ajj; // x and y refer to the embedded vectors for the multiply, not an axis unsigned int diag, a_pos, x_pos, y_pos; unsigned int col_step = r; // between columns unsigned int row_step = 1; // between rows unsigned int x_step = (tri==UPPER_TRIANGLE) ? row_step : col_step; unsigned int y_step = (tri==UPPER_TRIANGLE) ? col_step : row_step; for (unsigned int j=0; j<r; j++) { diag = (j * r) + j; // diagonal x_pos = j * ((tri==UPPER_TRIANGLE) ? col_step : row_step); a_pos = (j+1) * ((tri==UPPER_TRIANGLE) ? col_step : row_step); y_pos = diag + y_step; // ddot.value <- x'*y ajj = new_a[diag] - cblas_ddot(j, (new_a+x_pos), x_step, (new_a+x_pos), x_step); //if ajj is 0, negative or NaN, then error if (ajj <= 0.0) { rtlFree(new_a); rtlFail(0, "Not a positive definite matrix"); } ajj = sqrt(ajj); new_a[diag] = ajj; if ( j < r-1) { // y <- alpha*op(A)*x + beta*y cblas_dgemv(CblasColMajor, (tri==UPPER_TRIANGLE) ? CblasTrans : CblasNoTrans, (tri==UPPER_TRIANGLE) ? j : r-1-j, // M (tri==UPPER_TRIANGLE) ? r-1-j : j, // N -1.0, // alpha (new_a+a_pos), r, //A (new_a+x_pos), x_step, //X 1.0, (new_a+y_pos), y_step); // beta and Y // x <- alpha * x cblas_dscal(r-1-j, 1.0/ajj, (new_a+y_pos), y_step); } // clear lower or upper part if clear flag set for(unsigned int k=1; clear && k<r-j; k++) new_a[(k*x_step)+diag] = 0.0; } __result = (void*) new_a; }
static void createBindBuffer(MYSQL_BIND & bindInfo, enum_field_types sqlType, unsigned size) { if (size) { if (!bindInfo.buffer) { bindInfo.buffer_type = sqlType; bindInfo.buffer = rtlMalloc(size); } else assertex(bindInfo.buffer_type == sqlType); } else { // Buffer is reallocated each time - caller is responsible for it. bindInfo.buffer_type = sqlType; rtlFree(bindInfo.buffer); bindInfo.buffer = NULL; } }
void SimplePluginCtx::ctxFree(void * _ptr) { rtlFree(_ptr); }
CATCH_NEXTROW() { ActivityTimer t(totalCycles, timeActivities); if (abortSoon) return NULL; if (eogNext) { eogNext = false; anyThisGroup = false; return NULL; } try { for (;;) { if (xmlParser) { for (;;) { if (!xmlParser->next()) { if (helper->searchTextNeedsFree()) { rtlFree(searchStr); searchStr = NULL; } xmlParser.clear(); break; } if (lastMatch) { RtlDynamicRowBuilder row(allocator); size32_t sizeGot; try { sizeGot = helper->transform(row, nxt, lastMatch); } catch (IException *e) { ActPrintLog(e, "In helper->transform()"); throw; } lastMatch.clear(); if (sizeGot == 0) continue; // not sure if this will ever be possible in this context. dataLinkIncrement(); anyThisGroup = true; OwnedConstThorRow ret = row.finalizeRowClear(sizeGot); return ret.getClear(); } } } nxt.setown(inputStream->nextRow()); if (!nxt && !anyThisGroup) nxt.setown(inputStream->nextRow()); if (!nxt) break; unsigned len; helper->getSearchText(len, searchStr, nxt); OwnedRoxieString xmlIteratorPath(helper->getXmlIteratorPath()); xmlParser.setown(createXMLParse(searchStr, len, xmlIteratorPath, *this, ptr_noRoot, helper->requiresContents())); } } catch (IOutOfMemException *e) { StringBuffer s("XMLParse actId("); s.append(container.queryId()).append(") out of memory.").newline(); s.append("INTERNAL ERROR ").append(e->errorCode()).append(": "); e->errorMessage(s); e->Release(); throw MakeActivityException(this, 0, "%s", s.str()); } catch (IException *e) { StringBuffer s("XMLParse actId("); s.append(container.queryId()); s.append(") INTERNAL ERROR ").append(e->errorCode()).append(": "); e->errorMessage(s); e->Release(); throw MakeActivityException(this, 0, "%s", s.str()); } eogNext = false; anyThisGroup = false; return NULL; }
inline void clear() { rtlFree(ptr); ptr = NULL; }
inline ~rtlDataAttr() { rtlFree(ptr); }
inline void setown(void * _ptr) { rtlFree(ptr); ptr = _ptr; }