本文整理汇总了C++中OwnedHqlExpr类的典型用法代码示例。如果您正苦于以下问题:C++ OwnedHqlExpr类的具体用法?C++ OwnedHqlExpr怎么用?C++ OwnedHqlExpr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OwnedHqlExpr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dummyctx
void HqlCppLibrary::extractOutputs()
{
HqlExprArray symbols;
scopeExpr->queryScope()->getSymbols(symbols);
IHqlScope * scope = scopeExpr->queryScope();
HqlDummyLookupContext dummyctx(NULL);
ForEachItemIn(i, symbols)
{
IHqlExpression & cur = symbols.item(i);
if (isExported(&cur))
{
_ATOM name = cur.queryName();
OwnedHqlExpr value = scope->lookupSymbol(name, LSFpublic, dummyctx);
if (value && !value->isFunction())
{
if (value->isDataset() || value->isDatarow() || value->queryType()->isScalar())
{
OwnedHqlExpr null = createNullExpr(value);
outputs.append(*cur.cloneAllAnnotations(null));
}
}
}
}
示例2: strrchr
void WebServicesExtractor::getAttributeText(StringBuffer & text, const char* attributeName)
{
const char * dot = strrchr(attributeName, '.');
if(!dot || !dot[1])
throw MakeStringException(3, "Please specify both module and attribute");
OwnedHqlExpr symbol = getResolveAttributeFullPath(attributeName, LSFpublic, lookupCtx);
if (!symbol || !hasNamedSymbol(symbol) || !symbol->hasText())
{
StringBuffer txt;
txt.append("Could not read attribute: ").append(attributeName);
DBGLOG("%s", txt.str());
throw MakeStringException(ERR_NO_ATTRIBUTE_TEXT, "%s", txt.str());
}
symbol->getTextBuf(text);
/* MORE: It would be preferable if this was better integrated with hqlgram2.cpp. It's a reasonable stopgap */
if (archive)
{
StringAttr moduleName(attributeName, dot-attributeName);
IPropertyTree * moduleTree = queryEnsureArchiveModule(archive, moduleName, NULL);
IPropertyTree * attrTree = queryArchiveAttribute(moduleTree, dot+1);
if (!attrTree)
{
attrTree = createArchiveAttribute(moduleTree, dot+1);
const char * p = text.str();
if (0 == strncmp(p, UTF8_BOM,3))
p += 3;
attrTree->setProp("", p);
}
}
}
示例3: buildWorkUnitViewerEcl
IHqlExpression * buildWorkUnitViewerEcl(IHqlExpression * record, const char * wuid, unsigned sequence, const char * name)
{
OwnedHqlExpr newRecord = createSymbol(createIdentifierAtom("_SourceRecord_"), LINK(record), ob_private);
IHqlExpression * arg = name ? createConstant(name) : createConstant((int)sequence);
OwnedHqlExpr dataset = createDataset(no_workunit_dataset, newRecord.getLink(), createComma(createConstant(wuid), arg));
OwnedHqlExpr projected = addSimplifyProject(dataset);
OwnedHqlExpr output = addOutput(projected);
return output.getClear();
}
示例4: queryExpandFilename
static void queryExpandFilename(StringBuffer & out, IHqlExpression * expr)
{
if (expr)
{
OwnedHqlExpr folded = foldHqlExpression(expr);
if (folded->queryValue())
folded->queryValue()->generateECL(out.append('\n'));
}
}
示例5: a1
bool QueryDataSource::createBrowseWU()
{
StringAttr dataset, datasetDefs;
StringAttrAdaptor a1(dataset), a2(datasetDefs);
wuResult->getResultDataset(a1, a2);
if (!dataset || !datasetDefs)
return false;
StringBuffer fullText;
fullText.append(datasetDefs).append(dataset);
OwnedHqlExpr parsed = parseQuery(fullText.str());
if (!parsed)
return false;
HqlExprAttr selectFields = parsed.getLink();
if (selectFields->getOperator() == no_output)
selectFields.set(selectFields->queryChild(0));
OwnedHqlExpr browseWUcode = buildQueryViewerEcl(selectFields);
if (!browseWUcode)
return false;
returnedRecord.set(browseWUcode->queryChild(0)->queryRecord());
StringAttr tempAttr;
StringAttrAdaptor temp(tempAttr);
Owned<IWorkUnitFactory> factory = getWorkUnitFactory();
Owned<IConstWorkUnit> parent = factory->openWorkUnit(wuid, false);
SCMStringBuffer user;
StringAttrAdaptor acluster(cluster);
parent->getClusterName(acluster);
parent->getUser(user);
Owned<IWorkUnit> workunit = factory->createWorkUnit(NULL, "fileViewer", user.str());
workunit->setUser(user.str());
workunit->setClusterName(cluster);
workunit->setCustomerId(parent->getCustomerId(temp).str());
workunit->setCompareMode(CompareModeOff); // ? parent->getCompareMode()
StringAttrAdaptor bwa(browseWuid); workunit->getWuid(bwa);
workunit->setDebugValueInt("importImplicitModules", false, true);
workunit->setDebugValueInt("importAllModules", false, true);
workunit->setDebugValueInt("forceFakeThor", 1, true);
StringBuffer jobName;
jobName.append("FileView for ").append(wuid).append(":").append("x");
workunit->setJobName(jobName.str());
StringBuffer eclText;
toECL(browseWUcode, eclText, true);
Owned<IWUQuery> query = workunit->updateQuery();
query->setQueryText(eclText.str());
query->setQueryName(jobName.str());
return true;
}
示例6: createTransformed
virtual IHqlExpression * createTransformed(IHqlExpression * expr)
{
OwnedHqlExpr transformed = NewHqlTransformer::createTransformed(expr);
if (transformed->getOperator() == no_getgraphresult)
{
if (hasOperand(transformed, graph))
return removeAttribute(transformed, externalAtom);
}
return transformed.getClear();
}
示例7: getColumnAddress
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);
}
}
示例8: ForEachChild
ForEachChild(i, record)
{
IHqlExpression * cur = record->queryChild(i);
switch (cur->getOperator())
{
case no_record:
expandFieldNames(errorProcessor, out, cur, prefix, sep, formatFunc);
break;
case no_ifblock:
expandFieldNames(errorProcessor, out, cur->queryChild(1), prefix, sep, formatFunc);
break;
case no_field:
{
StringBuffer lowerName;
lowerName.append(cur->queryName()).toLowerCase();
if (formatFunc)
{
HqlExprArray args;
args.append(*createConstant(lowerName.str()));
OwnedHqlExpr bound = createBoundFunction(NULL, formatFunc, args, NULL, true);
OwnedHqlExpr folded = foldHqlExpression(errorProcessor, bound, NULL, HFOthrowerror|HFOfoldimpure|HFOforcefold);
assertex(folded->queryValue());
lowerName.clear();
getStringValue(lowerName, folded);
}
switch (cur->queryType()->getTypeCode())
{
case type_record:
case type_row:
{
unsigned len = prefix.length();
prefix.append(lowerName).append(".");
expandFieldNames(errorProcessor, out, cur->queryRecord(), prefix, sep, formatFunc);
prefix.setLength(len);
break;
}
default:
{
if (out.length())
out.append(sep);
out.append(prefix).append(lowerName);
break;
}
}
break;
}
}
}
示例9: checkCreateConcreteModule
IHqlExpression * checkCreateConcreteModule(IErrorReceiver * errors, IHqlExpression * expr, const ECLlocation & errpos)
{
IHqlScope * scope = expr->queryScope();
if (scope && scope->queryConcreteScope())
{
IHqlScope * concrete = scope->queryConcreteScope();
return LINK(queryExpression(concrete));
}
if (expr->getOperator() == no_delayedscope)
{
if (expr->queryChild(0)->getOperator() == no_assertconcrete)
return LINK(expr);
}
OwnedHqlExpr check = createValue(no_assertconcrete, expr->getType(), LINK(expr), errpos.createLocationAttr());
return createDelayedScope(check.getClear());
}
示例10: assertex
IHqlExpression* HqlGram::processAbstractDataset(IHqlExpression* _expr, IHqlExpression* formal, IHqlExpression* actual, IHqlExpression * mapping, const attribute& errpos, bool errorIfNotFound, bool & hadError)
{
LinkedHqlExpr transformed = _expr;
IHqlExpression* formalRecord = formal->queryRecord();
IHqlExpression* actualRecord = actual->queryRecord();
assertex(formalRecord && actualRecord);
hadError = false;
IHqlSimpleScope *actualScope = actualRecord->querySimpleScope();
unsigned numChildren = formalRecord->numChildren();
for (unsigned idx = 0; idx < numChildren; idx++)
{
IHqlExpression* kid = formalRecord->queryChild(idx);
if ((kid->getOperator() == no_ifblock) || kid->isAttribute())
continue;
IIdAtom * name = kid->queryId();
IIdAtom * mapto = fieldMapTo(mapping, name);
OwnedHqlExpr match = actualScope->lookupSymbol(mapto);
if (match)
{
if (!kid->queryType()->assignableFrom(match->queryType()))
{
StringBuffer fromType, toType;
getFriendlyTypeStr(kid,fromType);
getFriendlyTypeStr(match,toType);
reportError(ERR_DSPARAM_TYPEMISMATCH, errpos, "Can not mapping type %s(field '%s') to %s(field '%s')",
fromType.str(), str(kid->queryName()), toType.str(), str(match->queryName()));
hadError = true;
}
//MORE: This should really be mapped in a single go
if (transformed)
transformed.setown(bindField(transformed, kid, match));
}
else if (errorIfNotFound)
{
reportError(ERR_DSPARM_MISSINGFIELD,errpos,"Dataset %s has no field named '%s'", str(actual->queryName()), str(mapto));
hadError = true;
}
}
return transformed.getClear();
}
示例11: 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();
}
示例12: makeUtf8Type
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);
}
示例13: switch
IHqlExpression * PositionTransformer::createTransformed(IHqlExpression * _expr)
{
OwnedHqlExpr transformed = NewHqlTransformer::createTransformed(_expr);
switch (transformed->getOperator())
{
case no_table:
{
IHqlExpression * mode = transformed->queryChild(2);
HqlExprArray fields;
HqlExprArray args;
if (mode->getOperator() == no_thor)
{
unwindChildren(fields, transformed->queryChild(1));
IHqlExpression * filePosAttr = createComma(createAttribute(virtualAtom, createAttribute(filepositionAtom)), insertedAttr.getLink());
IHqlExpression * sizeofAttr = createComma(createAttribute(virtualAtom, createAttribute(sizeofAtom)), insertedAttr.getLink());
fields.append(*createField(fileposName, makeIntType(8, false), NULL, filePosAttr));
fields.append(*createField(recordlenName, makeIntType(2, false), NULL, sizeofAttr));
unwindChildren(args, transformed);
args.replace(*createRecord(fields), 1);
return transformed->clone(args);
}
}
break;
case no_iterate:
case no_hqlproject:
{
HqlExprArray args;
HqlExprArray assigns;
IHqlExpression * transform = transformed->queryChild(1);
unwindChildren(args, transformed);
unwindChildren(assigns, transform);
IHqlExpression * inRecord = transformed->queryChild(0)->queryRecord();
IHqlExpression * outRecord = transform->queryRecord();
HqlExprArray fields;
unwindChildren(fields, outRecord);
ForEachChild(idx, inRecord)
{
IHqlExpression * child = inRecord->queryChild(idx);
if (child->hasProperty(insertedAtom))
{
IHqlExpression * newTarget = createField(child->queryName(), child->getType(), LINK(child), insertedAttr.getLink());
fields.append(*newTarget);
assigns.append(*createValue(no_assign, makeVoidType(), newTarget, createSelectExpr(createValue(no_left), LINK(newTarget))));
}
}
IHqlExpression * newRecord = createRecord(fields);
args.replace(*createValue(no_transform, newRecord->getType(), assigns), 1);
return transformed->clone(args);
}
break;
case no_join:
//only ok if join first
case no_rollup:
case no_newaggregate:
case no_aggregate:
fail();
break;
case no_usertable:
case no_selectfields:
{
IHqlExpression * grouping = transformed->queryChild(2);
if (grouping && (grouping->getOperator() != no_attr))
fail();
IHqlExpression * record = transformed->queryRecord();
HqlExprArray fields;
unwindChildren(fields, transformed->queryChild(1));
ForEachChild(idx, record)
{
IHqlExpression * child = record->queryChild(idx);
if (child->hasProperty(insertedAtom))
fields.append(*createField(child->queryName(), child->getType(), LINK(child), insertedAttr.getLink()));
}
HqlExprArray args;
unwindChildren(args, transformed);
args.replace(*createRecord(fields), 1);
return transformed->clone(args);
}
示例14: optimizedReplaceSelector
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);
}
}
示例15: 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));
}