IHqlExpression * CChildDatasetColumnInfo::buildSizeOfUnbound(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector) { OwnedHqlExpr addressSize = getColumnAddress(translator, ctx, selector, sizetType, 0); OwnedHqlExpr length = convertAddressToValue(addressSize, sizetType); OwnedHqlExpr boundSize = translator.getBoundSize(column->queryType(), length, NULL); return createValue(no_translated, LINK(sizetType), adjustValue(boundSize, sizeof(size32_t))); }
void Amarok::Slider::setValue(int newValue) { // don't adjust the slider while the user is dragging it! if (!m_sliding || m_outside) QSlider::setValue(adjustValue(newValue)); else m_prevValue = newValue; }
bool Double::operator <=(const Double &other) const { int rate = digs - other.getDig(); if(rate == 0) return lv <= other.getlv(); qint64 v1=lv,v2=other.getlv(); adjustValue(rate,v1,v2); return v1<=v2; }
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); } }
// --- QGAMES::Screen::ScaleParameters::ScaleParameters (QGAMES::Screen* s, QGAMES::bdata sc, bool sA, QGAMES::Screen::ScaleParameters::Effect e) : _screen (s), _value (sc), _scaleByAlgorithm (sA), _effect (e) { assert (s); adjustValue (); calculateVectorScale (); }
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); }
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); }
/* Stack layout: ... | node */ static UA_StatusCode writeValueAttribute(UA_Server *server, UA_Session *session, UA_VariableNode *node, const UA_DataValue *value, const UA_String *indexRange) { UA_assert(node != NULL); /* Parse the range */ UA_NumericRange range; UA_NumericRange *rangeptr = NULL; UA_StatusCode retval = UA_STATUSCODE_GOOD; if(indexRange && indexRange->length > 0) { retval = UA_NumericRange_parseFromString(&range, indexRange); if(retval != UA_STATUSCODE_GOOD) return retval; rangeptr = ⦥ } /* Created an editable version. The data is not touched. Only the variant * "container". */ UA_DataValue adjustedValue = *value; /* Type checking. May change the type of editableValue */ if(value->hasValue && value->value.type) { adjustValue(server, &adjustedValue.value, &node->dataType); /* The value may be an extension object, especially the nodeset compiler uses * extension objects to write variable values. * If value is an extension object we check if the current node value is also an extension object. */ UA_Boolean compatible; if (value->value.type->typeId.identifierType == UA_NODEIDTYPE_NUMERIC && value->value.type->typeId.identifier.numeric == UA_NS0ID_STRUCTURE) { const UA_NodeId nodeDataType = UA_NODEID_NUMERIC(0, UA_NS0ID_STRUCTURE); compatible = compatibleValue(server, &nodeDataType, node->valueRank, node->arrayDimensionsSize, node->arrayDimensions, &adjustedValue.value, rangeptr); } else { compatible = compatibleValue(server, &node->dataType, node->valueRank, node->arrayDimensionsSize, node->arrayDimensions, &adjustedValue.value, rangeptr); } if(!compatible) { if(rangeptr) UA_free(range.dimensions); return UA_STATUSCODE_BADTYPEMISMATCH; } } /* Set the source timestamp if there is none */ if(!adjustedValue.hasSourceTimestamp) { adjustedValue.sourceTimestamp = UA_DateTime_now(); adjustedValue.hasSourceTimestamp = true; } /* Ok, do it */ if(node->valueSource == UA_VALUESOURCE_DATA) { if(!rangeptr) retval = writeValueAttributeWithoutRange(node, &adjustedValue); else retval = writeValueAttributeWithRange(node, &adjustedValue, rangeptr); /* Callback after writing */ if(retval == UA_STATUSCODE_GOOD && node->value.data.callback.onWrite) node->value.data.callback.onWrite(server, &session->sessionId, session->sessionHandle, &node->nodeId, node->context, rangeptr, &adjustedValue); } else { if(node->value.dataSource.write) { retval = node->value.dataSource.write(server, &session->sessionId, session->sessionHandle, &node->nodeId, node->context, rangeptr, &adjustedValue); } else { retval = UA_STATUSCODE_BADWRITENOTSUPPORTED; } } /* Clean up */ if(rangeptr) UA_free(range.dimensions); return retval; }
// Estimate the percentage of rows that will be returned for a particular extent. // This function provides the estimate for entire filter such as "col 1 < 100 or col1 > 10000". float RowEstimator::estimateRowReturnFactor(const BRM::EMEntry& emEntry, const messageqcpp::ByteStream* bs, const uint16_t NOPS, const execplan::CalpontSystemCatalog::ColType& ct, const uint8_t BOP, const uint32_t& rowsInExtent) { bool bIsUnsigned = execplan::isUnsigned(ct.colDataType); float factor = 1.0; float tempFactor = 1.0; // Adjust values based on column type and estimate the uint64_t adjustedMin = adjustValue(ct, emEntry.partition.cprange.lo_val); uint64_t adjustedMax = adjustValue(ct, emEntry.partition.cprange.hi_val); uint32_t distinctValuesEstimate = estimateDistinctValues( ct, adjustedMin, adjustedMax, emEntry.partition.cprange.isValid); // Loop through the operations and estimate the percentage of rows that will qualify. // For example, there are two operations for "col1 > 5 and col1 < 10": // 1) col1 > 5 // 2) col2 < 10 int length = bs->length(), pos = 0; const char *msgDataPtr = (const char *) bs->buf(); int64_t value=0; bool firstQualifyingOrCondition = true; uint16_t comparisonLimit = (NOPS <= fMaxComparisons) ? NOPS : fMaxComparisons; for (int i = 0; i < comparisonLimit; i++) { pos += ct.colWidth + 2; // predicate + op + lcf // TODO: Stole this condition from lbidlist. // Investigate whether this can happen / should throw an error. if (pos > length) { return factor; } // Get the comparison value for the condition. char op = *msgDataPtr++; uint8_t lcf = *(uint8_t*)msgDataPtr++; if (bIsUnsigned) { switch (ct.colWidth) { case 1: { uint8_t val = *(uint8_t*)msgDataPtr; value = val; break; } case 2: { uint16_t val = *(uint16_t*)msgDataPtr; value = val; break; } case 4: { uint32_t val = *(uint32_t*)msgDataPtr; value = val; break; } case 8: default: { uint64_t val = *(uint64_t*)msgDataPtr; value = static_cast<int64_t>(val); break; } } } else { switch (ct.colWidth) { case 1: { int8_t val = *(int8_t*)msgDataPtr; value = val; break; } case 2: { int16_t val = *(int16_t*)msgDataPtr; value = val; break; } case 4: { int32_t val = *(int32_t*)msgDataPtr; value = val; break; } case 8: default: { int64_t val = *(int64_t*)msgDataPtr; value = val; break; } } } // TODO: Investigate whether condition below should throw an error. msgDataPtr += ct.colWidth; if (pos > length) { return factor; } #if ROW_EST_DEBUG cout << " Min-" << emEntry.partition.cprange.lo_val << ", Max-" << emEntry.partition.cprange.hi_val << ", Val-" << value; #endif // Get the factor for the individual operation. if (bIsUnsigned) { tempFactor = estimateOpFactor<uint64_t>( adjustedMin, adjustedMax, adjustValue(ct, value), op, lcf, distinctValuesEstimate, emEntry.partition.cprange.isValid); } else { tempFactor = estimateOpFactor<int64_t>( adjustedMin, adjustedMax, adjustValue(ct, value), op, lcf, distinctValuesEstimate, emEntry.partition.cprange.isValid); } #if ROW_EST_DEBUG cout << ", OperatorFactor-" << tempFactor << ", DistinctValsEst-" << distinctValuesEstimate << endl; #endif // Use it in the overall factor. if (BOP == BOP_AND) { // TODO: Handle betweens correctly (same as a >= 5 and a <= 10) factor *= tempFactor; } else if (BOP == BOP_OR) { if (firstQualifyingOrCondition) { factor = tempFactor; firstQualifyingOrCondition = false; } else { factor += tempFactor; } } else { factor = tempFactor; } } // for() if(factor > 1.0) { factor = 1.0; } #if ROW_EST_DEBUG if(NOPS > 1) cout << " FilterFactor-" << factor << endl; #endif return factor; }