parse fixed point decimal numbers
| 126 | |
| 127 | // parse fixed point decimal numbers |
| 128 | void fillDecimalValues(const std::vector<std::string>& data, orc::ColumnVectorBatch* batch, |
| 129 | uint64_t numValues, uint64_t colIndex, size_t scale, size_t precision) { |
| 130 | orc::Decimal128VectorBatch* d128Batch = nullptr; |
| 131 | orc::Decimal64VectorBatch* d64Batch = nullptr; |
| 132 | if (precision <= 18) { |
| 133 | d64Batch = dynamic_cast<orc::Decimal64VectorBatch*>(batch); |
| 134 | d64Batch->scale = static_cast<int32_t>(scale); |
| 135 | } else { |
| 136 | d128Batch = dynamic_cast<orc::Decimal128VectorBatch*>(batch); |
| 137 | d128Batch->scale = static_cast<int32_t>(scale); |
| 138 | } |
| 139 | bool hasNull = false; |
| 140 | for (uint64_t i = 0; i < numValues; ++i) { |
| 141 | std::string col = extractColumn(data[i], colIndex); |
| 142 | if (col.empty()) { |
| 143 | batch->notNull[i] = 0; |
| 144 | hasNull = true; |
| 145 | } else { |
| 146 | batch->notNull[i] = 1; |
| 147 | size_t ptPos = col.find('.'); |
| 148 | size_t curScale = 0; |
| 149 | std::string num = col; |
| 150 | if (ptPos != std::string::npos) { |
| 151 | curScale = col.length() - ptPos - 1; |
| 152 | num = col.substr(0, ptPos) + col.substr(ptPos + 1); |
| 153 | } |
| 154 | orc::Int128 decimal(num); |
| 155 | while (curScale != scale) { |
| 156 | curScale++; |
| 157 | decimal *= 10; |
| 158 | } |
| 159 | if (precision <= 18) { |
| 160 | d64Batch->values[i] = decimal.toLong(); |
| 161 | } else { |
| 162 | d128Batch->values[i] = decimal; |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | batch->hasNulls = hasNull; |
| 167 | batch->numElements = numValues; |
| 168 | } |
| 169 | |
| 170 | void fillBoolValues(const std::vector<std::string>& data, orc::ColumnVectorBatch* batch, |
| 171 | uint64_t numValues, uint64_t colIndex) { |
no test coverage detected