Commit d937ce8
committed
(improvement) metadata: single-pass column classification in _build_table_columns
Rewrite _build_table_columns to classify columns by kind in a single
pass instead of iterating col_rows three times with list comprehensions.
This also fixes a bug where the third pass filtered on 'clustering_key'
instead of 'clustering', causing clustering columns to leak through and
get re-processed as regular columns.
Additionally, use in-place sort() instead of sorted() to avoid creating
intermediate list copies, and append the already-built column_meta
object to partition_key/clustering_key instead of re-looking it up
from meta.columns by name.
Combined benchmark results for the full optimization series (A-F):
Row creation + access: 323 ns/row vs 485 ns/row (1.50x faster)
_build_table_columns: 9.0 us/table vs 9.9 us/table (1.10x faster)
Full pipeline (100 tables x 20 cols): 0.79 ms vs 1.57 ms (1.98x faster)
Memory per row: 48 bytes vs 272 bytes (5.7x reduction)
__slots__ per instance: 80 bytes (saves ~104 bytes __dict__ overhead)1 parent 40ccd3d commit d937ce8
1 file changed
Lines changed: 23 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2673 | 2673 | | |
2674 | 2674 | | |
2675 | 2675 | | |
2676 | | - | |
2677 | | - | |
2678 | | - | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
2679 | 2692 | | |
2680 | | - | |
| 2693 | + | |
2681 | 2694 | | |
2682 | | - | |
2683 | | - | |
2684 | 2695 | | |
2685 | 2696 | | |
2686 | | - | |
| 2697 | + | |
2687 | 2698 | | |
2688 | 2699 | | |
2689 | | - | |
2690 | | - | |
2691 | | - | |
| 2700 | + | |
2692 | 2701 | | |
2693 | | - | |
| 2702 | + | |
2694 | 2703 | | |
2695 | 2704 | | |
2696 | 2705 | | |
2697 | | - | |
| 2706 | + | |
2698 | 2707 | | |
2699 | | - | |
2700 | | - | |
| 2708 | + | |
| 2709 | + | |
2701 | 2710 | | |
2702 | 2711 | | |
2703 | 2712 | | |
| |||
0 commit comments