| 76 | |
| 77 | private: |
| 78 | void vector(const IColumn * lon_column, const IColumn * lat_column, const IColumn * precision_column, ColumnPtr & result, size_t input_rows_count) const |
| 79 | { |
| 80 | auto col_str = ColumnString::create(); |
| 81 | ColumnString::Chars & out_vec = col_str->getChars(); |
| 82 | ColumnString::Offsets & out_offsets = col_str->getOffsets(); |
| 83 | |
| 84 | out_offsets.resize(input_rows_count); |
| 85 | out_vec.resize(input_rows_count * GEOHASH_MAX_TEXT_LENGTH); |
| 86 | |
| 87 | char * begin = reinterpret_cast<char *>(out_vec.data()); |
| 88 | char * pos = begin; |
| 89 | |
| 90 | for (size_t i = 0; i < input_rows_count; ++i) |
| 91 | { |
| 92 | const Float64 longitude_value = lon_column->getFloat64(i); |
| 93 | const Float64 latitude_value = lat_column->getFloat64(i); |
| 94 | const UInt64 precision_value = std::min<UInt64>(precision_column->get64(i), GEOHASH_MAX_TEXT_LENGTH); |
| 95 | |
| 96 | const size_t encoded_size = geohashEncode(longitude_value, latitude_value, static_cast<UInt8>(precision_value), pos); |
| 97 | |
| 98 | pos += encoded_size; |
| 99 | out_offsets[i] = pos - begin; |
| 100 | } |
| 101 | out_vec.resize(pos - begin); |
| 102 | |
| 103 | if (!out_offsets.empty() && out_offsets.back() != out_vec.size()) |
| 104 | throw Exception(ErrorCodes::LOGICAL_ERROR, "Column size mismatch (internal logical error)"); |
| 105 | |
| 106 | result = std::move(col_str); |
| 107 | } |
| 108 | }; |
| 109 | |
| 110 | } |
nothing calls this directly
no test coverage detected