alamb commented on code in PR #8877: URL: https://github.com/apache/arrow-rs/pull/8877#discussion_r2543112275
########## docs/arraydata_bitmap_layout_contract.md: ########## @@ -0,0 +1,76 @@ +# ArrayData + Bitmap Layout Contract Review Comment: If you want to add docs , let's do it in doc comments to keep it close to the code rather than in a separate document that is more likely to drift out of sync ########## arrow-select/src/nullif.rs: ########## @@ -17,11 +17,50 @@ //! Implements the `nullif` function for Arrow arrays. +/* + * NULLIF Implementation Contract + * + * For any ArrayData: + * len = data.len() // logical elements + * offset = data.offset() // logical starting index into buffers + * + * Validity bitmap (if present) is a Buffer B. + * Invariant: + * Logical index i in [0, len) is valid iff get_bit(B, offset + i) == true. + * + * For the result of nullif: + * We will build a fresh ArrayData with offset = 0. + * For that result: + * Logical index i is valid iff get_bit(result_validity, i) == true. + * Values buffer is laid out so element 0 is first result value, etc. + * + * For nullif semantics: + * Let V(i) = left is valid at i + * C(i) = condition "nullify at i" is true (depends on left, right, type) + * Then: + * result_valid(i) = V(i) & !C(i) + * result_value(i) = left_value(i) // when result_valid(i) == true + * + * This contract is the law. All nullif implementations must follow it. Review Comment: i don't understand the contract is the law comment. We should be enforcing things with tests not external readme files -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
