From 86d6673d615daacb0cc2071e4ac6f2d5ba6d6a3c Mon Sep 17 00:00:00 2001 From: Anton Popov Date: Sun, 16 May 2021 21:59:43 +0300 Subject: [PATCH] minor fixes --- src/Columns/ColumnSparse.h | 5 --- src/Columns/IColumn.cpp | 2 +- src/Columns/tests/gtest_column_sparse.cpp | 33 ++++++++++--------- src/Common/ya.make | 1 - src/DataTypes/DataTypeCustomIPv4AndIPv6.cpp | 6 ---- src/DataTypes/DataTypeFixedString.cpp | 1 - src/DataTypes/DataTypeTuple.cpp | 1 + src/DataTypes/IDataType.cpp | 2 +- .../Serializations/ISerialization.cpp | 2 ++ .../Serializations/SerializationIP.cpp | 1 + .../Serializations/SerializationNothing.h | 2 ++ .../Serializations/SerializationTuple.cpp | 1 - src/Functions/IFunction.cpp | 2 +- src/Functions/IFunctionAdaptors.h | 2 +- src/Interpreters/Aggregator.cpp | 2 +- .../MergeTree/MergeTreeDataPartWriterWide.cpp | 2 +- .../MergeTree/MergeTreeDataWriter.cpp | 3 -- tests/integration/test_merge_tree_s3/test.py | 4 +-- .../test_replicated_merge_tree_s3/test.py | 4 +-- .../test.py | 4 +-- 20 files changed, 36 insertions(+), 44 deletions(-) diff --git a/src/Columns/ColumnSparse.h b/src/Columns/ColumnSparse.h index cb7daa5482a..4167e6a7cc0 100644 --- a/src/Columns/ColumnSparse.h +++ b/src/Columns/ColumnSparse.h @@ -11,11 +11,6 @@ class Collator; namespace DB { -namespace ErrorCodes -{ - extern const int LOGICAL_ERROR; -} - class ColumnSparse final : public COWHelper { private: diff --git a/src/Columns/IColumn.cpp b/src/Columns/IColumn.cpp index e3626fd2c82..76334e0da6e 100644 --- a/src/Columns/IColumn.cpp +++ b/src/Columns/IColumn.cpp @@ -56,7 +56,7 @@ ColumnPtr IColumn::createWithOffsets(const Offsets & offsets, size_t total_rows) } ssize_t offsets_diff = static_cast(total_rows) - current_offset; - if(offsets_diff > 1) + if (offsets_diff > 1) res->insertManyFrom(*this, 0, offsets_diff - 1); return res; diff --git a/src/Columns/tests/gtest_column_sparse.cpp b/src/Columns/tests/gtest_column_sparse.cpp index e6078417a94..ac6351a8b21 100644 --- a/src/Columns/tests/gtest_column_sparse.cpp +++ b/src/Columns/tests/gtest_column_sparse.cpp @@ -54,6 +54,9 @@ bool checkEquals(const IColumn & lhs, const IColumn & rhs) return true; } +// Can't use ErrorCodes, because of 'using namespace DB'. +constexpr int error_code = 12345; + constexpr size_t T = 5000; constexpr size_t MAX_ROWS = 10000; constexpr size_t sparse_ratios[] = {1, 2, 5, 10, 32, 50, 64, 100, 256, 500, 1000, 5000, 10000}; @@ -79,7 +82,7 @@ TEST(ColumnSparse, InsertRangeFrom) DUMP_COLUMN(sparse_dst); DUMP_COLUMN(full_dst); DUMP_NON_DEFAULTS(full_dst); - throw Exception(ErrorCodes::LOGICAL_ERROR, "Columns are unequal"); + throw Exception(error_code, "Columns are unequal"); } }; @@ -102,7 +105,7 @@ TEST(ColumnSparse, InsertRangeFrom) test_case(n1, k1, n2, k2, from, to - from); } } - catch(const Exception & e) + catch (const Exception & e) { FAIL() << e.displayText(); } @@ -122,7 +125,7 @@ TEST(ColumnSparse, PopBack) DUMP_COLUMN(sparse_dst); DUMP_COLUMN(full_dst); DUMP_NON_DEFAULTS(full_dst); - throw Exception(ErrorCodes::LOGICAL_ERROR, "Columns are unequal"); + throw Exception(error_code, "Columns are unequal"); } }; @@ -137,7 +140,7 @@ TEST(ColumnSparse, PopBack) test_case(n, k, m); } } - catch(const Exception & e) + catch (const Exception & e) { FAIL() << e.displayText(); } @@ -163,7 +166,7 @@ TEST(ColumnSparse, Filter) DUMP_COLUMN(sparse_dst); DUMP_COLUMN(full_dst); DUMP_NON_DEFAULTS(full_dst); - throw Exception(ErrorCodes::LOGICAL_ERROR, "Columns are unequal"); + throw Exception(error_code, "Columns are unequal"); } }; @@ -178,7 +181,7 @@ TEST(ColumnSparse, Filter) test_case(n, k, m); } } - catch(const Exception & e) + catch (const Exception & e) { FAIL() << e.displayText(); } @@ -190,7 +193,7 @@ TEST(ColumnSparse, Permute) { auto [sparse_src, full_src] = createColumns(n, k); - PaddedPODArray perm(n); + IColumn::Permutation perm; std::iota(perm.begin(), perm.end(), 0); std::shuffle(perm.begin(), perm.end(), rng); @@ -210,7 +213,7 @@ TEST(ColumnSparse, Permute) DUMP_COLUMN(sparse_dst); DUMP_COLUMN(full_dst); DUMP_NON_DEFAULTS(full_dst); - throw Exception(ErrorCodes::LOGICAL_ERROR, "Columns are unequal"); + throw Exception(error_code, "Columns are unequal"); } }; @@ -225,7 +228,7 @@ TEST(ColumnSparse, Permute) test_case(n, k, limit); } } - catch(const Exception & e) + catch (const Exception & e) { FAIL() << e.displayText(); } @@ -250,7 +253,7 @@ TEST(ColumnSparse, CompareColumn) DUMP_COLUMN(full_src1); DUMP_COLUMN(sparse_src2); DUMP_COLUMN(full_src2); - throw Exception(ErrorCodes::LOGICAL_ERROR, "Compare results are unequal"); + throw Exception(error_code, "Compare results are unequal"); } }; @@ -269,7 +272,7 @@ TEST(ColumnSparse, CompareColumn) test_case(n1, k1, n2, k2, row_num); } } - catch(const Exception & e) + catch (const Exception & e) { FAIL() << e.displayText(); } @@ -281,8 +284,8 @@ TEST(ColumnSparse, GetPermutation) { auto [sparse_src, full_src] = createColumns(n, k); - PaddedPODArray perm_sparse; - PaddedPODArray perm_full; + IColumn::Permutation perm_sparse; + IColumn::Permutation perm_full; sparse_src->getPermutation(reverse, limit, 1, perm_sparse); full_src->getPermutation(reverse, limit, 1, perm_full); @@ -303,7 +306,7 @@ TEST(ColumnSparse, GetPermutation) DUMP_COLUMN(sparse_sorted); DUMP_COLUMN(full_sorted); DUMP_NON_DEFAULTS(full_sorted); - throw Exception(ErrorCodes::LOGICAL_ERROR, "Sorted columns are unequal"); + throw Exception(error_code, "Sorted columns are unequal"); } }; @@ -320,7 +323,7 @@ TEST(ColumnSparse, GetPermutation) test_case(n, k, limit, reverse); } } - catch(const Exception & e) + catch (const Exception & e) { FAIL() << e.displayText(); } diff --git a/src/Common/ya.make b/src/Common/ya.make index dde1e6ae013..f12b17827f7 100644 --- a/src/Common/ya.make +++ b/src/Common/ya.make @@ -18,7 +18,6 @@ PEERDIR( contrib/libs/openssl contrib/libs/poco/NetSSL_OpenSSL contrib/libs/re2 - contrib/libs/cxxsupp/libcxxabi-parts contrib/restricted/dragonbox ) diff --git a/src/DataTypes/DataTypeCustomIPv4AndIPv6.cpp b/src/DataTypes/DataTypeCustomIPv4AndIPv6.cpp index f0eeaa21be8..808aa43528e 100644 --- a/src/DataTypes/DataTypeCustomIPv4AndIPv6.cpp +++ b/src/DataTypes/DataTypeCustomIPv4AndIPv6.cpp @@ -5,12 +5,6 @@ namespace DB { -namespace ErrorCodes -{ - extern const int ILLEGAL_COLUMN; - extern const int CANNOT_PARSE_DOMAIN_VALUE_FROM_STRING; -} - void registerDataTypeDomainIPv4AndIPv6(DataTypeFactory & factory) { factory.registerSimpleDataTypeCustom("IPv4", [] diff --git a/src/DataTypes/DataTypeFixedString.cpp b/src/DataTypes/DataTypeFixedString.cpp index 4b6042febab..a40592ba023 100644 --- a/src/DataTypes/DataTypeFixedString.cpp +++ b/src/DataTypes/DataTypeFixedString.cpp @@ -25,7 +25,6 @@ namespace ErrorCodes { extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; extern const int UNEXPECTED_AST_STRUCTURE; - extern const int TOO_LARGE_STRING_SIZE; } diff --git a/src/DataTypes/DataTypeTuple.cpp b/src/DataTypes/DataTypeTuple.cpp index e5dcc327d5c..33a763e8fcf 100644 --- a/src/DataTypes/DataTypeTuple.cpp +++ b/src/DataTypes/DataTypeTuple.cpp @@ -36,6 +36,7 @@ namespace ErrorCodes extern const int ILLEGAL_COLUMN; extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; extern const int SIZES_OF_COLUMNS_IN_TUPLE_DOESNT_MATCH; + extern const int LOGICAL_ERROR; } diff --git a/src/DataTypes/IDataType.cpp b/src/DataTypes/IDataType.cpp index 2b844c05109..3c916cb80cb 100644 --- a/src/DataTypes/IDataType.cpp +++ b/src/DataTypes/IDataType.cpp @@ -192,7 +192,7 @@ SerializationPtr IDataType::getSerialization(const ISerialization::Kinds & kinds { if (!kinds.subcolumns.empty()) throw Exception(ErrorCodes::LOGICAL_ERROR,"Data type {} doesn't support " - "custom kinds of serialization for subcolumns ot doesn't have subcolumns at all.", getName()); + "custom kinds of serialization for subcolumns or doesn't have subcolumns at all.", getName()); if (kinds.main == ISerialization::Kind::SPARSE) return getSparseSerialization(); diff --git a/src/DataTypes/Serializations/ISerialization.cpp b/src/DataTypes/Serializations/ISerialization.cpp index 978ee05f3c2..a0bc0947dfa 100644 --- a/src/DataTypes/Serializations/ISerialization.cpp +++ b/src/DataTypes/Serializations/ISerialization.cpp @@ -24,6 +24,8 @@ String ISerialization::kindToString(Kind kind) case Kind::SPARSE: return "Sparse"; } + + __builtin_unreachable(); } void ISerialization::Kinds::writeBinary(WriteBuffer & ostr) const diff --git a/src/DataTypes/Serializations/SerializationIP.cpp b/src/DataTypes/Serializations/SerializationIP.cpp index d14122671d9..ec49f960c77 100644 --- a/src/DataTypes/Serializations/SerializationIP.cpp +++ b/src/DataTypes/Serializations/SerializationIP.cpp @@ -10,6 +10,7 @@ namespace DB namespace ErrorCodes { extern const int CANNOT_PARSE_DOMAIN_VALUE_FROM_STRING; + extern const int ILLEGAL_COLUMN; } SerializationIPv4::SerializationIPv4(const SerializationPtr & nested_) diff --git a/src/DataTypes/Serializations/SerializationNothing.h b/src/DataTypes/Serializations/SerializationNothing.h index e9d25c62ee0..a7b26c117bc 100644 --- a/src/DataTypes/Serializations/SerializationNothing.h +++ b/src/DataTypes/Serializations/SerializationNothing.h @@ -1,3 +1,5 @@ +#pragma once + #include #include diff --git a/src/DataTypes/Serializations/SerializationTuple.cpp b/src/DataTypes/Serializations/SerializationTuple.cpp index 0657b1bd43d..7893b5e3808 100644 --- a/src/DataTypes/Serializations/SerializationTuple.cpp +++ b/src/DataTypes/Serializations/SerializationTuple.cpp @@ -19,7 +19,6 @@ namespace ErrorCodes { extern const int SIZES_OF_COLUMNS_IN_TUPLE_DOESNT_MATCH; extern const int NOT_FOUND_COLUMN_IN_BLOCK; - extern const int LOGICAL_ERROR; } diff --git a/src/Functions/IFunction.cpp b/src/Functions/IFunction.cpp index 5fb4428227e..f1f25579f8b 100644 --- a/src/Functions/IFunction.cpp +++ b/src/Functions/IFunction.cpp @@ -467,7 +467,7 @@ ColumnPtr ExecutableFunctionAdaptor::execute(const ColumnsWithTypeAndName & argu { const auto * column_sparse = checkAndGetColumn(arguments[i].column.get()); /// In rare case, when sparse column doesn't have default values, - /// it's more convinient to convert it to full before execution of function. + /// it's more convenient to convert it to full before execution of function. if (column_sparse && column_sparse->getNumberOfDefaults()) { sparse_column_position = i; diff --git a/src/Functions/IFunctionAdaptors.h b/src/Functions/IFunctionAdaptors.h index 13886fb8660..9824d2a1659 100644 --- a/src/Functions/IFunctionAdaptors.h +++ b/src/Functions/IFunctionAdaptors.h @@ -35,7 +35,7 @@ private: const ColumnsWithTypeAndName & args, const DataTypePtr & result_type, size_t input_rows_count, bool dry_run) const; ColumnPtr executeWithoutSparseColumns( - const ColumnsWithTypeAndName & args, const DataTypePtr & result_type, size_t input_rows_count, bool dry_run) const; + const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, size_t input_rows_count, bool dry_run) const; }; class FunctionBaseAdaptor final : public IFunctionBase diff --git a/src/Interpreters/Aggregator.cpp b/src/Interpreters/Aggregator.cpp index f9e62bb5c50..54a47205d94 100644 --- a/src/Interpreters/Aggregator.cpp +++ b/src/Interpreters/Aggregator.cpp @@ -613,7 +613,7 @@ void NO_INLINE Aggregator::executeWithoutKeyImpl( if (inst->offsets) inst->batch_that->addBatchSinglePlace( inst->offsets[static_cast(rows - 1)], res + inst->state_offset, inst->batch_arguments, arena); - else if(inst->has_sparse_arguments) + else if (inst->has_sparse_arguments) inst->batch_that->addBatchSparseSinglePlace(res + inst->state_offset, inst->batch_arguments, arena); else inst->batch_that->addBatchSinglePlace(rows, res + inst->state_offset, inst->batch_arguments, arena); diff --git a/src/Storages/MergeTree/MergeTreeDataPartWriterWide.cpp b/src/Storages/MergeTree/MergeTreeDataPartWriterWide.cpp index f48feb48355..4c772d93152 100644 --- a/src/Storages/MergeTree/MergeTreeDataPartWriterWide.cpp +++ b/src/Storages/MergeTree/MergeTreeDataPartWriterWide.cpp @@ -403,7 +403,7 @@ void MergeTreeDataPartWriterWide::validateColumnOfFixedSize(const String & name, { const auto & serialization = serializations[name]; - if (!type.isValueRepresentedByNumber() || type.haveSubtypes() || serialization->getKind() != ISerialization::Kind::SPARSE) + if (!type.isValueRepresentedByNumber() || type.haveSubtypes() || serialization->getKind() != ISerialization::Kind::DEFAULT) throw Exception(ErrorCodes::LOGICAL_ERROR, "Cannot validate column of non fixed type {}", type.getName()); auto disk = data_part->volume->getDisk(); diff --git a/src/Storages/MergeTree/MergeTreeDataWriter.cpp b/src/Storages/MergeTree/MergeTreeDataWriter.cpp index 0cd5a6a2550..6cbe772bddf 100644 --- a/src/Storages/MergeTree/MergeTreeDataWriter.cpp +++ b/src/Storages/MergeTree/MergeTreeDataWriter.cpp @@ -564,9 +564,6 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataWriter::writeTempProjectionPart( const IMergeTreeDataPart * parent_part, size_t block_num) { - - - /// Size of part would not be greater than block.bytes() + epsilon size_t expected_size = block.bytes(); diff --git a/tests/integration/test_merge_tree_s3/test.py b/tests/integration/test_merge_tree_s3/test.py index c0c05355def..32c48df3db0 100644 --- a/tests/integration/test_merge_tree_s3/test.py +++ b/tests/integration/test_merge_tree_s3/test.py @@ -64,8 +64,8 @@ def cluster(): FILES_OVERHEAD = 1 FILES_OVERHEAD_PER_COLUMN = 2 # Data and mark files -FILES_OVERHEAD_PER_PART_WIDE = FILES_OVERHEAD_PER_COLUMN * 3 + 2 + 6 + 1 -FILES_OVERHEAD_PER_PART_COMPACT = 10 + 1 +FILES_OVERHEAD_PER_PART_WIDE = FILES_OVERHEAD_PER_COLUMN * 3 + 2 + 6 + 1 + 1 +FILES_OVERHEAD_PER_PART_COMPACT = 10 + 1 + 1 def random_string(length): diff --git a/tests/integration/test_replicated_merge_tree_s3/test.py b/tests/integration/test_replicated_merge_tree_s3/test.py index 3b3540ef1b8..ab5fb41eec5 100644 --- a/tests/integration/test_replicated_merge_tree_s3/test.py +++ b/tests/integration/test_replicated_merge_tree_s3/test.py @@ -32,8 +32,8 @@ def cluster(): FILES_OVERHEAD = 1 FILES_OVERHEAD_PER_COLUMN = 2 # Data and mark files -FILES_OVERHEAD_PER_PART_WIDE = FILES_OVERHEAD_PER_COLUMN * 3 + 2 + 6 + 1 -FILES_OVERHEAD_PER_PART_COMPACT = 10 + 1 +FILES_OVERHEAD_PER_PART_WIDE = FILES_OVERHEAD_PER_COLUMN * 3 + 2 + 6 + 1 + 1 +FILES_OVERHEAD_PER_PART_COMPACT = 10 + 1 + 1 def random_string(length): diff --git a/tests/integration/test_replicated_merge_tree_s3_zero_copy/test.py b/tests/integration/test_replicated_merge_tree_s3_zero_copy/test.py index 793abc53566..6d00a94733b 100644 --- a/tests/integration/test_replicated_merge_tree_s3_zero_copy/test.py +++ b/tests/integration/test_replicated_merge_tree_s3_zero_copy/test.py @@ -32,8 +32,8 @@ def cluster(): FILES_OVERHEAD = 1 FILES_OVERHEAD_PER_COLUMN = 2 # Data and mark files -FILES_OVERHEAD_PER_PART_WIDE = FILES_OVERHEAD_PER_COLUMN * 3 + 2 + 6 + 1 -FILES_OVERHEAD_PER_PART_COMPACT = 10 + 1 +FILES_OVERHEAD_PER_PART_WIDE = FILES_OVERHEAD_PER_COLUMN * 3 + 2 + 6 + 1 + 1 +FILES_OVERHEAD_PER_PART_COMPACT = 10 + 1 + 1 def random_string(length):