* GinBsonExtractQuerySize generates the index term needed to match * $size on dotted path and values. * In this case, we can simply return the term path with a empty array value * The extra data is populated with the desired array size. * The query is expected to be of the format {path}{typeCode}{value} * i.e. a BsonElement. */
| 2935 | * i.e. a BsonElement. |
| 2936 | */ |
| 2937 | static Datum * |
| 2938 | GinBsonExtractQuerySize(BsonExtractQueryArgs *args) |
| 2939 | { |
| 2940 | int32 *nentries = args->nentries; |
| 2941 | bool **partialmatch = args->partialmatch; |
| 2942 | Pointer **extra_data = args->extra_data; |
| 2943 | Datum *entries = (Datum *) palloc(sizeof(Datum)); |
| 2944 | pgbsonelement documentElement = args->filterElement; |
| 2945 | |
| 2946 | *partialmatch = (bool *) palloc(sizeof(bool)); |
| 2947 | *nentries = 1; |
| 2948 | **partialmatch = true; |
| 2949 | |
| 2950 | /* store the query value in extra data - this allows us to compute upper bound using */ |
| 2951 | /* this extra value. */ |
| 2952 | *extra_data = (Pointer *) palloc(sizeof(int64_t)); |
| 2953 | *((int64_t *) *extra_data) = BsonValueAsInt64(&documentElement.bsonValue); |
| 2954 | |
| 2955 | /* now create a bson for that path which has the min value for the field */ |
| 2956 | /* we map this to an empty array since that's the smallest value we'll encounter */ |
| 2957 | entries[0] = GenerateEmptyArrayTerm(&documentElement, &args->termMetadata); |
| 2958 | return entries; |
| 2959 | } |
| 2960 | |
| 2961 | |
| 2962 | /* |
no test coverage detected