ColumnUnique.h 20.7 KB
Newer Older
1
#pragma once
2
#include <Columns/IColumnUnique.h>
3 4
#include <Columns/ReverseIndex.h>

5 6
#include <Columns/ColumnVector.h>
#include <Columns/ColumnNullable.h>
7
#include <Columns/ColumnString.h>
8
#include <Columns/ColumnFixedString.h>
9

N
Nikolai Kochetov 已提交
10
#include <DataTypes/DataTypeNullable.h>
11
#include <DataTypes/NumberTraits.h>
12

13 14
#include <Common/typeid_cast.h>
#include <ext/range.h>
15

A
Alexey Milovidov 已提交
16 17 18
#include <common/unaligned.h>


19 20 21
namespace DB
{

P
proller 已提交
22 23 24 25
namespace ErrorCodes
{
    extern const int ILLEGAL_COLUMN;
}
26

27
template <typename ColumnType>
28
class ColumnUnique final : public COWHelper<IColumnUnique, ColumnUnique<ColumnType>>
29
{
30
    friend class COWHelper<IColumnUnique, ColumnUnique<ColumnType>>;
31 32

private:
33
    explicit ColumnUnique(MutableColumnPtr && holder, bool is_nullable);
34
    explicit ColumnUnique(const IDataType & type);
35
    ColumnUnique(const ColumnUnique & other);
36

37
public:
38 39 40
    MutableColumnPtr cloneEmpty() const override;

    const ColumnPtr & getNestedColumn() const override;
41
    const ColumnPtr & getNestedNotNullableColumn() const override { return column_holder; }
42
    bool nestedColumnIsNullable() const override { return is_nullable; }
43

44 45
    size_t uniqueInsert(const Field & x) override;
    size_t uniqueInsertFrom(const IColumn & src, size_t n) override;
46 47 48
    MutableColumnPtr uniqueInsertRangeFrom(const IColumn & src, size_t start, size_t length) override;
    IColumnUnique::IndexesWithOverflow uniqueInsertRangeWithOverflow(const IColumn & src, size_t start, size_t length,
                                                                     size_t max_dictionary_size) override;
49 50
    size_t uniqueInsertData(const char * pos, size_t length) override;
    size_t uniqueDeserializeAndInsertFromArena(const char * pos, const char *& new_pos) override;
51

52
    size_t getDefaultValueIndex() const override { return 0; }
53
    size_t getNullValueIndex() const override;
54
    size_t getNestedTypeDefaultValueIndex() const override { return is_nullable ? 1 : 0; }
55 56
    bool canContainNulls() const override { return is_nullable; }

57 58 59
    Field operator[](size_t n) const override { return (*getNestedColumn())[n]; }
    void get(size_t n, Field & res) const override { getNestedColumn()->get(n, res); }
    StringRef getDataAt(size_t n) const override { return getNestedColumn()->getDataAt(n); }
N
Nikolai Kochetov 已提交
60 61
    StringRef getDataAtWithTerminatingZero(size_t n) const override
    {
62
        return getNestedColumn()->getDataAtWithTerminatingZero(n);
N
Nikolai Kochetov 已提交
63
    }
64 65 66
    UInt64 get64(size_t n) const override { return getNestedColumn()->get64(n); }
    UInt64 getUInt(size_t n) const override { return getNestedColumn()->getUInt(n); }
    Int64 getInt(size_t n) const override { return getNestedColumn()->getInt(n); }
67 68
    Float64 getFloat64(size_t n) const override { return getNestedColumn()->getFloat64(n); }
    bool getBool(size_t n) const override { return getNestedColumn()->getBool(n); }
69
    bool isNullAt(size_t n) const override { return is_nullable && n == getNullValueIndex(); }
70
    StringRef serializeValueIntoArena(size_t n, Arena & arena, char const *& begin) const override;
71
    void updateHashWithValue(size_t n, SipHash & hash_func) const override
N
Nikolai Kochetov 已提交
72
    {
73
        return getNestedColumn()->updateHashWithValue(n, hash_func);
N
Nikolai Kochetov 已提交
74
    }
75

76
    int compareAt(size_t n, size_t m, const IColumn & rhs, int nan_direction_hint) const override;
77

78 79 80 81 82 83 84
    void getExtremes(Field & min, Field & max) const override { column_holder->getExtremes(min, max); }
    bool valuesHaveFixedSize() const override { return column_holder->valuesHaveFixedSize(); }
    bool isFixedAndContiguous() const override { return column_holder->isFixedAndContiguous(); }
    size_t sizeOfValueIfFixed() const override { return column_holder->sizeOfValueIfFixed(); }
    bool isNumeric() const override { return column_holder->isNumeric(); }

    size_t byteSize() const override { return column_holder->byteSize(); }
85
    void protect() override { column_holder->protect(); }
N
Nikolai Kochetov 已提交
86 87
    size_t allocatedBytes() const override
    {
88
        return column_holder->allocatedBytes()
89
               + index.allocatedBytes()
90
               + (nested_null_mask ? nested_null_mask->allocatedBytes() : 0);
91 92 93
    }
    void forEachSubcolumn(IColumn::ColumnCallback callback) override
    {
94
        callback(column_holder);
95
        index.setColumn(getRawColumnPtr());
96 97
        if (is_nullable)
            nested_column_nullable = ColumnNullable::create(column_holder, nested_null_mask);
N
Nikolai Kochetov 已提交
98
    }
99

100 101 102 103 104 105 106
    bool structureEquals(const IColumn & rhs) const override
    {
        if (auto rhs_concrete = typeid_cast<const ColumnUnique *>(&rhs))
            return column_holder->structureEquals(*rhs_concrete->column_holder);
        return false;
    }

107 108
    const UInt64 * tryGetSavedHash() const override { return index.tryGetSavedHash(); }

109 110
    UInt128 getHash() const override { return hash.getHash(*getRawColumnPtr()); }

111 112
private:

113
    IColumn::WrappedPtr column_holder;
114
    bool is_nullable;
115
    size_t size_of_value_if_fixed = 0;
116
    ReverseIndex<UInt64, ColumnType> index;
N
Nikolai Kochetov 已提交
117

118
    /// For DataTypeNullable, stores null map.
119 120
    IColumn::WrappedPtr nested_null_mask;
    IColumn::WrappedPtr nested_column_nullable;
N
Nikolai Kochetov 已提交
121

122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
    class IncrementalHash
    {
    private:
        UInt128 hash;
        std::atomic<size_t> num_added_rows;

        std::mutex mutex;
    public:
        IncrementalHash() : num_added_rows(0) {}

        UInt128 getHash(const ColumnType & column);
    };

    mutable IncrementalHash hash;

137
    void createNullMask();
138 139
    void updateNullMask();

140 141
    static size_t numSpecialValues(bool is_nullable) { return is_nullable ? 2 : 1; }
    size_t numSpecialValues() const { return numSpecialValues(is_nullable); }
142

143
    ColumnType * getRawColumnPtr() { return static_cast<ColumnType *>(column_holder.get()); }
144
    const ColumnType * getRawColumnPtr() const { return static_cast<const ColumnType *>(column_holder.get()); }
145

146 147
    template <typename IndexType>
    MutableColumnPtr uniqueInsertRangeImpl(
148 149 150
        const IColumn & src,
        size_t start,
        size_t length,
151
        size_t num_added_rows,
152
        typename ColumnVector<IndexType>::MutablePtr && positions_column,
153
        ReverseIndex<UInt64, ColumnType> * secondary_index,
154
        size_t max_dictionary_size);
155 156
};

157 158 159 160 161 162
template <typename ColumnType>
MutableColumnPtr ColumnUnique<ColumnType>::cloneEmpty() const
{
    return ColumnUnique<ColumnType>::create(column_holder->cloneResized(numSpecialValues()), is_nullable);
}

163
template <typename ColumnType>
164 165 166
ColumnUnique<ColumnType>::ColumnUnique(const ColumnUnique & other)
    : column_holder(other.column_holder)
    , is_nullable(other.is_nullable)
167
    , size_of_value_if_fixed (other.size_of_value_if_fixed)
168 169 170
    , index(numSpecialValues(is_nullable), 0)
{
    index.setColumn(getRawColumnPtr());
171
    createNullMask();
172 173 174 175 176 177
}

template <typename ColumnType>
ColumnUnique<ColumnType>::ColumnUnique(const IDataType & type)
    : is_nullable(type.isNullable())
    , index(numSpecialValues(is_nullable), 0)
N
Nikolai Kochetov 已提交
178
{
179 180
    const auto & holder_type = is_nullable ? *static_cast<const DataTypeNullable &>(type).getNestedType() : type;
    column_holder = holder_type.createColumn()->cloneResized(numSpecialValues());
181
    index.setColumn(getRawColumnPtr());
182
    createNullMask();
183 184 185

    if (column_holder->valuesHaveFixedSize())
        size_of_value_if_fixed = column_holder->sizeOfValueIfFixed();
N
Nikolai Kochetov 已提交
186 187
}

188 189
template <typename ColumnType>
ColumnUnique<ColumnType>::ColumnUnique(MutableColumnPtr && holder, bool is_nullable)
190 191 192
    : column_holder(std::move(holder))
    , is_nullable(is_nullable)
    , index(numSpecialValues(is_nullable), 0)
193
{
194 195
    if (column_holder->size() < numSpecialValues())
        throw Exception("Too small holder column for ColumnUnique.", ErrorCodes::ILLEGAL_COLUMN);
C
chertus 已提交
196
    if (isColumnNullable(*column_holder))
197
        throw Exception("Holder column for ColumnUnique can't be nullable.", ErrorCodes::ILLEGAL_COLUMN);
198 199

    index.setColumn(getRawColumnPtr());
200
    createNullMask();
201 202 203

    if (column_holder->valuesHaveFixedSize())
        size_of_value_if_fixed = column_holder->sizeOfValueIfFixed();
204 205
}

206
template <typename ColumnType>
207
void ColumnUnique<ColumnType>::createNullMask()
N
Nikolai Kochetov 已提交
208 209 210
{
    if (is_nullable)
    {
211
        size_t size = getRawColumnPtr()->size();
212
        if (!nested_null_mask)
213 214 215
        {
            ColumnUInt8::MutablePtr null_mask = ColumnUInt8::create(size, UInt8(0));
            null_mask->getData()[getNullValueIndex()] = 1;
216 217
            nested_null_mask = std::move(null_mask);
            nested_column_nullable = ColumnNullable::create(column_holder, nested_null_mask);
218
        }
219 220 221 222 223 224 225 226 227 228 229 230 231 232
        else
            throw Exception("Null mask for ColumnUnique is already created.", ErrorCodes::LOGICAL_ERROR);
    }
}

template <typename ColumnType>
void ColumnUnique<ColumnType>::updateNullMask()
{
    if (is_nullable)
    {
        if (!nested_null_mask)
            throw Exception("Null mask for ColumnUnique is was not created.", ErrorCodes::LOGICAL_ERROR);

        size_t size = getRawColumnPtr()->size();
233

234
        if (nested_null_mask->size() != size)
235
            static_cast<ColumnUInt8 &>(*nested_null_mask).getData().resize_fill(size);
N
Nikolai Kochetov 已提交
236
    }
237 238 239 240 241 242 243 244
}

template <typename ColumnType>
const ColumnPtr & ColumnUnique<ColumnType>::getNestedColumn() const
{
    if (is_nullable)
        return nested_column_nullable;

N
Nikolai Kochetov 已提交
245 246 247
    return column_holder;
}

248 249
template <typename ColumnType>
size_t ColumnUnique<ColumnType>::getNullValueIndex() const
250 251
{
    if (!is_nullable)
252
        throw Exception("ColumnUnique can't contain null values.", ErrorCodes::LOGICAL_ERROR);
253 254 255 256

    return 0;
}

257 258
template <typename ColumnType>
size_t ColumnUnique<ColumnType>::uniqueInsert(const Field & x)
259 260 261 262
{
    if (x.getType() == Field::Types::Null)
        return getNullValueIndex();

263 264
    if (size_of_value_if_fixed)
        return uniqueInsertData(&x.get<char>(), size_of_value_if_fixed);
265

266 267
    auto & val = x.get<String>();
    return uniqueInsertData(val.data(), val.size());
268 269
}

270 271
template <typename ColumnType>
size_t ColumnUnique<ColumnType>::uniqueInsertFrom(const IColumn & src, size_t n)
272
{
273 274 275
    if (is_nullable && src.isNullAt(n))
        return getNullValueIndex();

C
chertus 已提交
276
    if (auto * nullable = checkAndGetColumn<ColumnNullable>(src))
277 278
        return uniqueInsertFrom(nullable->getNestedColumn(), n);

279 280 281 282
    auto ref = src.getDataAt(n);
    return uniqueInsertData(ref.data, ref.size);
}

283 284
template <typename ColumnType>
size_t ColumnUnique<ColumnType>::uniqueInsertData(const char * pos, size_t length)
285 286 287
{
    auto column = getRawColumnPtr();

288 289
    if (column->getDataAt(getNestedTypeDefaultValueIndex()) == StringRef(pos, length))
        return getNestedTypeDefaultValueIndex();
290

291
    auto insertion_point = index.insert(StringRef(pos, length));
292

293 294
    updateNullMask();

295
    return insertion_point;
296 297
}

298 299 300 301 302
template <typename ColumnType>
StringRef ColumnUnique<ColumnType>::serializeValueIntoArena(size_t n, Arena & arena, char const *& begin) const
{
    if (is_nullable)
    {
303
        static constexpr auto s = sizeof(UInt8);
304

305 306 307
        auto pos = arena.allocContinue(s, begin);
        UInt8 flag = (n == getNullValueIndex() ? 1 : 0);
        unalignedStore<UInt8>(pos, flag);
308

309 310
        if (n == getNullValueIndex())
            return StringRef(pos, s);
311

312
        auto nested_ref = column_holder->serializeValueIntoArena(n, arena, begin);
313

314 315
        /// serializeValueIntoArena may reallocate memory. Have to use ptr from nested_ref.data and move it back.
        return StringRef(nested_ref.data - s, nested_ref.size + s);
316 317 318 319 320
    }

    return column_holder->serializeValueIntoArena(n, arena, begin);
}

321 322
template <typename ColumnType>
size_t ColumnUnique<ColumnType>::uniqueDeserializeAndInsertFromArena(const char * pos, const char *& new_pos)
323
{
324 325 326 327 328 329 330 331 332 333 334 335
    if (is_nullable)
    {
        UInt8 val = *reinterpret_cast<const UInt8 *>(pos);
        pos += sizeof(val);

        if (val)
        {
            new_pos = pos;
            return getNullValueIndex();
        }
    }

N
Nikolai Kochetov 已提交
336
    /// Numbers, FixedString
337
    if (size_of_value_if_fixed)
338
    {
339 340
        new_pos = pos + size_of_value_if_fixed;
        return uniqueInsertData(pos, size_of_value_if_fixed);
341 342
    }

N
Nikolai Kochetov 已提交
343
    /// String
A
Alexey Milovidov 已提交
344
    const size_t string_size = unalignedLoad<size_t>(pos);
345 346
    pos += sizeof(string_size);
    new_pos = pos + string_size;
347

N
Nikolai Kochetov 已提交
348 349
    /// -1 because of terminating zero
    return uniqueInsertData(pos, string_size - 1);
350 351
}

352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
template <typename ColumnType>
int ColumnUnique<ColumnType>::compareAt(size_t n, size_t m, const IColumn & rhs, int nan_direction_hint) const
{
    if (is_nullable)
    {
        /// See ColumnNullable::compareAt
        bool lval_is_null = n == getNullValueIndex();
        bool rval_is_null = m == getNullValueIndex();

        if (unlikely(lval_is_null || rval_is_null))
        {
            if (lval_is_null && rval_is_null)
                return 0;
            else
                return lval_is_null ? nan_direction_hint : -nan_direction_hint;
        }
    }

    auto & column_unique = static_cast<const IColumnUnique &>(rhs);
    return getNestedColumn()->compareAt(n, m, *column_unique.getNestedColumn(), nan_direction_hint);
}

374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
template <typename IndexType>
static void checkIndexes(const ColumnVector<IndexType> & indexes, size_t max_dictionary_size)
{
    auto & data = indexes.getData();
    for (size_t i = 0; i < data.size(); ++i)
    {
        if (data[i] >= max_dictionary_size)
        {
            throw Exception("Found index " + toString(data[i]) + " at position " + toString(i)
                            + " which is grated or equal than dictionary size " + toString(max_dictionary_size),
                            ErrorCodes::LOGICAL_ERROR);
        }
    }
}

389 390 391
template <typename ColumnType>
template <typename IndexType>
MutableColumnPtr ColumnUnique<ColumnType>::uniqueInsertRangeImpl(
392 393 394
    const IColumn & src,
    size_t start,
    size_t length,
395
    size_t num_added_rows,
396
    typename ColumnVector<IndexType>::MutablePtr && positions_column,
397
    ReverseIndex<UInt64, ColumnType> * secondary_index,
398
    size_t max_dictionary_size)
399 400 401
{
    const ColumnType * src_column;
    const NullMap * null_map = nullptr;
402 403
    auto & positions = positions_column->getData();

404
    auto update_position = [&](UInt64 & next_position) -> MutableColumnPtr
405
    {
406 407 408
        constexpr auto next_size = NumberTraits::nextSize(sizeof(IndexType));
        using SuperiorIndexType = typename NumberTraits::Construct<false, false, next_size>::Type;

409 410 411 412 413 414 415 416
        ++next_position;

        if (next_position > std::numeric_limits<IndexType>::max())
        {
            if (sizeof(SuperiorIndexType) == sizeof(IndexType))
                throw Exception("Can't find superior index type for type " + demangle(typeid(IndexType).name()),
                                ErrorCodes::LOGICAL_ERROR);

417
            auto expanded_column = ColumnVector<SuperiorIndexType>::create(length);
418 419 420 421 422 423
            auto & expanded_data = expanded_column->getData();
            for (size_t i = 0; i < num_added_rows; ++i)
                expanded_data[i] = positions[i];

            return uniqueInsertRangeImpl<SuperiorIndexType>(
                    src,
424 425 426
                    start,
                    length,
                    num_added_rows,
427
                    std::move(expanded_column),
428
                    secondary_index,
429 430 431 432 433
                    max_dictionary_size);
        }

        return nullptr;
    };
434

C
chertus 已提交
435
    if (auto * nullable_column = checkAndGetColumn<ColumnNullable>(src))
436
    {
437
        src_column = typeid_cast<const ColumnType *>(&nullable_column->getNestedColumn());
438 439 440
        null_map = &nullable_column->getNullMapData();
    }
    else
441
        src_column = typeid_cast<const ColumnType *>(&src);
442

443 444 445
    if (src_column == nullptr)
        throw Exception("Invalid column type for ColumnUnique::insertRangeFrom. Expected " + column_holder->getName() +
                        ", got " + src.getName(), ErrorCodes::ILLEGAL_COLUMN);
446

447 448
    auto column = getRawColumnPtr();

449
    UInt64 next_position = column->size();
450 451 452
    if (secondary_index)
        next_position += secondary_index->size();

453
    auto insert_key = [&](const StringRef & ref, ReverseIndex<UInt64, ColumnType> & cur_index) -> MutableColumnPtr
454
    {
455 456 457 458
        auto inserted_pos = cur_index.insert(ref);
        positions[num_added_rows] = inserted_pos;
        if (inserted_pos == next_position)
            return update_position(next_position);
459

460
        return nullptr;
461 462
    };

463
    for (; num_added_rows < length; ++num_added_rows)
464
    {
465
        auto row = start + num_added_rows;
466

N
Nikolai Kochetov 已提交
467
        if (null_map && (*null_map)[row])
468
            positions[num_added_rows] = getNullValueIndex();
469 470
        else if (column->compareAt(getNestedTypeDefaultValueIndex(), row, *src_column, 1) == 0)
            positions[num_added_rows] = getNestedTypeDefaultValueIndex();
471 472
        else
        {
473
            auto ref = src_column->getDataAt(row);
474
            MutableColumnPtr res = nullptr;
475

476
            if (secondary_index && next_position >= max_dictionary_size)
477
            {
478 479 480
                auto insertion_point = index.getInsertionPoint(ref);
                if (insertion_point == index.lastInsertionPoint())
                    res = insert_key(ref, *secondary_index);
481
                else
482
                    positions[num_added_rows] = insertion_point;
483
            }
484 485 486 487 488
            else
                res = insert_key(ref, index);

            if (res)
                return res;
489 490
        }
    }
491

492
    // checkIndexes(*positions_column, column->size() + (overflowed_keys ? overflowed_keys->size() : 0));
493
    return std::move(positions_column);
494 495
}

496 497
template <typename ColumnType>
MutableColumnPtr ColumnUnique<ColumnType>::uniqueInsertRangeFrom(const IColumn & src, size_t start, size_t length)
498
{
499
    auto callForType = [this, &src, start, length](auto x) -> MutableColumnPtr
500
    {
501 502
        size_t size = getRawColumnPtr()->size();

503 504 505
        using IndexType = decltype(x);
        if (size <= std::numeric_limits<IndexType>::max())
        {
506
            auto positions = ColumnVector<IndexType>::create(length);
507
            return this->uniqueInsertRangeImpl<IndexType>(src, start, length, 0, std::move(positions), nullptr, 0);
508
        }
509

510 511 512 513 514 515 516 517 518 519 520 521 522 523
        return nullptr;
    };

    MutableColumnPtr positions_column;
    if (!positions_column)
        positions_column = callForType(UInt8());
    if (!positions_column)
        positions_column = callForType(UInt16());
    if (!positions_column)
        positions_column = callForType(UInt32());
    if (!positions_column)
        positions_column = callForType(UInt64());
    if (!positions_column)
        throw Exception("Can't find index type for ColumnUnique", ErrorCodes::LOGICAL_ERROR);
524

525 526
    updateNullMask();

527 528 529
    return positions_column;
}

530 531
template <typename ColumnType>
IColumnUnique::IndexesWithOverflow ColumnUnique<ColumnType>::uniqueInsertRangeWithOverflow(
532 533 534 535 536 537 538 539 540 541
    const IColumn & src,
    size_t start,
    size_t length,
    size_t max_dictionary_size)
{
    auto overflowed_keys = column_holder->cloneEmpty();
    auto overflowed_keys_ptr = typeid_cast<ColumnType *>(overflowed_keys.get());
    if (!overflowed_keys_ptr)
        throw Exception("Invalid keys type for ColumnUnique.", ErrorCodes::LOGICAL_ERROR);

542
    auto callForType = [this, &src, start, length, overflowed_keys_ptr, max_dictionary_size](auto x) -> MutableColumnPtr
543
    {
544 545
        size_t size = getRawColumnPtr()->size();

546 547 548
        using IndexType = decltype(x);
        if (size <= std::numeric_limits<IndexType>::max())
        {
549
            auto positions = ColumnVector<IndexType>::create(length);
550 551
            ReverseIndex<UInt64, ColumnType> secondary_index(0, max_dictionary_size);
            secondary_index.setColumn(overflowed_keys_ptr);
552
            return this->uniqueInsertRangeImpl<IndexType>(src, start, length, 0, std::move(positions),
553
                                                          &secondary_index, max_dictionary_size);
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
        }

        return nullptr;
    };

    MutableColumnPtr positions_column;
    if (!positions_column)
        positions_column = callForType(UInt8());
    if (!positions_column)
        positions_column = callForType(UInt16());
    if (!positions_column)
        positions_column = callForType(UInt32());
    if (!positions_column)
        positions_column = callForType(UInt64());
    if (!positions_column)
        throw Exception("Can't find index type for ColumnUnique", ErrorCodes::LOGICAL_ERROR);
570

571 572
    updateNullMask();

573 574 575 576 577 578
    IColumnUnique::IndexesWithOverflow indexes_with_overflow;
    indexes_with_overflow.indexes = std::move(positions_column);
    indexes_with_overflow.overflowed_keys = std::move(overflowed_keys);
    return indexes_with_overflow;
}

579 580 581 582
template <typename ColumnType>
UInt128 ColumnUnique<ColumnType>::IncrementalHash::getHash(const ColumnType & column)
{
    size_t column_size = column.size();
583
    UInt128 cur_hash;
584 585 586 587 588 589 590 591

    if (column_size != num_added_rows.load())
    {
        SipHash sip_hash;
        for (size_t i = 0; i < column_size; ++i)
            column.updateHashWithValue(i, sip_hash);

        std::lock_guard lock(mutex);
592 593 594 595 596 597 598 599
        sip_hash.get128(hash.low, hash.high);
        cur_hash = hash;
        num_added_rows.store(column_size);
    }
    else
    {
        std::lock_guard lock(mutex);
        cur_hash = hash;
600 601 602 603 604
    }

    return cur_hash;
}

605
}