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

Function bson_dollar_size

pg_documentdb/src/query/bson_dollar_operators.c:621–638  ·  view source on GitHub ↗

* Traverses the document for a given dot-path notation * When a matching path is found, then returns true if the * element is an array with the specified size. Returns false * otherwise. */

Source from the content-addressed store, hash-verified

619 * otherwise.
620 */
621Datum
622bson_dollar_size(PG_FUNCTION_ARGS)
623{
624 pgbson *document = PG_GETARG_PGBSON(0);
625 pgbson *filter = PG_GETARG_PGBSON(1);
626
627 bson_iter_t documentIterator;
628 pgbsonelement filterElement;
629 TraverseElementValidateState state = { 0 };
630 PgbsonInitIterator(document, &documentIterator);
631 PgbsonToSinglePgbsonElement(filter, &filterElement);
632 filterElement.pathLength = 0;
633 state.filter = &filterElement;
634 state.traverseState.matchFunc = CompareArraySizeMatch;
635 TraverseBson(&documentIterator, filterElement.path, &state.traverseState,
636 &CompareTopLevelFieldExecutionFuncs);
637 PG_RETURN_BOOL(state.traverseState.compareResult == CompareResult_Match);
638}
639
640
641/*

Callers

nothing calls this directly

Calls 3

PgbsonInitIteratorFunction · 0.85
TraverseBsonFunction · 0.85

Tested by

no test coverage detected