()
| 378 | |
| 379 | #[test] |
| 380 | fn write_segment_multi_block() { |
| 381 | let schema = |
| 382 | ColumnarSchema::new(vec![ColumnDef::required("x", ColumnType::Int64)]).expect("valid"); |
| 383 | |
| 384 | let mut mt = ColumnarMemtable::new(&schema); |
| 385 | for i in 0..2500 { |
| 386 | mt.append_row(&[Value::Integer(i)]).expect("append"); |
| 387 | } |
| 388 | |
| 389 | let (schema, columns, row_count) = mt.drain(); |
| 390 | let writer = SegmentWriter::plain(); |
| 391 | let segment = writer |
| 392 | .write_segment(&schema, &columns, row_count, None) |
| 393 | .expect("write"); |
| 394 | |
| 395 | let footer = SegmentFooter::from_segment_tail(&segment).expect("valid footer"); |
| 396 | assert_eq!(footer.row_count, 2500); |
| 397 | |
| 398 | // 2500 rows / 1024 = 3 blocks (1024 + 1024 + 452). |
| 399 | assert_eq!(footer.columns[0].block_count, 3); |
| 400 | assert_eq!(footer.columns[0].block_stats[0].row_count, 1024); |
| 401 | assert_eq!(footer.columns[0].block_stats[1].row_count, 1024); |
| 402 | assert_eq!(footer.columns[0].block_stats[2].row_count, 452); |
| 403 | |
| 404 | // Block 0: min=0, max=1023. |
| 405 | assert_eq!(footer.columns[0].block_stats[0].min, 0.0); |
| 406 | assert_eq!(footer.columns[0].block_stats[0].max, 1023.0); |
| 407 | // Block 2: min=2048, max=2499. |
| 408 | assert_eq!(footer.columns[0].block_stats[2].min, 2048.0); |
| 409 | assert_eq!(footer.columns[0].block_stats[2].max, 2499.0); |
| 410 | } |
| 411 | |
| 412 | #[test] |
| 413 | fn write_segment_empty_rejected() { |
nothing calls this directly
no test coverage detected