Esempio n. 1
0
TIMELIB_API size32_t TIMELIB_CALL tlDatesForWeek(ARowBuilder& __self, unsigned int date)
{
    struct tm       timeInfo;

    struct TMDateRange
    {
        unsigned int    startDate;
        unsigned int    endDate;
    };

    TMDateRange* result = reinterpret_cast<TMDateRange*>(__self.getSelf());

    memset(&timeInfo, 0, sizeof(timeInfo));
    tlInsertDateIntoTimeStruct(&timeInfo, date);

    // Call mktime once to fix up any bogus data
    tlMKTime(&timeInfo);

    // Adjust and call again
    timeInfo.tm_mday -= timeInfo.tm_wday;
    tlMKTime(&timeInfo);

    result->startDate = tlExtractDateFromTimeStruct(&timeInfo);

    // Adjust to the beginning of the week
    timeInfo.tm_mday += 6;
    tlMKTime(&timeInfo);

    result->endDate = tlExtractDateFromTimeStruct(&timeInfo);

    return static_cast<size32_t>(sizeof(TMDateRange));
}
Esempio n. 2
0
size32_t CThorContiguousRowBuffer::readVStr(ARowBuilder & target, size32_t offset, size32_t fixedSize)
{
    size32_t size = sizeVStr();
    byte * self = target.ensureCapacity(fixedSize + size, NULL);
    doRead(size, self+offset);
    return size;
}
Esempio n. 3
0
TIMELIB_API size32_t TIMELIB_CALL tlSecondsToParts(ARowBuilder& __self, __int64 seconds)
{
    struct tm       timeInfo;

    struct TMParts
    {
        __int32 sec;
        __int32 min;
        __int32 hour;
        __int32 mday;
        __int32 mon;
        __int32 year;
        __int32 wday;
    };

    tlMakeTimeStructFromUTCSeconds(seconds, &timeInfo);

    TMParts* result = reinterpret_cast<TMParts*>(__self.getSelf());

    result->sec = timeInfo.tm_sec;
    result->min = timeInfo.tm_min;
    result->hour = timeInfo.tm_hour;
    result->mday = timeInfo.tm_mday;
    result->mon = timeInfo.tm_mon;
    result->year = timeInfo.tm_year;
    result->wday = timeInfo.tm_wday;

    return static_cast<size32_t>(sizeof(TMParts));
}
Esempio n. 4
0
size32_t CThorStreamDeserializerSource::readUtf8(ARowBuilder & target, size32_t offset, size32_t fixedSize, size32_t len)
{
    //The len is the number of utf characters, size depends on which characters are included.
    size32_t totalSize = 0;
    loop
    {
        if (len == 0)
            return totalSize;

        size32_t available;
        const byte * cur = doPeek(1, available);

        size32_t copyLen;
        for (copyLen = 0; copyLen < available;)
        {
            copyLen += readUtf8Size(cur+copyLen);   // This function only accesses the first byte
            if (--len == 0)
                break;
        }

        byte * self = target.ensureCapacity(fixedSize + totalSize + copyLen, NULL);
        doRead(copyLen, self+offset+totalSize);
        totalSize += copyLen;
    }
}
Esempio n. 5
0
size32_t CThorStreamDeserializerSource::readVUni(ARowBuilder & target, size32_t offset, size32_t fixedSize)
{
    size32_t totalSize = 0;
    bool done = false;
    loop
    {
        size32_t available;
        const byte * cur = doPeek(2, available);

        size32_t copyLen = 0;
        for (copyLen = 0; copyLen+1 < available; copyLen+=2)
        {
            if (cur[copyLen] == 0 && cur[copyLen+1] == 0)
            {
                copyLen += 2;
                done = true;
                break;
            }
        }

        byte * self = target.ensureCapacity(fixedSize + totalSize + copyLen, NULL);
        doRead(copyLen, self+offset+totalSize);
        totalSize += copyLen;
        if (done)
            return totalSize;
    }
}
Esempio n. 6
0
 virtual size32_t getTransformResult(ARowBuilder & rowBuilder)
 {
     SqLite3RowBuilder sqliteRowBuilder(stmt);
     const RtlTypeInfo *typeInfo = rowBuilder.queryAllocator()->queryOutputMeta()->queryTypeInfo();
     assertex(typeInfo);
     RtlFieldStrInfo dummyField("<row>", NULL, typeInfo);
     return typeInfo->build(rowBuilder, 0, &dummyField, sqliteRowBuilder);
 }
Esempio n. 7
0
size32_t CThorContiguousRowBuffer::readUtf8(ARowBuilder & target, size32_t offset, size32_t fixedSize, size32_t len)
{
    if (len == 0)
        return 0;

    size32_t size = sizeUtf8(len);
    byte * self = target.ensureCapacity(fixedSize + size, NULL);
    doRead(size, self+offset);
    return size;
}
Esempio n. 8
0
    size32_t CouchbaseEmbedFunctionContext::getTransformResult(ARowBuilder & rowBuilder)
    {
        execute();

        auto resultrow = nextResultRowTree();
        if (!resultrow)
            fail("Failed to read row");
        if (resultrow->getCount("./*") != 1)
            typeError("row", "");

        CouchbaseRowBuilder couchbaseRowBuilder(resultrow);
        const RtlTypeInfo *typeInfo = rowBuilder.queryAllocator()->queryOutputMeta()->queryTypeInfo();
        assertex(typeInfo);
        RtlFieldStrInfo dummyField("<row>", NULL, typeInfo);
        return typeInfo->build(rowBuilder, 0, &dummyField, couchbaseRowBuilder);
    }
Esempio n. 9
0
size32_t CThorStreamDeserializerSource::readVStr(ARowBuilder & target, size32_t offset, size32_t fixedSize)
{
    size32_t totalSize = 0;
    loop
    {
        size32_t available;
        const byte * cur = doPeek(1, available);

        const byte * end = static_cast<const byte *>(memchr(cur, 0, available));
        size32_t copyLen = end ? (end+1) - cur : available;

        byte * self = target.ensureCapacity(fixedSize + totalSize + copyLen, NULL);
        doRead(copyLen, self+offset+totalSize);
        totalSize += copyLen;
        if (end)
            return totalSize;
    }
}
Esempio n. 10
0
 virtual size32_t transform(ARowBuilder & rowBuilder, const void * src) override
 {
     unsigned size = recordSize.getRecordSize(src);
     memcpy(rowBuilder.ensureCapacity(size, NULL), src, size);
     return size;
 }