Commit 4f9e4f5
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 8ce7aa2 commit 4f9e4f5
1 file changed
Lines changed: 23 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2677 | 2677 | | |
2678 | 2678 | | |
2679 | 2679 | | |
2680 | | - | |
2681 | | - | |
2682 | | - | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
2683 | 2696 | | |
2684 | | - | |
| 2697 | + | |
2685 | 2698 | | |
2686 | | - | |
2687 | | - | |
2688 | 2699 | | |
2689 | 2700 | | |
2690 | | - | |
| 2701 | + | |
2691 | 2702 | | |
2692 | 2703 | | |
2693 | | - | |
2694 | | - | |
2695 | | - | |
| 2704 | + | |
2696 | 2705 | | |
2697 | | - | |
| 2706 | + | |
2698 | 2707 | | |
2699 | 2708 | | |
2700 | 2709 | | |
2701 | | - | |
| 2710 | + | |
2702 | 2711 | | |
2703 | | - | |
2704 | | - | |
| 2712 | + | |
| 2713 | + | |
2705 | 2714 | | |
2706 | 2715 | | |
2707 | 2716 | | |
| |||
0 commit comments