MCPcopy Create free account
hub / github.com/documentdb/documentdb / AddNumberToBsonValue

Function AddNumberToBsonValue

pg_documentdb_core/src/io/pgbson_utils.c:142–182  ·  view source on GitHub ↗

* Adds the number stored in number to state and modifies state. * returns true if addition happened (type was supported) * @state: The augend * @number: The addend * @overflowedFromInt64: Used for AddInt64ToValue(); set if overflow from Int64 occurs, unset otherwise. */

Source from the content-addressed store, hash-verified

140 * @overflowedFromInt64: Used for AddInt64ToValue(); set if overflow from Int64 occurs, unset otherwise.
141 */
142bool
143AddNumberToBsonValue(bson_value_t *state, const bson_value_t *number,
144 bool *overflowedFromInt64)
145{
146 if (!BsonValueIsNumberOrBool(state))
147 {
148 return false;
149 }
150
151 switch (number->value_type)
152 {
153 case BSON_TYPE_INT64:
154 {
155 AddInt64ToValue(state, number->value.v_int64, overflowedFromInt64);
156 return true;
157 }
158
159 case BSON_TYPE_INT32:
160 {
161 AddInt32ToValue(state, number->value.v_int32, overflowedFromInt64);
162 return true;
163 }
164
165 case BSON_TYPE_DOUBLE:
166 {
167 AddDoubleToValue(state, number->value.v_double);
168 return true;
169 }
170
171 case BSON_TYPE_DECIMAL128:
172 {
173 AddDecimal128ToValue(state, number);
174 return true;
175 }
176
177 default:
178 {
179 return false;
180 }
181 }
182}
183
184
185/*

Callers 14

bson_in_range_numericFunction · 0.85
MergeWorkerIndexDocsFunction · 0.85
ProcessDollarAddFunction · 0.85
HandleUpdateDollarIncFunction · 0.85
IndexStatsWorkerFunction · 0.85
MergeWorkerResultsFunction · 0.85
NumericStepIncrementorFunction · 0.85
ArithmeticOperationFuncFunction · 0.85
bson_sum_avg_transitionFunction · 0.85

Calls 5

BsonValueIsNumberOrBoolFunction · 0.85
AddInt64ToValueFunction · 0.85
AddInt32ToValueFunction · 0.85
AddDoubleToValueFunction · 0.85
AddDecimal128ToValueFunction · 0.85

Tested by

no test coverage detected