* Recurses over a type tree and selects the parents of every selected type. * @return true if any child was selected. */
| 123 | * @return true if any child was selected. |
| 124 | */ |
| 125 | bool ColumnSelector::selectParents(std::vector<bool>& selectedColumns, const Type& type) { |
| 126 | size_t id = static_cast<size_t>(type.getColumnId()); |
| 127 | bool result = selectedColumns[id]; |
| 128 | uint64_t numSubtypeSelected = 0; |
| 129 | for (uint64_t c = 0; c < type.getSubtypeCount(); ++c) { |
| 130 | if (selectParents(selectedColumns, *type.getSubtype(c))) { |
| 131 | result = true; |
| 132 | numSubtypeSelected++; |
| 133 | } |
| 134 | } |
| 135 | selectedColumns[id] = result; |
| 136 | |
| 137 | if (type.getKind() == TypeKind::UNION && selectedColumns[id]) { |
| 138 | if (0 < numSubtypeSelected && numSubtypeSelected < type.getSubtypeCount()) { |
| 139 | // Subtypes of UNION should be fully selected or not selected at all. |
| 140 | // Override partial subtype selections with full selections. |
| 141 | for (uint64_t c = 0; c < type.getSubtypeCount(); ++c) { |
| 142 | selectChildren(selectedColumns, *type.getSubtype(c)); |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | return result; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Recurses over a type tree and build two maps |
no test coverage detected