本文整理汇总了C++中OwnedHqlExpr::setown方法的典型用法代码示例。如果您正苦于以下问题:C++ OwnedHqlExpr::setown方法的具体用法?C++ OwnedHqlExpr::setown怎么用?C++ OwnedHqlExpr::setown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OwnedHqlExpr
的用法示例。
在下文中一共展示了OwnedHqlExpr::setown方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setColumn
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);
}
}
示例2: buildDiskFileViewerEcl
IHqlExpression * buildDiskFileViewerEcl(const char * logicalName, IHqlExpression * record)
{
//Add filepos to the incomming record structure...
IHqlExpression * filePosAttr = createAttribute(virtualAtom, createAttribute(filepositionAtom));
OwnedHqlExpr filepos = createField(fileposName, makeIntType(8, false), NULL, filePosAttr);
IHqlExpression * sizeofAttr = createAttribute(virtualAtom, createAttribute(sizeofAtom));
OwnedHqlExpr reclen = createField(recordlenName, makeIntType(2, false), NULL, sizeofAttr);
HqlExprArray fields;
unwindChildren(fields, record);
fields.append(*filepos.getLink());
fields.append(*reclen.getLink());
OwnedHqlExpr newRecord = createRecord(fields);
newRecord.setown(createSymbol(createIdentifierAtom("_SourceRecord_"), newRecord.getLink(), ob_private));
OwnedHqlExpr dataset = createNewDataset(createConstant(logicalName), newRecord.getLink(), createValue(no_thor), NULL, NULL, NULL);
OwnedHqlExpr filtered = addFilter(dataset, filepos);
OwnedHqlExpr projected = addSimplifyProject(filtered);
OwnedHqlExpr output = addOutput(projected);
return output.getClear();
}
示例3: LINK
static IHqlExpression * optimizedReplaceSelector(IHqlExpression * expr, IHqlExpression * oldDataset, IHqlExpression * newDataset)
{
switch (expr->getOperator())
{
case no_constant:
case no_attr:
return LINK(expr);
case no_select:
{
IHqlExpression * lhs = expr->queryChild(0);
IHqlExpression * field = expr->queryChild(1);
OwnedHqlExpr newLhs;
if (expr->hasAttribute(newAtom))
{
newLhs.setown(optimizedReplaceSelector(lhs, oldDataset, newDataset));
}
else
{
if (lhs == oldDataset)
{
if (newDataset->getOperator() == no_newrow)
return createNewSelectExpr(LINK(newDataset->queryChild(0)), LINK(field));
if (newDataset->getOperator() == no_activerow)
newDataset = newDataset->queryChild(0);
return createSelectExpr(LINK(newDataset->queryNormalizedSelector()), LINK(field));
}
else
newLhs.setown(optimizedReplaceSelector(lhs, oldDataset, newDataset));
}
if (newLhs)
return replaceChild(expr, 0, newLhs);
return NULL;
}
case no_implicitcast:
case no_cast:
{
IHqlExpression * newUncast = optimizedReplaceSelector(expr->queryChild(0), oldDataset, newDataset);
if (!newUncast)
return NULL;
OwnedHqlExpr ret = createValue(expr->getOperator(), expr->getType(), newUncast);
return expr->cloneAllAnnotations(ret);
}
case no_hash:
case no_hash32:
case no_hash64:
case no_sortlist:
case no_concat:
case no_trim:
case no_negate:
case no_eq:
case no_ne:
case no_sizeof:
case no_attr_expr:
case no_add:
{
HqlExprArray args;
ForEachChild(i, expr)
{
IHqlExpression * cur = expr->queryChild(i);
IHqlExpression * newCur = optimizedReplaceSelector(cur, oldDataset, newDataset);
if (!newCur)
return NULL;
args.append(*newCur);
}
return expr->clone(args);
}
}
示例4: queryActiveTableSelector
IHqlExpression * HqlCppCaseInfo::buildIndexedMap(BuildCtx & ctx, const CHqlBoundExpr & test)
{
ITypeInfo * compareType = test.queryType()->queryPromotedType();
type_t compareTypeCode = compareType->getTypeCode();
HqlExprArray values;
IHqlExpression * dft = queryActiveTableSelector(); // value doesn't matter as long as it will not occur
__int64 lower = getIntValue(lowerTableBound, 0);
unsigned num = (getIntValue(upperTableBound, 0)-lower)+1;
CHqlBoundExpr indexExpr;
switch (compareTypeCode)
{
case type_int:
indexExpr.set(test);
break;
case type_string:
indexExpr.expr.setown(createValue(no_index, makeCharType(), LINK(test.expr), getZero()));
indexExpr.expr.setown(createValue(no_cast, makeIntType(1, false), LINK(indexExpr.expr)));
break;
default:
throwUnexpectedType(compareType);
}
if (useRangeIndex && (num != 1))
translator.ensureSimpleExpr(ctx, indexExpr);
OwnedHqlExpr mapped;
ITypeInfo * retType = resultType;
//if num == pairs.ordinality() and all results are identical, avoid the table lookup.
if (allResultsMatch && (num == pairs.ordinality()))
{
mapped.set(pairs.item(0).queryChild(1));
}
else
{
values.ensure(num);
unsigned idx;
for (idx = 0; idx < num; idx++)
values.append(*LINK(dft));
ForEachItemIn(idx2, pairs)
{
IHqlExpression & cur = pairs.item(idx2);
IValue * value = cur.queryChild(0)->queryValue();
unsigned replaceIndex;
switch (compareTypeCode)
{
case type_int:
replaceIndex = (unsigned)(value->getIntValue()-lower);
break;
case type_string:
{
StringBuffer temp;
value->getStringValue(temp);
replaceIndex = (unsigned)((unsigned char)temp.charAt(0)-lower);
break;
}
default:
throwUnexpectedType(compareType);
}
IHqlExpression * mapTo = cur.queryChild(1);
if (mapTo->getOperator() != no_constant)
throwUnexpected();
if (replaceIndex >= num)
translator.reportWarning(CategoryIgnored, HQLWRN_CaseCanNeverMatch, "CASE entry %d can never match the test condition", replaceIndex);
else
values.replace(*LINK(mapTo),replaceIndex);
}
//Now replace the placeholders with the default values.
for (idx = 0; idx < num; idx++)
{
if (&values.item(idx) == dft)
values.replace(*defaultValue.getLink(),idx);
}
// use a var string type to get better C++ generated...
ITypeInfo * storeType = getArrayElementType(resultType);
ITypeInfo * listType = makeArrayType(storeType, values.ordinality());
OwnedHqlExpr lvalues = createValue(no_list, listType, values);
CHqlBoundExpr boundTable;
translator.buildExpr(ctx, lvalues, boundTable);
LinkedHqlExpr tableIndex = indexExpr.expr;
if (getIntValue(lowerTableBound, 0))
tableIndex.setown(createValue(no_sub, tableIndex->getType(), LINK(tableIndex), LINK(lowerTableBound)));
IHqlExpression * ret = createValue(no_index, LINK(retType), LINK(boundTable.expr), LINK(tableIndex));
mapped.setown(createTranslatedOwned(ret));
}