diff --git a/src/Common/HashTable/ClearableHashSet.h b/src/Common/HashTable/ClearableHashSet.h index 371302dd8a9..bc94675073e 100644 --- a/src/Common/HashTable/ClearableHashSet.h +++ b/src/Common/HashTable/ClearableHashSet.h @@ -19,11 +19,9 @@ struct ClearableHashSetState /// Serialization, in binary and text form. void write(DB::WriteBuffer & wb) const { DB::writeBinary(version, wb); } - void writeText(DB::WriteBuffer & wb) const { DB::writeText(version, wb); } /// Deserialization, in binary and text form. void read(DB::ReadBuffer & rb) { DB::readBinary(version, rb); } - void readText(DB::ReadBuffer & rb) { DB::readText(version, rb); } }; diff --git a/src/Common/HashTable/FixedHashTable.h b/src/Common/HashTable/FixedHashTable.h index d96e4d7342f..1e3be0bf0e5 100644 --- a/src/Common/HashTable/FixedHashTable.h +++ b/src/Common/HashTable/FixedHashTable.h @@ -395,26 +395,6 @@ public: } } - void writeText(DB::WriteBuffer & wb) const - { - Cell::State::writeText(wb); - DB::writeText(size(), wb); - - if (!buf) - return; - - for (auto ptr = buf, buf_end = buf + NUM_CELLS; ptr < buf_end; ++ptr) - { - if (!ptr->isZero(*this)) - { - DB::writeChar(',', wb); - DB::writeText(ptr - buf, wb); - DB::writeChar(',', wb); - ptr->writeText(wb); - } - } - } - void read(DB::ReadBuffer & rb) { Cell::State::read(rb); @@ -435,28 +415,6 @@ public: } } - void readText(DB::ReadBuffer & rb) - { - Cell::State::readText(rb); - destroyElements(); - size_t m_size; - DB::readText(m_size, rb); - this->setSize(m_size); - free(); - alloc(); - - for (size_t i = 0; i < m_size; ++i) - { - size_t place_value = 0; - DB::assertChar(',', rb); - DB::readText(place_value, rb); - Cell x; - DB::assertChar(',', rb); - x.readText(rb); - new (&buf[place_value]) Cell(x, *this); - } - } - size_t size() const { return this->getSize(buf, *this, NUM_CELLS); } bool empty() const { return this->isEmpty(buf, *this, NUM_CELLS); } diff --git a/src/Common/HashTable/HashMap.h b/src/Common/HashTable/HashMap.h index dc3e9a392bc..d1eb0d52345 100644 --- a/src/Common/HashTable/HashMap.h +++ b/src/Common/HashTable/HashMap.h @@ -103,13 +103,6 @@ struct HashMapCell DB::writeBinary(value.second, wb); } - void writeText(DB::WriteBuffer & wb) const - { - DB::writeDoubleQuoted(value.first, wb); - DB::writeChar(',', wb); - DB::writeDoubleQuoted(value.second, wb); - } - /// Deserialization, in binary and text form. void read(DB::ReadBuffer & rb) { @@ -117,13 +110,6 @@ struct HashMapCell DB::readBinary(value.second, rb); } - void readText(DB::ReadBuffer & rb) - { - DB::readDoubleQuoted(value.first, rb); - DB::assertChar(',', rb); - DB::readDoubleQuoted(value.second, rb); - } - static bool constexpr need_to_notify_cell_during_move = false; static void move(HashMapCell * /* old_location */, HashMapCell * /* new_location */) {} diff --git a/src/Common/HashTable/HashSet.h b/src/Common/HashTable/HashSet.h index 22c982a1cf8..e1bc43172b5 100644 --- a/src/Common/HashTable/HashSet.h +++ b/src/Common/HashTable/HashSet.h @@ -44,24 +44,6 @@ public: if (!rhs.buf[i].isZero(*this)) this->insert(rhs.buf[i].getValue()); } - - - void readAndMerge(DB::ReadBuffer & rb) - { - Cell::State::read(rb); - - size_t new_size = 0; - DB::readVarUInt(new_size, rb); - - this->resize(new_size); - - for (size_t i = 0; i < new_size; ++i) - { - Cell x; - x.read(rb); - this->insert(x.getValue()); - } - } }; diff --git a/src/Common/HashTable/HashTable.h b/src/Common/HashTable/HashTable.h index 837647cb8bd..a092fe2321a 100644 --- a/src/Common/HashTable/HashTable.h +++ b/src/Common/HashTable/HashTable.h @@ -57,11 +57,9 @@ struct HashTableNoState { /// Serialization, in binary and text form. void write(DB::WriteBuffer &) const {} - void writeText(DB::WriteBuffer &) const {} /// Deserialization, in binary and text form. void read(DB::ReadBuffer &) {} - void readText(DB::ReadBuffer &) {} }; @@ -200,11 +198,9 @@ struct HashTableCell /// Serialization, in binary and text form. void write(DB::WriteBuffer & wb) const { DB::writeBinary(key, wb); } - void writeText(DB::WriteBuffer & wb) const { DB::writeDoubleQuoted(key, wb); } /// Deserialization, in binary and text form. void read(DB::ReadBuffer & rb) { DB::readBinary(key, rb); } - void readText(DB::ReadBuffer & rb) { DB::readDoubleQuoted(key, rb); } /// When cell pointer is moved during erase, reinsert or resize operations @@ -1255,30 +1251,6 @@ public: ptr->write(wb); } - void writeText(DB::WriteBuffer & wb) const - { - Cell::State::writeText(wb); - DB::writeText(m_size, wb); - - if (this->hasZero()) - { - DB::writeChar(',', wb); - this->zeroValue()->writeText(wb); - } - - if (!buf) - return; - - for (auto ptr = buf, buf_end = buf + grower.bufSize(); ptr < buf_end; ++ptr) - { - if (!ptr->isZero(*this)) - { - DB::writeChar(',', wb); - ptr->writeText(wb); - } - } - } - void read(DB::ReadBuffer & rb) { Cell::State::read(rb); @@ -1303,32 +1275,6 @@ public: } } - void readText(DB::ReadBuffer & rb) - { - Cell::State::readText(rb); - - destroyElements(); - this->clearHasZero(); - m_size = 0; - - size_t new_size = 0; - DB::readText(new_size, rb); - - free(); - Grower new_grower = grower; - new_grower.set(new_size); - alloc(new_grower); - - for (size_t i = 0; i < new_size; ++i) - { - Cell x; - DB::assertChar(',', rb); - x.readText(rb); - insert(x.getValue()); - } - } - - size_t size() const { return m_size; diff --git a/src/Common/HashTable/SmallTable.h b/src/Common/HashTable/SmallTable.h index b78901b03f6..d90d8dfa79d 100644 --- a/src/Common/HashTable/SmallTable.h +++ b/src/Common/HashTable/SmallTable.h @@ -259,18 +259,6 @@ public: buf[i].write(wb); } - void writeText(DB::WriteBuffer & wb) const - { - Cell::State::writeText(wb); - DB::writeText(m_size, wb); - - for (size_t i = 0; i < m_size; ++i) - { - DB::writeChar(',', wb); - buf[i].writeText(wb); - } - } - void read(DB::ReadBuffer & rb) { Cell::State::read(rb); @@ -289,28 +277,6 @@ public: m_size = new_size; } - void readText(DB::ReadBuffer & rb) - { - Cell::State::readText(rb); - - m_size = 0; - - size_t new_size = 0; - DB::readText(new_size, rb); - - if (new_size > capacity) - throw DB::Exception("Illegal size", DB::ErrorCodes::INCORRECT_DATA); - - for (size_t i = 0; i < new_size; ++i) - { - DB::assertChar(',', rb); - buf[i].readText(rb); - } - - m_size = new_size; - } - - size_t size() const { return m_size; diff --git a/src/Common/HashTable/StringHashTable.h b/src/Common/HashTable/StringHashTable.h index c947e746e8d..75dbfc9bdf2 100644 --- a/src/Common/HashTable/StringHashTable.h +++ b/src/Common/HashTable/StringHashTable.h @@ -141,9 +141,7 @@ public: } void write(DB::WriteBuffer & wb) const { zeroValue()->write(wb); } - void writeText(DB::WriteBuffer & wb) const { zeroValue()->writeText(wb); } void read(DB::ReadBuffer & rb) { zeroValue()->read(rb); } - void readText(DB::ReadBuffer & rb) { zeroValue()->readText(rb); } size_t size() const { return hasZero() ? 1 : 0; } bool empty() const { return !hasZero(); } size_t getBufferSizeInBytes() const { return sizeof(Cell); } @@ -379,19 +377,6 @@ public: ms.write(wb); } - void writeText(DB::WriteBuffer & wb) const - { - m0.writeText(wb); - DB::writeChar(',', wb); - m1.writeText(wb); - DB::writeChar(',', wb); - m2.writeText(wb); - DB::writeChar(',', wb); - m3.writeText(wb); - DB::writeChar(',', wb); - ms.writeText(wb); - } - void read(DB::ReadBuffer & rb) { m0.read(rb); @@ -401,19 +386,6 @@ public: ms.read(rb); } - void readText(DB::ReadBuffer & rb) - { - m0.readText(rb); - DB::assertChar(',', rb); - m1.readText(rb); - DB::assertChar(',', rb); - m2.readText(rb); - DB::assertChar(',', rb); - m3.readText(rb); - DB::assertChar(',', rb); - ms.readText(rb); - } - size_t size() const { return m0.size() + m1.size() + m2.size() + m3.size() + ms.size(); } bool empty() const { return m0.empty() && m1.empty() && m2.empty() && m3.empty() && ms.empty(); } diff --git a/src/Common/HashTable/TwoLevelHashTable.h b/src/Common/HashTable/TwoLevelHashTable.h index 5acc8b19195..abdac5e8d5d 100644 --- a/src/Common/HashTable/TwoLevelHashTable.h +++ b/src/Common/HashTable/TwoLevelHashTable.h @@ -290,33 +290,12 @@ public: impls[i].write(wb); } - void writeText(DB::WriteBuffer & wb) const - { - for (UInt32 i = 0; i < NUM_BUCKETS; ++i) - { - if (i != 0) - DB::writeChar(',', wb); - impls[i].writeText(wb); - } - } - void read(DB::ReadBuffer & rb) { for (UInt32 i = 0; i < NUM_BUCKETS; ++i) impls[i].read(rb); } - void readText(DB::ReadBuffer & rb) - { - for (UInt32 i = 0; i < NUM_BUCKETS; ++i) - { - if (i != 0) - DB::assertChar(',', rb); - impls[i].readText(rb); - } - } - - size_t size() const { size_t res = 0; diff --git a/src/Common/HashTable/TwoLevelStringHashTable.h b/src/Common/HashTable/TwoLevelStringHashTable.h index ea1914348b2..32bb25acd52 100644 --- a/src/Common/HashTable/TwoLevelStringHashTable.h +++ b/src/Common/HashTable/TwoLevelStringHashTable.h @@ -179,32 +179,12 @@ public: impls[i].write(wb); } - void writeText(DB::WriteBuffer & wb) const - { - for (UInt32 i = 0; i < NUM_BUCKETS; ++i) - { - if (i != 0) - DB::writeChar(',', wb); - impls[i].writeText(wb); - } - } - void read(DB::ReadBuffer & rb) { for (UInt32 i = 0; i < NUM_BUCKETS; ++i) impls[i].read(rb); } - void readText(DB::ReadBuffer & rb) - { - for (UInt32 i = 0; i < NUM_BUCKETS; ++i) - { - if (i != 0) - DB::assertChar(',', rb); - impls[i].readText(rb); - } - } - size_t size() const { size_t res = 0; diff --git a/src/Common/tests/gtest_hash_table.cpp b/src/Common/tests/gtest_hash_table.cpp index 0221a682577..aa17531e53d 100644 --- a/src/Common/tests/gtest_hash_table.cpp +++ b/src/Common/tests/gtest_hash_table.cpp @@ -258,29 +258,6 @@ TEST(HashTable, Erase) TEST(HashTable, SerializationDeserialization) { - { - /// Use dummy hash to make it reproducible if default hash implementation will be changed - using Cont = HashSet, HashTableGrowerWithPrecalculation<1>>; - - Cont cont; - - cont.insert(1); - cont.insert(2); - cont.insert(3); - - WriteBufferFromOwnString wb; - cont.writeText(wb); - - std::string expected = "3,1,2,3"; - - ASSERT_EQ(wb.str(), expected); - - ReadBufferFromString rb(expected); - - Cont deserialized; - deserialized.readText(rb); - ASSERT_EQ(convertToSet(cont), convertToSet(deserialized)); - } { using Cont = HashSet, HashTableGrowerWithPrecalculation<1>>; @@ -299,22 +276,6 @@ TEST(HashTable, SerializationDeserialization) deserialized.read(rb); ASSERT_EQ(convertToSet(cont), convertToSet(deserialized)); } - { - using Cont = HashSet, HashTableGrowerWithPrecalculation<1>>; - Cont cont; - - WriteBufferFromOwnString wb; - cont.writeText(wb); - - std::string expected = "0"; - ASSERT_EQ(wb.str(), expected); - - ReadBufferFromString rb(expected); - - Cont deserialized; - deserialized.readText(rb); - ASSERT_EQ(convertToSet(cont), convertToSet(deserialized)); - } { using Cont = HashSet; Cont cont;