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); }
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); } }
void CChildLimitedDatasetColumnInfo::setColumn(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, IHqlExpression * value) { if (sizeField) translator.throwError(HQLERR_CannotCreateSizedChildDataset); if (countField) { IHqlExpression * record = column->queryRecord(); OwnedHqlExpr mappedCount = replaceSelector(countField, querySelfReference(), selector->queryExpr()->queryChild(0)); Owned<IHqlCppDatasetBuilder> builder = translator.createLimitedDatasetBuilder(record, mappedCount); builder->buildDeclare(ctx); translator.buildDatasetAssign(ctx, builder, value); setColumnFromBuilder(translator, ctx, selector, builder); } }
void CChildSetColumnInfo::setColumn(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, IHqlExpression * _value) { 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)); OwnedHqlExpr isAllTarget = convertAddressToValue(address, boolType); OwnedHqlExpr lengthTarget = convertAddressToValue(addressSize, sizetType); ITypeInfo * columnType = column->queryType(); ITypeInfo * elementType = columnType->queryChildType(); OwnedHqlExpr value = ensureExprType(_value, columnType); OwnedHqlExpr inlineSize; switch (value->getOperator()) { case no_list: if ((value->numChildren() != 0) && ::isFixedSize(elementType)) inlineSize.setown(getSizetConstant(value->numChildren() * elementType->getSize())); break; } if (inlineSize) { checkAssignOk(translator, ctx, selector, inlineSize, sizeof(size32_t)+sizeof(bool)); Owned<IHqlCppSetBuilder> builder = translator.createInlineSetBuilder(elementType, isAllTarget, inlineSize, addressData); builder->buildDeclare(ctx); translator.buildSetAssign(ctx, builder, value); CHqlBoundTarget boundTarget; boundTarget.length.set(lengthTarget); builder->buildFinish(ctx, boundTarget); } else { CHqlBoundExpr bound; if ((value->getOperator() == no_list) && value->numChildren()) { CHqlBoundTarget tempTarget; translator.createTempFor(ctx, columnType, tempTarget, typemod_none, FormatNatural); translator.buildExprAssign(ctx, tempTarget, value); bound.setFromTarget(tempTarget); } else translator.buildExpr(ctx, value, bound); ensureSimpleLength(translator, ctx, bound); OwnedHqlExpr isAll = bound.getIsAll(); OwnedHqlExpr length = translator.getBoundLength(bound); OwnedHqlExpr size = createValue(no_translated, LINK(sizetType), translator.getBoundSize(bound)); checkAssignOk(translator, ctx, selector, size, sizeof(size32_t)+sizeof(bool)); translator.assignBoundToTemp(ctx, isAllTarget, isAll); translator.assignBoundToTemp(ctx, lengthTarget, length); translator.buildBlockCopy(ctx, addressData, bound); ensureSimpleLength(translator, ctx, bound); OwnedHqlExpr boundSize = translator.getBoundSize(bound); associateSizeOf(ctx, selector, boundSize, sizeof(size32_t)+sizeof(bool)); } }