Binary.ApproximateLength
BinaryReturns the approximate length of a binary value, or an error if the data source does not support approximate length.
Syntax
Binary.ApproximateLength(binary as nullable binary) as nullable numberParameters
| Name | Type | Required | Description |
|---|---|---|---|
binary | binary | Yes | The binary value whose approximate length to return. |
Return Value
number — The approximate number of bytes in the binary value.
Remarks
Binary.ApproximateLength returns an estimate of the number of bytes in a binary value. Unlike Binary.Length, which may need to fully evaluate a stream to determine its exact size, this function can return a result without reading all bytes. Not all data sources support approximate lengths — if the source cannot provide one, an error is raised.
This function is useful in scenarios where you need a quick size check without the cost of fully materializing a binary stream, such as when deciding whether to buffer content into memory.
Examples
Example 1: Get the approximate length of a binary value
let
Source = Binary.FromText("i45WMlSKjQUA", BinaryEncoding.Base64),
ApproxLen = Binary.ApproximateLength(Source)
in
ApproxLenReturns the approximate length of the binary value, which is 9 bytes.
Value | |
|---|---|
| 1 | 9 |