Пример #1
0
void CColumnInfo::buildDeserializeChildLoop(HqlCppTranslator & translator, BuildCtx & loopctx, IReferenceSelector * selector, IHqlExpression * helper, IAtom * serializeForm)
{
    OwnedHqlExpr endMarker = loopctx.getTempDeclare(sizetType, NULL);
    HqlExprArray args;
    args.append(*LINK(helper));
    OwnedHqlExpr beginCall = translator.bindTranslatedFunctionCall(deserializerBeginNestedId, args);
    loopctx.addAssign(endMarker, beginCall);

    args.append(*LINK(helper));
    args.append(*LINK(endMarker));
    OwnedHqlExpr loopCall = createBoolExpr(no_not, translator.bindTranslatedFunctionCall(deserializerFinishedNestedId, args));
    loopctx.addLoop(loopCall, NULL, false);
}
Пример #2
0
bool CppFilterExtractor::createGroupingMonitor(BuildCtx ctx, const char * listName, IHqlExpression * expr, unsigned & maxField)
{
    switch (expr->getOperator())
    {
    case no_if:
        {
            IHqlExpression * cond = expr->queryChild(0);
            if (expr->queryChild(2)->isConstant() && isIndependentOfScope(cond))
            {
                BuildCtx subctx(ctx);
                translator.buildFilter(subctx, expr->queryChild(0));
                createGroupingMonitor(subctx, listName, expr->queryChild(1), maxField);
                return true;        // may still be keyed
            }
            break;
        }
    case no_select:
        {
            size32_t offset = 0;
            ForEachItemIn(i, keyableSelects)
            {
                IHqlExpression & cur = keyableSelects.item(i);
                size32_t curSize = cur.queryType()->getSize();
                if (!createValueSets && curSize == UNKNOWN_LENGTH)
                    break;
                if (expr == &cur)
                {
                    maxField = i+1;
                    if (createValueSets)
                    {
                        StringBuffer type;
                        translator.buildRtlFieldType(type, expr->queryChild(1), queryRecord(tableExpr));
                        ctx.addQuotedF("%s->append(FFkeyed, createWildFieldFilter(%u, %s));", listName, i, type.str());
                    }
                    else
                    {
                        //MORE: Check the type of the field is legal.
                        ctx.addQuotedF("%s->append(createWildKeySegmentMonitor(%u, %u, %u));", listName, i, offset, curSize);
                    }
                    return true;
                }
                offset += curSize;
            }
            break;
        }
    case no_constant:
        return true;
    }
Пример #3
0
void CChildLimitedDatasetColumnInfo::buildDeserialize(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, IHqlExpression * helper, IAtom * serializeForm)
{
    assertex(!column->isDictionary());
    if (sizeField || !countField)
    {
        ctx.addQuoted("rtlFailUnexpected();");
        return;
    }

    //NB: The serialized form of a dataset with an external count is not the same as a normal dataset
    IHqlExpression * record = column->queryRecord();
    if (recordRequiresSerialization(record, serializeForm) || !translator.isFixedRecordSize(record))
    {
        Owned<IHqlCppDatasetBuilder> builder = translator.createBlockedDatasetBuilder(column->queryRecord());
        builder->buildDeclare(ctx);

        buildDeserializeToBuilder(translator, ctx, builder, selector, helper, serializeForm);

        CHqlBoundExpr bound;
        builder->buildFinish(ctx, bound);

        setColumnFromBuilder(translator, ctx, selector, builder);
    }
    else
        CColumnInfo::buildDeserialize(translator, ctx, selector, helper, serializeForm);
}
Пример #4
0
void CChildLimitedDatasetColumnInfo::buildDeserializeChildLoop(HqlCppTranslator & translator, BuildCtx & loopctx, IReferenceSelector * selector, IHqlExpression * helper, IAtom * serializeForm)
{
    OwnedHqlExpr mappedCount = replaceSelector(countField, querySelfReference(), selector->queryExpr()->queryChild(0));
    CHqlBoundExpr bound;
    translator.buildTempExpr(loopctx, mappedCount, bound);

    OwnedHqlExpr test = createValue(no_postdec, LINK(bound.expr));
    loopctx.addLoop(test, NULL, false);
}
Пример #5
0
void CChildDatasetColumnInfo::setColumn(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, IHqlExpression * _value)
{
    OwnedHqlExpr addressSize = getColumnAddress(translator, ctx, selector, sizetType, 0);
    OwnedHqlExpr addressData = getColumnAddress(translator, ctx, selector, queryType(), sizeof(size32_t));

    OwnedHqlExpr lengthTarget = convertAddressToValue(addressSize, sizetType);

    ITypeInfo * columnType = column->queryType();
    OwnedHqlExpr value = LINK(_value); //ensureExprType(_value, columnType);
    ITypeInfo * valueType = value->queryType();

    assertRecordTypesMatch(valueType, columnType);

    bool assignInline = false;  // canEvaluateInline(value);   // MORE: What is the test
//  bool assignInline = canAssignInline(&ctx, value) && !canEvaluateInline(&ctx, value);
    value.setown(addDatasetLimits(translator, ctx, selector, value));

    IHqlExpression * record = column->queryRecord();
    if (assignInline)
    {
        OwnedHqlExpr inlineSize = getSizetConstant(0);
        checkAssignOk(translator, ctx, selector, inlineSize, sizeof(size32_t));

        //Can only assign inline if we know the maximum length that will be assigned is 0.
        Owned<IHqlCppDatasetBuilder> builder = translator.createInlineDatasetBuilder(record, inlineSize, addressData);
        builder->buildDeclare(ctx);

        translator.buildDatasetAssign(ctx, builder, value);

        CHqlBoundTarget boundTarget;
        boundTarget.length.set(lengthTarget);
        builder->buildFinish(ctx, boundTarget);
    }
    else
    {
        CHqlBoundExpr bound;
        translator.buildDataset(ctx, value, bound, FormatBlockedDataset);
        translator.normalizeBoundExpr(ctx, bound);
        ensureSimpleLength(translator, ctx, bound);

        OwnedHqlExpr length = translator.getBoundLength(bound);
        OwnedHqlExpr size = createValue(no_translated, LINK(sizetType), translator.getBoundSize(bound));
        checkAssignOk(translator, ctx, selector, size, sizeof(size32_t));

        translator.assignBoundToTemp(ctx, lengthTarget, length);
        translator.buildBlockCopy(ctx, addressData, bound);

        //Use the size just calculated for the field
        OwnedHqlExpr sizeOfExpr = createValue(no_sizeof, LINK(sizetType), LINK(selector->queryExpr()));
        OwnedHqlExpr boundSize = translator.getBoundSize(bound);
        OwnedHqlExpr srcSize = adjustValue(boundSize, sizeof(size32_t));
        ctx.associateExpr(sizeOfExpr, srcSize);
    }
}
Пример #6
0
void HqlCppCaseInfo::buildChop3Map(BuildCtx & ctx, const CHqlBoundTarget & target, CHqlBoundExpr & test)
{
    translator.buildExprAssign(ctx, target, defaultValue);
    if (getNumPairs() <= 2)
    {
        buildChop2Map(ctx, target, test, 0, getNumPairs());
    }
    else
    {
        //need to hack it because there is no signed integer type
        OwnedHqlExpr tempVar = ctx.getTempDeclare(indexType, NULL);
        buildChop3Map(ctx, target, test, tempVar, 0, getNumPairs());
    }
}
Пример #7
0
void CChildLimitedDatasetColumnInfo::setColumnFromBuilder(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, IHqlCppDatasetBuilder * builder)
{
    CHqlBoundExpr bound;
    builder->buildFinish(ctx, bound);
    if (bound.length)
        bound.length.setown(translator.ensureSimpleTranslatedExpr(ctx, bound.length));

    OwnedHqlExpr size = createValue(no_translated, LINK(sizetType), translator.getBoundSize(bound));
    checkAssignOk(translator, ctx, selector, size, 0);

    OwnedHqlExpr addressData = getColumnAddress(translator, ctx, selector, queryType(), 0);
    translator.buildBlockCopy(ctx, addressData, bound);

    //Use the size just calculated for the field
    OwnedHqlExpr sizeOfExpr = createValue(no_sizeof, LINK(sizetType), LINK(selector->queryExpr()));
    OwnedHqlExpr srcSize = translator.getBoundSize(bound);
    ctx.associateExpr(sizeOfExpr, srcSize);
}
Пример #8
0
void CChildSetColumnInfo::buildDeserialize(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, IHqlExpression * helper, IAtom * serializeForm)
{
    OwnedHqlExpr address = getColumnAddress(translator, ctx, selector, boolType, 0);
    OwnedHqlExpr addressSize = getColumnAddress(translator, ctx, selector, sizetType, sizeof(bool));
    OwnedHqlExpr addressData = getColumnAddress(translator, ctx, selector, queryType(), sizeof(bool)+sizeof(size32_t));

    size32_t sizeExtra = sizeof(bool)+sizeof(size32_t);

    //Read the all flag and the size
    OwnedHqlExpr sizeAllSizet = getSizetConstant(sizeExtra);
    callDeserializeGetN(translator, ctx, helper, sizeAllSizet, address);

    OwnedHqlExpr targetSize = convertAddressToValue(addressSize, sizetType);
    OwnedHqlExpr unboundSize = createTranslated(targetSize);
    checkAssignOk(translator, ctx, selector, unboundSize, sizeExtra);

    callDeserializeGetN(translator, ctx, helper, targetSize, addressData);

    OwnedHqlExpr sizeOfExpr = createValue(no_sizeof, LINK(sizetType), LINK(selector->queryExpr()));
    OwnedHqlExpr srcSize = adjustValue(targetSize, sizeExtra);
    ctx.associateExpr(sizeOfExpr, srcSize);
}
Пример #9
0
void CChildDatasetColumnInfo::buildDeserialize(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, IHqlExpression * helper, IAtom * serializeForm)
{
    IHqlExpression * record = column->queryRecord();
    assertex(!recordRequiresLinkCount(record)); // Why would it?
    if (column->isDictionary())
    {
        if (serializeForm == diskAtom)
        {
            //If we ever generate the meta definition for an internal serialization format then the following needs to be implemented
            UNIMPLEMENTED_X("deserialize serialized dictionary from disk");
            return;
        }
    }


    if (isConditional())
        checkAssignOk(translator, ctx, selector, queryZero(), sizeof(size32_t));

    OwnedHqlExpr addressSize = getColumnAddress(translator, ctx, selector, sizetType, 0);
    OwnedHqlExpr addressData = getColumnAddress(translator, ctx, selector, queryType(), sizeof(size32_t));

    //Read the all flag and the size
    OwnedHqlExpr sizeSizet = getSizetConstant(sizeof(size32_t));
    callDeserializeGetN(translator, ctx, helper, sizeSizet, addressSize);

    OwnedHqlExpr targetSize = convertAddressToValue(addressSize, sizetType);
    OwnedHqlExpr simpleSize = translator.ensureSimpleTranslatedExpr(ctx, targetSize);
    OwnedHqlExpr unboundSize = createTranslated(simpleSize);
    checkAssignOk(translator, ctx, selector, unboundSize, sizeof(size32_t));

    callDeserializeGetN(translator, ctx, helper, simpleSize, addressData);

    OwnedHqlExpr sizeOfExpr = createValue(no_sizeof, LINK(sizetType), LINK(selector->queryExpr()));
    OwnedHqlExpr srcSize = adjustValue(simpleSize, sizeof(size32_t));
    ctx.associateExpr(sizeOfExpr, srcSize);
}