Exemplo n.º 1
0
bool CChildLimitedDatasetColumnInfo::buildReadAhead(HqlCppTranslator & translator, BuildCtx & ctx, ReadAheadState & state)
{
    try
    {
        OwnedHqlExpr self = container->getRelativeSelf();
        if (sizeField)
        {
            OwnedHqlExpr mappedSize = replaceSelector(sizeField, querySelfReference(), self);
            OwnedHqlExpr replacedSize = quickFullReplaceExpressions(mappedSize, state.requiredValues, state.mappedValues);
            if (containsSelector(replacedSize, queryRootSelf()))
                return false;
            callDeserializerSkipInputSize(translator, ctx, state. helper, replacedSize);
            return true;
        }
        else
        {
            OwnedHqlExpr mappedCount = replaceSelector(countField, querySelfReference(), self);
            OwnedHqlExpr replacedCount = quickFullReplaceExpressions(mappedCount, state.requiredValues, state.mappedValues);
            if (containsSelector(replacedCount, queryRootSelf()))
                return false;
            if (fixedChildSize != UNKNOWN_LENGTH)
            {
                OwnedHqlExpr scaledSize = multiplyValue(replacedCount, fixedChildSize);
                callDeserializerSkipInputSize(translator, ctx, state. helper, scaledSize);
                return true;
            }

            BuildCtx loopctx(ctx);
            CHqlBoundExpr bound;
            translator.buildTempExpr(loopctx, replacedCount, bound);

            OwnedHqlExpr test = createValue(no_postdec, LINK(bound.expr));
            loopctx.addLoop(test, NULL, false);

            StringBuffer prefetcherInstanceName;
            translator.ensureRowPrefetcher(prefetcherInstanceName, ctx, column->queryRecord());
            
            StringBuffer s;
            s.append(prefetcherInstanceName).append("->readAhead(");
            translator.generateExprCpp(s, state.helper).append(");");
            loopctx.addQuoted(s);
            return true;
        }
    }
    catch (IException * e)
    {
        //yuk yuk yuk!!  Couldn't resolve the dataset count/size for some strange reason
        e->Release();
    }
    return false;
}
css_RuleList mergeNodes(css_RuleList list) {	
	css_RuleList newRules = NULL;	
	
	while(list) {
		css_Rule tmpRule = list->rule;		
		css_SelectorList sels = tmpRule->selectorList;	
		
		while(sels) {
			css_Selector currSel = sels->selector;		
			css_RuleList tmpList = list->next;
	
			if(currSel == NULL) 
				break;
	
			css_Rule newRule = NULL;
			newRule = mergeToNewRule(tmpRule, NULL, currSel);
			while(tmpList) {
				if(containsSelector(tmpList->rule->selectorList, currSel)) {
					newRule = mergeToNewRule(newRule, tmpList->rule, currSel);					
					removeSelector(currSel, tmpList->rule->selectorList);
				}
		
				tmpList = tmpList->next;
			}
			
			
			
			newRules = create_CSSRuleList(newRule, newRules);
		
			sels = sels->next;
		}
	
		list = list->next;
	}
	
	return newRules;
}