@@ -237,100 +237,6 @@ static inline UInt128 ALWAYS_INLINE hash128(
237237 return key;
238238}
239239
240-
241- // / Copy keys to the pool. Then put into pool StringRefs to them and return the pointer to the first.
242- static inline StringRef * ALWAYS_INLINE placeKeysInPool (size_t keys_size, StringRefs & keys, Arena & pool)
243- {
244- for (size_t j = 0 ; j < keys_size; ++j)
245- {
246- char * place = pool.alloc (keys[j].size );
247- memcpy (place, keys[j].data , keys[j].size ); // / TODO padding in Arena and memcpySmall
248- keys[j].data = place;
249- }
250-
251- // / Place the StringRefs on the newly copied keys in the pool.
252- char * res = pool.alloc (keys_size * sizeof (StringRef));
253- memcpy (res, keys.data (), keys_size * sizeof (StringRef));
254-
255- return reinterpret_cast <StringRef *>(res);
256- }
257-
258- /*
259- /// Copy keys to the pool. Then put into pool StringRefs to them and return the pointer to the first.
260- static inline StringRef * ALWAYS_INLINE extractKeysAndPlaceInPool(
261- size_t i,
262- size_t keys_size,
263- const ColumnRawPtrs & key_columns,
264- StringRefs & keys,
265- Arena & pool)
266- {
267- for (size_t j = 0; j < keys_size; ++j)
268- {
269- keys[j] = key_columns[j]->getDataAtWithTerminatingZero(i);
270- char * place = pool.alloc(keys[j].size);
271- memcpy(place, keys[j].data, keys[j].size);
272- keys[j].data = place;
273- }
274-
275- /// Place the StringRefs on the newly copied keys in the pool.
276- char * res = pool.alloc(keys_size * sizeof(StringRef));
277- memcpy(res, keys.data(), keys_size * sizeof(StringRef));
278-
279- return reinterpret_cast<StringRef *>(res);
280- }
281-
282-
283- /// Copy the specified keys to a continuous memory chunk of a pool.
284- /// Subsequently append StringRef objects referring to each key.
285- ///
286- /// [key1][key2]...[keyN][ref1][ref2]...[refN]
287- /// ^ ^ : | |
288- /// +-----|--------:-----+ |
289- /// : +--------:-----------+
290- /// : :
291- /// <-------------->
292- /// (1)
293- ///
294- /// Return a StringRef object, referring to the area (1) of the memory
295- /// chunk that contains the keys. In other words, we ignore their StringRefs.
296- inline StringRef ALWAYS_INLINE extractKeysAndPlaceInPoolContiguous(
297- size_t i,
298- size_t keys_size,
299- const ColumnRawPtrs & key_columns,
300- StringRefs & keys,
301- const TiDB::TiDBCollators & collators,
302- std::vector<std::string> & sort_key_containers,
303- Arena & pool)
304- {
305- size_t sum_keys_size = 0;
306- for (size_t j = 0; j < keys_size; ++j)
307- {
308- keys[j] = key_columns[j]->getDataAtWithTerminatingZero(i);
309- if (!collators.empty() && collators[j] != nullptr)
310- {
311- // todo check if need to handle the terminating zero
312- keys[j] = collators[j]->sortKey(keys[j].data, keys[j].size - 1, sort_key_containers[j]);
313- }
314- sum_keys_size += keys[j].size;
315- }
316-
317- char * res = pool.alloc(sum_keys_size + keys_size * sizeof(StringRef));
318- char * place = res;
319-
320- for (size_t j = 0; j < keys_size; ++j)
321- {
322- memcpy(place, keys[j].data, keys[j].size);
323- keys[j].data = place;
324- place += keys[j].size;
325- }
326-
327- /// Place the StringRefs on the newly copied keys in the pool.
328- memcpy(place, keys.data(), keys_size * sizeof(StringRef));
329-
330- return {res, sum_keys_size};
331- }
332- */
333-
334240/* * Serialize keys into a continuous chunk of memory.
335241 */
336242static inline StringRef ALWAYS_INLINE serializeKeysToPoolContiguous (
0 commit comments