|
75 | 75 | iterator-seq |
76 | 76 | (into []))) |
77 | 77 |
|
78 | | -(defn table-partitions |
| 78 | +(defn partition-data->vec |
| 79 | + [pdata] |
| 80 | + (let [size (.size pdata) |
| 81 | + fields (->> pdata |
| 82 | + .getPartitionType |
| 83 | + .fields |
| 84 | + (mapv #(.name %))) |
| 85 | + values (mapv #(.get pdata %) (range size))] |
| 86 | + (zipmap fields values))) |
| 87 | + |
| 88 | +(defn table-partitions-from-meta |
79 | 89 | [table] |
80 | | - (letfn [(partition-data->vec [pdata] |
81 | | - (let [size (.size pdata) |
82 | | - fields (->> pdata |
83 | | - .getPartitionType |
84 | | - .fields |
85 | | - (mapv #(.name %))) |
86 | | - values (mapv #(.get pdata %) (range size))] |
87 | | - (zipmap fields values))) |
88 | | - (content-data-file->vec [content-data-file] |
| 90 | + (letfn [(content-data-file->vec [content-data-file] |
89 | 91 | (-> content-data-file |
90 | 92 | .partition |
91 | 93 | partition-data->vec))] |
|
94 | 96 | (.addedDataFiles (.io table)) |
95 | 97 | (->> (map content-data-file->vec))))) |
96 | 98 |
|
| 99 | +(defn table-partitions-from-data |
| 100 | + [table] |
| 101 | + (-> table |
| 102 | + .newScan |
| 103 | + .planTasks |
| 104 | + .iterator |
| 105 | + iterator-seq |
| 106 | + (->> (mapcat #(.files %)) |
| 107 | + (map #(-> % |
| 108 | + .partition |
| 109 | + partition-data->vec))))) |
| 110 | + |
97 | 111 | (defn handle-scan-table [ns-in table-in] |
98 | 112 | (let [table (load-table (get-catalog) ns-in table-in) |
99 | 113 | rows (scan-table table) |
|
104 | 118 |
|
105 | 119 | (defn handle-table-partitions [ns-in table-in] |
106 | 120 | (let [table (load-table (get-catalog) ns-in table-in) |
107 | | - partitions (table-partitions table) |
108 | | - response-body (json/write-str partitions)] |
| 121 | + partitions-from-meta (table-partitions-from-meta table) |
| 122 | + partitions-from-data (table-partitions-from-data table) |
| 123 | + response {:from-data partitions-from-data |
| 124 | + :from-meta partitions-from-meta} |
| 125 | + response-body (json/write-str response)] |
109 | 126 | {:body response-body})) |
110 | 127 |
|
111 | 128 | (defroutes app-routes |
|
0 commit comments