()
| 179 | |
| 180 | #[test] |
| 181 | fn custom_key_fn() { |
| 182 | let rows = vec![ |
| 183 | row_with_field("r1", "score", "10"), |
| 184 | row_with_field("r2", "score", "90"), |
| 185 | row_with_field("r3", "score", "50"), |
| 186 | ]; |
| 187 | |
| 188 | match partition_batch(&rows, 32, |row| { |
| 189 | let score: i64 = row |
| 190 | .new_fields() |
| 191 | .and_then(|m| m.get("score")) |
| 192 | .and_then(|v| v.as_str()) |
| 193 | .and_then(|s| s.parse().ok()) |
| 194 | .unwrap_or(0); |
| 195 | if score >= 50 { |
| 196 | "high".into() |
| 197 | } else { |
| 198 | "low".into() |
| 199 | } |
| 200 | }) { |
| 201 | PartitionResult::Partitions(parts) => { |
| 202 | assert_eq!(parts.len(), 2); |
| 203 | } |
| 204 | PartitionResult::CircuitBroken { .. } => panic!("unexpected"), |
| 205 | } |
| 206 | } |
| 207 | } |
nothing calls this directly
no test coverage detected