예제 #1
0
 void bindResults(MYSQL_RES *res)
 {
     init(mysql_num_fields(res));
     for (int i = 0; i < columns; i++)
     {
         MYSQL_FIELD *col = mysql_fetch_field_direct(res, i);
         switch (col->type)
         {
         case MYSQL_TYPE_DECIMAL:
         case MYSQL_TYPE_NEWDECIMAL:
             bindinfo[i].buffer_type = MYSQL_TYPE_STRING;
             bindinfo[i].buffer_length = 100;  // MORE - is there a better guess?
             break;
         case MYSQL_TYPE_TIMESTAMP:
         case MYSQL_TYPE_DATETIME:
         case MYSQL_TYPE_TIME:
         case MYSQL_TYPE_DATE:
             bindinfo[i].buffer_type = col->type;
             bindinfo[i].buffer_length = sizeof(MYSQL_TIME);
             break;
         default:
             bindinfo[i].buffer_type = col->type;
             bindinfo[i].buffer_length = col->length;
             break;
         }
         bindinfo[i].buffer = rtlMalloc(bindinfo[i].buffer_length);
     }
 }
예제 #2
0
ECL_H3_API void ECL_H3_CALL center(ICodeContext *_ctx, size32_t &__lenResult, void *&__result, unsigned __int64 index)
{
    GeoCoord location;
    ::h3ToGeo(index, &location);
    __lenResult = 2 * sizeof(double);
    __result = rtlMalloc(__lenResult);
    double *cur = static_cast<double *>(__result);
    *cur++ = ::radsToDegs(location.lat);
    *cur = ::radsToDegs(location.lon);
}
예제 #3
0
ECL_H3_API void ECL_H3_CALL boundary(ICodeContext *_ctx, size32_t &__lenResult, void *&__result, unsigned __int64 index)
{
    GeoBoundary boundary;
    ::h3ToGeoBoundary(index, &boundary);
    __lenResult = boundary.numVerts * 2 * sizeof(double);
    __result = rtlMalloc(__lenResult);

    double *cur = static_cast<double *>(__result);
    for (int v = 0; v < boundary.numVerts; v++)
    {
        *cur++ = ::radsToDegs(boundary.verts[v].lat);
        *cur++ = ::radsToDegs(boundary.verts[v].lon);
    }
}
예제 #4
0
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;
}
예제 #5
0
TIMELIB_API void TIMELIB_CALL tlTimeToString(size32_t &__lenResult, char* &__result, unsigned int time, const char* format)
{
    struct tm       timeInfo;
    const size_t    kBufferSize = 256;
    char            buffer[kBufferSize];

    memset(&timeInfo, 0, sizeof(timeInfo));
    tlInsertTimeIntoTimeStruct(&timeInfo, time);
    tlMKTime(&timeInfo);

    __lenResult = strftime(buffer, kBufferSize, format, &timeInfo);
    __result = NULL;

    if (__lenResult > 0)
    {
        __result = reinterpret_cast<char*>(rtlMalloc(__lenResult));
        memcpy(__result, buffer, __lenResult);
    }
}
예제 #6
0
TIMELIB_API void TIMELIB_CALL tlSecondsToString(size32_t &__lenResult, char* &__result, __int64 seconds, const char* format)
{
    struct tm       timeInfo;
    time_t          theTime = seconds;
    const size_t    kBufferSize = 256;
    char            buffer[kBufferSize];

    memset(buffer, 0, kBufferSize);

    tlGMTime_r(&theTime, &timeInfo);

    __lenResult = strftime(buffer, kBufferSize, format, &timeInfo);
    __result = NULL;

    if (__lenResult > 0)
    {
        __result = reinterpret_cast<char*>(rtlMalloc(__lenResult));
        memcpy(__result, buffer, __lenResult);
    }
}
예제 #7
0
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;
    }
}
예제 #8
0
void ViewFieldECLTransformer::transform(unsigned & lenTarget, char * & target, unsigned lenSource, const char * source, const HqlExprArray & extraArgs)
{
    Owned<ITypeInfo> sourceType = makeUtf8Type(lenSource, 0);
    IValue * sourceValue = createUtf8Value(source, LINK(sourceType));
    OwnedHqlExpr sourceExpr = createConstant(sourceValue);
    HqlExprArray actuals;
    actuals.append(*LINK(sourceExpr));
    appendArray(actuals, extraArgs);

    Owned<IErrorReceiver> errorReporter = createThrowingErrorReceiver();
    OwnedHqlExpr call = createBoundFunction(errorReporter, function, actuals, NULL, true);
    OwnedHqlExpr castValue = ensureExprType(call, utf8Type);
    OwnedHqlExpr folded = quickFoldExpression(castValue, NULL, 0);
    IValue * foldedValue = folded->queryValue();
    assertex(foldedValue);
    unsigned len = foldedValue->queryType()->getStringLen();
    const char * data = static_cast<const char *>(foldedValue->queryValue());
    unsigned size = rtlUtf8Size(len, data);
    lenTarget = len;
    target = (char *)rtlMalloc(size);
    memcpy(target, data, size);
}
예제 #9
0
ECL_H3_API void ECL_H3_CALL toString(ICodeContext *_ctx, size32_t &lenVarStr, char *&varStr, unsigned __int64 index)
{
    varStr = static_cast<char *>(rtlMalloc(H3_INDEX_MINSTRLEN));
    ::h3ToString(index, varStr, H3_INDEX_MINSTRLEN);
    lenVarStr = strlen(varStr);
}
예제 #10
0
void * SimplePluginCtx::ctxMalloc(size_t size)
{ 
    return rtlMalloc(size); 
}
예제 #11
0
 inline rtlDataAttr(size32_t size)   {
     ptr=rtlMalloc(size);
 };