Validate that the `BinaryRow` is compatible with this computer's partition keys.
(&self, row: &BinaryRow)
| 113 | |
| 114 | /// Validate that the `BinaryRow` is compatible with this computer's partition keys. |
| 115 | fn validate_row(&self, row: &BinaryRow) -> crate::Result<()> { |
| 116 | if self.partition_keys.len() != row.arity() as usize { |
| 117 | return Err(Error::UnexpectedError { |
| 118 | message: format!( |
| 119 | "Partition keys length ({}) does not match row arity ({})", |
| 120 | self.partition_keys.len(), |
| 121 | row.arity() |
| 122 | ), |
| 123 | source: None, |
| 124 | }); |
| 125 | } |
| 126 | |
| 127 | if row.is_empty() { |
| 128 | return Err(Error::UnexpectedError { |
| 129 | message: "Partition row has no backing data but arity > 0".to_string(), |
| 130 | source: None, |
| 131 | }); |
| 132 | } |
| 133 | |
| 134 | // Validate that the backing data is large enough for null-bits + fixed-part. |
| 135 | let min_size = BinaryRow::cal_bit_set_width_in_bytes(row.arity()) as usize |
| 136 | + (row.arity() as usize) * 8; |
| 137 | if row.data().len() < min_size { |
| 138 | return Err(Error::UnexpectedError { |
| 139 | message: format!( |
| 140 | "Partition BinaryRow data too short: need at least {} bytes, got {}", |
| 141 | min_size, |
| 142 | row.data().len() |
| 143 | ), |
| 144 | source: None, |
| 145 | }); |
| 146 | } |
| 147 | |
| 148 | Ok(()) |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | /// Resolve the `DataField` for each partition key from the schema fields, preserving order. |
no test coverage detected