MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / vector

Method vector

src/Functions/geohashEncode.cpp:78–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76
77private:
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}

Callers

nothing calls this directly

Calls 12

geohashEncodeFunction · 0.85
createFunction · 0.70
ExceptionClass · 0.50
getCharsMethod · 0.45
getOffsetsMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45
getFloat64Method · 0.45
get64Method · 0.45
emptyMethod · 0.45
backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected