[SERVER-30967] Add $binarySize expression Created: 06/Sep/17 Updated: 30/Oct/23 Resolved: 21/Nov/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | 4.3.3 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Stephen Tunney (Inactive) | Assignee: | David Percy |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | expression, neweng, pm1457 | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||
| Sprint: | Query 2019-12-02 | ||||||||||||||||||||
| Participants: | |||||||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||||||
| Description |
|
The query team has discussed and decided on the following syntax/semantics: Name: $binarySizeAlternate Names: $binSize, $byteSizeThis expression takes an expression that evaluates to a string or BinData and return the size of the value in bytes. It will error if the result evaluates to a type other than string, BinData, or null. Given nullish, returns null.
Original DescriptionImplement an aggregation expression that return the length of BinData type value. This would work much in the same way as Examples
Pipeline
Output
|
| Comments |
| Comment by Githook User [ 21/Nov/19 ] |
|
Author: {'email': 'david.percy@mongodb.com', 'name': 'David Percy', 'username': 'dpercy'}Message: |
| Comment by Githook User [ 21/Nov/19 ] |
|
Author: {'name': 'David Percy', 'username': 'dpercy', 'email': 'david.percy@mongodb.com'}Message: |
| Comment by Asya Kamsky [ 07/Apr/18 ] |
|
Is there a reason to restrict this expression to work on Binary only? If it also worked on strings we could remove $strLenBytes and simplify how many functions return length of string/stream things in bytes. (and we could then alias $strLenCP to $strLen). It could be named $byteLen or $lenBytes. |