From 1b505829099034a026810e390536d530f688400f Mon Sep 17 00:00:00 2001 From: JaySon Date: Thu, 26 Aug 2021 08:54:04 +0800 Subject: [PATCH] Update style of clang-format (#2746) --- .ci/build.groovy | 2 +- .clang-format | 80 +++++++------ README.md | 2 + .../AggregateFunctions/IAggregateFunction.h | 112 +++++++++--------- dbms/src/Storages/DeltaMerge/File/DMFile.cpp | 75 ++++++++---- dbms/src/Storages/DeltaMerge/Segment.h | 105 +++++++++++----- dbms/src/Storages/DeltaMerge/Tuple.h | 19 +-- release-centos7/build/build-tiflash-ci.sh | 3 +- 8 files changed, 238 insertions(+), 160 deletions(-) diff --git a/.ci/build.groovy b/.ci/build.groovy index 139dec9317f..a40620c5838 100644 --- a/.ci/build.groovy +++ b/.ci/build.groovy @@ -43,7 +43,7 @@ catchError { stage("Build & Upload") { timeout(time: 70, unit: 'MINUTES') { container("builder") { - sh "NPROC=5 BUILD_BRANCH=${ghprbTargetBranch} release-centos7/build/build-tiflash-ci.sh" + sh "NPROC=5 BUILD_BRANCH=${ghprbTargetBranch} ENABLE_FORMAT_CHECK=true release-centos7/build/build-tiflash-ci.sh" sh "PULL_ID=${ghprbPullId} COMMIT_HASH=${ghprbActualCommit} release-centos7/build/upload-ci-build.sh" } } diff --git a/.clang-format b/.clang-format index 5e988172ed8..740c996f77f 100644 --- a/.clang-format +++ b/.clang-format @@ -1,61 +1,63 @@ --- BasedOnStyle: Google Language: Cpp -AlignAfterOpenBracket: false +AlignAfterOpenBracket: Align +AlignEscapedNewlines: Left +AlignTrailingComments: false +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Always +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Inline +AllowShortLambdasOnASingleLine: Inline +AlwaysBreakAfterReturnType: None +AlwaysBreakTemplateDeclarations: true +BinPackArguments: false +BinPackParameters: false BreakBeforeBraces: Custom -BraceWrapping: { - AfterCaseLabel: 'true' - AfterClass: 'true' - AfterControlStatement: 'true' - AfterEnum : 'true' - AfterFunction : 'true' - AfterNamespace : 'true' - AfterStruct : 'true' - AfterUnion : 'true' - BeforeCatch : 'true' - BeforeElse : 'true' - IndentBraces : 'false' - SplitEmptyFunction: 'false' -} - -BreakConstructorInitializersBeforeComma: false +BraceWrapping: + AfterCaseLabel: true + AfterClass: true + AfterControlStatement: true + AfterEnum : true + AfterFunction : true + AfterNamespace : true + AfterStruct : true + AfterUnion : true + BeforeCatch : true + BeforeElse : true + IndentBraces : false + SplitEmptyFunction: false +BreakConstructorInitializers: BeforeComma +BreakInheritanceList : BeforeComma +ColumnLimit: 0 +ConstructorInitializerAllOnOneLineOrOnePerLine: false Cpp11BracedListStyle: true -ColumnLimit: 140 -ConstructorInitializerAllOnOneLineOrOnePerLine: true +EmptyLineBeforeAccessModifier: LogicalBlock ExperimentalAutoDetectBinPacking: true -UseTab: Never -TabWidth: 4 +FixNamespaceComments: true +IndentCaseLabels: false IndentWidth: 4 -Standard: Cpp11 -PointerAlignment: Middle +KeepEmptyLinesAtTheStartOfBlocks: false MaxEmptyLinesToKeep: 2 -KeepEmptyLinesAtTheStartOfBlocks: true -#AllowShortFunctionsOnASingleLine: Inline -AllowShortFunctionsOnASingleLine: All -AlwaysBreakTemplateDeclarations: true -IndentCaseLabels: true -#SpaceAfterTemplateKeyword: true -#SortIncludes: true -FixNamespaceComments: true - +#PPIndentWidth: 2 # clang-format version 12.0.0 doesn't support yet +PointerAlignment: Middle ReflowComments: false -AlignEscapedNewlinesLeft: true +SortIncludes: true +SpaceAfterTemplateKeyword: true +Standard: Cpp11 +TabWidth: 4 +UseTab: Never # Not changed: AccessModifierOffset: -4 AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: false AlignOperands: false -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: true AllowShortCaseLabelsOnASingleLine: false AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakBeforeMultilineStrings: false -BinPackArguments: true -BinPackParameters: true BreakBeforeBinaryOperators: All BreakBeforeTernaryOperators: true CommentPragmas: '^ IWYU pragma:' diff --git a/README.md b/README.md index 16c4c3b72e4..c8c522b853d 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ ### Prerequisites - CMake 3.13.2+ +- clang-format 12.0.0+ ### Setup Compiler @@ -57,3 +58,4 @@ Before submitting pull request, please use [format-diff.py](format-diff.py) to f $ python3 format-diff.py --diff_from `git merge-base ${TARGET_REMOTE_BRANCH} HEAD` ``` +You can download the `clang-format` from [muttleyxd/clang-tools-static-binaries](https://github.com/muttleyxd/clang-tools-static-binaries/releases). clang-format 12.0.0+ is required. diff --git a/dbms/src/AggregateFunctions/IAggregateFunction.h b/dbms/src/AggregateFunctions/IAggregateFunction.h index 1b6c25183f4..03d7caaa4fe 100644 --- a/dbms/src/AggregateFunctions/IAggregateFunction.h +++ b/dbms/src/AggregateFunctions/IAggregateFunction.h @@ -1,26 +1,25 @@ #pragma once -#include -#include -#include -#include - -#include -#include #include #include #include +#include +#include #include #include #include +#include +#include +#include +#include + namespace DB { - namespace ErrorCodes { - extern const int NOT_IMPLEMENTED; +extern const int NOT_IMPLEMENTED; } class Arena; @@ -91,10 +90,7 @@ class IAggregateFunction virtual void deserialize(AggregateDataPtr __restrict place, ReadBuffer & buf, Arena * arena) const = 0; /// Returns true if a function requires Arena to handle own states (see add(), merge(), deserialize()). - virtual bool allocatesMemoryInArena() const - { - return false; - } + virtual bool allocatesMemoryInArena() const { return false; } /// Inserts results into a column. virtual void insertResultInto(ConstAggregateDataPtr __restrict place, IColumn & to, Arena * arena) const = 0; @@ -134,7 +130,11 @@ class IAggregateFunction /** The same for single place. */ virtual void addBatchSinglePlace( - size_t batch_size, AggregateDataPtr place, const IColumn ** columns, Arena * arena, ssize_t if_argument_pos = -1) const = 0; + size_t batch_size, + AggregateDataPtr place, + const IColumn ** columns, + Arena * arena, + ssize_t if_argument_pos = -1) const = 0; /** The same for single place when need to aggregate only filtered data. */ @@ -147,8 +147,12 @@ class IAggregateFunction ssize_t if_argument_pos = -1) const = 0; virtual void addBatchSinglePlaceFromInterval( - size_t batch_begin, size_t batch_end, AggregateDataPtr place, const IColumn ** columns, Arena * arena, ssize_t if_argument_pos = -1) - const = 0; + size_t batch_begin, + size_t batch_end, + AggregateDataPtr place, + const IColumn ** columns, + Arena * arena, + ssize_t if_argument_pos = -1) const = 0; /** In addition to addBatch, this method collects multiple rows of arguments into array "places" * as long as they are between offsets[i-1] and offsets[i]. This is used for arrayReduce and @@ -181,7 +185,7 @@ class IAggregateFunction */ virtual const char * getHeaderFilePath() const = 0; - virtual void setCollators(TiDB::TiDBCollators & ) {} + virtual void setCollators(TiDB::TiDBCollators &) {} }; /// Implement method to obtain an address of 'add' function. @@ -235,7 +239,11 @@ class IAggregateFunctionHelper : public IAggregateFunction } void addBatchSinglePlace( - size_t batch_size, AggregateDataPtr place, const IColumn ** columns, Arena * arena, ssize_t if_argument_pos = -1) const override + size_t batch_size, + AggregateDataPtr place, + const IColumn ** columns, + Arena * arena, + ssize_t if_argument_pos = -1) const override { if (if_argument_pos >= 0) { @@ -277,8 +285,12 @@ class IAggregateFunctionHelper : public IAggregateFunction } void addBatchSinglePlaceFromInterval( - size_t batch_begin, size_t batch_end, AggregateDataPtr place, const IColumn ** columns, Arena * arena, ssize_t if_argument_pos = -1) - const override + size_t batch_begin, + size_t batch_end, + AggregateDataPtr place, + const IColumn ** columns, + Arena * arena, + ssize_t if_argument_pos = -1) const override { if (if_argument_pos >= 0) { @@ -297,8 +309,12 @@ class IAggregateFunctionHelper : public IAggregateFunction } void addBatchArray( - size_t batch_size, AggregateDataPtr * places, size_t place_offset, const IColumn ** columns, const UInt64 * offsets, Arena * arena) - const override + size_t batch_size, + AggregateDataPtr * places, + size_t place_offset, + const IColumn ** columns, + const UInt64 * offsets, + Arena * arena) const override { size_t current_offset = 0; for (size_t i = 0; i < batch_size; ++i) @@ -356,14 +372,11 @@ namespace _IAggregateFunctionImpl template struct CollatorsHolder { - void setCollators(const TiDB::TiDBCollators &) - { - } + void setCollators(const TiDB::TiDBCollators &) {} template void setDataCollators(T *) const - { - } + {} }; template <> @@ -371,10 +384,7 @@ struct CollatorsHolder { TiDB::TiDBCollators collators; - void setCollators(const TiDB::TiDBCollators & collators_) - { - collators = collators_; - } + void setCollators(const TiDB::TiDBCollators & collators_) { collators = collators_; } template void setDataCollators(T * data) const @@ -389,19 +399,16 @@ struct AggregationCollatorsWrapper { void setCollators(const TiDB::TiDBCollators &) {} - StringRef getUpdatedValueForCollator(StringRef & in, size_t) - { - return in; - } + StringRef getUpdatedValueForCollator(StringRef & in, size_t) { return in; } - std::pair, std::string *> getCollatorAndSortKeyContainer(size_t ) + std::pair, std::string *> getCollatorAndSortKeyContainer(size_t) { return std::make_pair(static_cast>(nullptr), &TiDB::dummy_sort_key_contaner); } - void writeCollators(WriteBuffer & ) const {} + void writeCollators(WriteBuffer &) const {} - void readCollators(ReadBuffer & ) {} + void readCollators(ReadBuffer &) {} }; template <> @@ -468,7 +475,9 @@ struct AggregationCollatorsWrapper /// Implements several methods for manipulation with data. T - type of structure with data for aggregation. template -class IAggregateFunctionDataHelper : public IAggregateFunctionHelper, protected _IAggregateFunctionImpl::CollatorsHolder +class IAggregateFunctionDataHelper + : public IAggregateFunctionHelper + , protected _IAggregateFunctionImpl::CollatorsHolder { protected: using Data = T; @@ -482,31 +491,16 @@ class IAggregateFunctionDataHelper : public IAggregateFunctionHelper, p _IAggregateFunctionImpl::CollatorsHolder::setCollators(collators_); } - void create(AggregateDataPtr __restrict place) const override - { - this->setDataCollators(new (place) Data); - } + void create(AggregateDataPtr __restrict place) const override { this->setDataCollators(new (place) Data); } - void destroy(AggregateDataPtr __restrict place) const noexcept override - { - data(place).~Data(); - } + void destroy(AggregateDataPtr __restrict place) const noexcept override { data(place).~Data(); } - bool hasTrivialDestructor() const override - { - return std::is_trivially_destructible_v; - } + bool hasTrivialDestructor() const override { return std::is_trivially_destructible_v; } - size_t sizeOfData() const override - { - return sizeof(Data); - } + size_t sizeOfData() const override { return sizeof(Data); } /// NOTE: Currently not used (structures with aggregation state are put without alignment). - size_t alignOfData() const override - { - return alignof(Data); - } + size_t alignOfData() const override { return alignof(Data); } void addBatchLookupTable8( size_t batch_size, diff --git a/dbms/src/Storages/DeltaMerge/File/DMFile.cpp b/dbms/src/Storages/DeltaMerge/File/DMFile.cpp index 95a9e7be960..47f59955e24 100644 --- a/dbms/src/Storages/DeltaMerge/File/DMFile.cpp +++ b/dbms/src/Storages/DeltaMerge/File/DMFile.cpp @@ -15,7 +15,6 @@ namespace DB { - namespace FailPoints { extern const char exception_before_dmfile_remove_encryption[]; @@ -24,7 +23,6 @@ extern const char exception_before_dmfile_remove_from_disk[]; namespace DM { - namespace details { inline constexpr static const char * NGC_FILE_NAME = "NGC"; @@ -35,7 +33,10 @@ inline constexpr static const char * DATA_FILE_SUFFIX = ".dat"; inline constexpr static const char * INDEX_FILE_SUFFIX = ".idx"; inline constexpr static const char * MARK_FILE_SUFFIX = ".mrk"; -inline String getNGCPath(const String & prefix, bool is_single_mode) { return prefix + (is_single_mode ? "." : "/") + NGC_FILE_NAME; } +inline String getNGCPath(const String & prefix, bool is_single_mode) +{ + return prefix + (is_single_mode ? "." : "/") + NGC_FILE_NAME; +} } // namespace details // Some static helper functions @@ -45,16 +46,16 @@ String DMFile::getPathByStatus(const String & parent_path, UInt64 file_id, DMFil String s = parent_path + "/"; switch (status) { - case DMFile::Status::READABLE: - s += details::FOLDER_PREFIX_READABLE; - break; - case DMFile::Status::WRITABLE: - case DMFile::Status::WRITING: - s += details::FOLDER_PREFIX_WRITABLE; - break; - case DMFile::Status::DROPPED: - s += details::FOLDER_PREFIX_DROPPED; - break; + case DMFile::Status::READABLE: + s += details::FOLDER_PREFIX_READABLE; + break; + case DMFile::Status::WRITABLE: + case DMFile::Status::WRITING: + s += details::FOLDER_PREFIX_WRITABLE; + break; + case DMFile::Status::DROPPED: + s += details::FOLDER_PREFIX_DROPPED; + break; } s += DB::toString(file_id); return s; @@ -67,13 +68,19 @@ String DMFile::getNGCPath(const String & parent_path, UInt64 file_id, DMFile::St // -String DMFile::path() const { return getPathByStatus(parent_path, file_id, status); } +String DMFile::path() const +{ + return getPathByStatus(parent_path, file_id, status); +} -String DMFile::ngcPath() const { return getNGCPath(parent_path, file_id, status, isSingleFileMode()); } +String DMFile::ngcPath() const +{ + return getNGCPath(parent_path, file_id, status, isSingleFileMode()); +} DMFilePtr DMFile::create(UInt64 file_id, const String & parent_path, bool single_file_mode) { - Logger * log = &Logger::get("DMFile"); + Poco::Logger * log = &Logger::get("DMFile"); // On create, ref_id is the same as file_id. DMFilePtr new_dmfile( new DMFile(file_id, file_id, parent_path, single_file_mode ? Mode::SINGLE_FILE : Mode::FOLDER, Status::WRITABLE, log)); @@ -112,7 +119,12 @@ DMFilePtr DMFile::restore(const FileProviderPtr & file_provider, UInt64 file_id, String path = getPathByStatus(parent_path, file_id, DMFile::Status::READABLE); bool single_file_mode = Poco::File(path).isFile(); DMFilePtr dmfile(new DMFile( - file_id, ref_id, parent_path, single_file_mode ? Mode::SINGLE_FILE : Mode::FOLDER, Status::READABLE, &Logger::get("DMFile"))); + file_id, + ref_id, + parent_path, + single_file_mode ? Mode::SINGLE_FILE : Mode::FOLDER, + Status::READABLE, + &Logger::get("DMFile"))); if (read_meta) dmfile->readMetadata(file_provider); return dmfile; @@ -155,7 +167,10 @@ bool DMFile::isColIndexExist(const ColId & col_id) const } } -const String DMFile::encryptionBasePath() const { return getPathByStatus(parent_path, file_id, DMFile::Status::READABLE); } +const String DMFile::encryptionBasePath() const +{ + return getPathByStatus(parent_path, file_id, DMFile::Status::READABLE); +} const EncryptionPath DMFile::encryptionDataPath(const FileNameBase & file_name_base) const @@ -188,9 +203,18 @@ const EncryptionPath DMFile::encryptionPackPropertyPath() const return EncryptionPath(encryptionBasePath(), isSingleFileMode() ? "" : packPropertyFileName()); } -String DMFile::colDataFileName(const FileNameBase & file_name_base) { return file_name_base + details::DATA_FILE_SUFFIX; } -String DMFile::colIndexFileName(const FileNameBase & file_name_base) { return file_name_base + details::INDEX_FILE_SUFFIX; } -String DMFile::colMarkFileName(const FileNameBase & file_name_base) { return file_name_base + details::MARK_FILE_SUFFIX; } +String DMFile::colDataFileName(const FileNameBase & file_name_base) +{ + return file_name_base + details::DATA_FILE_SUFFIX; +} +String DMFile::colIndexFileName(const FileNameBase & file_name_base) +{ + return file_name_base + details::INDEX_FILE_SUFFIX; +} +String DMFile::colMarkFileName(const FileNameBase & file_name_base) +{ + return file_name_base + details::MARK_FILE_SUFFIX; +} DMFile::OffsetAndSize DMFile::writeMetaToBuffer(WriteBuffer & buffer) { @@ -441,7 +465,9 @@ void DMFile::finalizeForSingleFileMode(WriteBuffer & buffer) } std::set DMFile::listAllInPath( - const FileProviderPtr & file_provider, const String & parent_path, const DMFile::ListOptions & options) + const FileProviderPtr & file_provider, + const String & parent_path, + const DMFile::ListOptions & options) { Poco::File folder(parent_path); if (!folder.exists()) @@ -531,7 +557,10 @@ std::set DMFile::listAllInPath( return file_ids; } -bool DMFile::canGC() { return !Poco::File(ngcPath()).exists(); } +bool DMFile::canGC() +{ + return !Poco::File(ngcPath()).exists(); +} void DMFile::enableGC() { diff --git a/dbms/src/Storages/DeltaMerge/Segment.h b/dbms/src/Storages/DeltaMerge/Segment.h index f72126eaabd..8f66d6d7a38 100644 --- a/dbms/src/Storages/DeltaMerge/Segment.h +++ b/dbms/src/Storages/DeltaMerge/Segment.h @@ -16,7 +16,6 @@ namespace DB class WriteBatch; namespace DM { - class Segment; struct SegmentSnapshot; using SegmentSnapshotPtr = std::shared_ptr; @@ -37,7 +36,10 @@ struct SegmentSnapshot : private boost::noncopyable DeltaSnapshotPtr delta; StableSnapshotPtr stable; - SegmentSnapshot(DeltaSnapshotPtr && delta_, StableSnapshotPtr && stable_) : delta(std::move(delta_)), stable(std::move(stable_)) {} + SegmentSnapshot(DeltaSnapshotPtr && delta_, StableSnapshotPtr && stable_) + : delta(std::move(delta_)) + , stable(std::move(stable_)) + {} SegmentSnapshotPtr clone() { return std::make_shared(delta->clone(), stable->clone()); } @@ -65,12 +67,17 @@ class Segment : private boost::noncopyable ColumnDefinesPtr read_columns; - ReadInfo(DeltaValueReaderPtr delta_reader_, + ReadInfo( + DeltaValueReaderPtr delta_reader_, DeltaIndexIterator index_begin_, DeltaIndexIterator index_end_, ColumnDefinesPtr read_columns_) - : delta_reader(delta_reader_), index_begin(index_begin_), index_end(index_end_), read_columns(read_columns_) - {} + : delta_reader(delta_reader_) + , index_begin(index_begin_) + , index_end(index_end_) + , read_columns(read_columns_) + { + } DeltaValueReaderPtr getDeltaReader() const { return delta_reader->createNewReader(read_columns); } DeltaValueReaderPtr getDeltaReader(ColumnDefinesPtr columns) const { return delta_reader->createNewReader(columns); } @@ -89,21 +96,24 @@ class Segment : private boost::noncopyable Segment & operator=(const Segment &) = delete; Segment & operator=(Segment &&) = delete; - Segment(UInt64 epoch_, // + Segment( + UInt64 epoch_, const RowKeyRange & rowkey_range_, PageId segment_id_, PageId next_segment_id_, const DeltaValueSpacePtr & delta_, const StableValueSpacePtr & stable_); - static SegmentPtr newSegment(DMContext & context, // + static SegmentPtr newSegment( + DMContext & context, const ColumnDefinesPtr & schema, const RowKeyRange & rowkey_range, PageId segment_id, PageId next_segment_id, PageId delta_id, PageId stable_id); - static SegmentPtr newSegment(DMContext & context, // + static SegmentPtr newSegment( + DMContext & context, const ColumnDefinesPtr & schema, const RowKeyRange & rowkey_range, PageId segment_id, @@ -121,7 +131,8 @@ class Segment : private boost::noncopyable SegmentSnapshotPtr createSnapshot(const DMContext & dm_context, bool for_update, CurrentMetrics::Metric metric) const; - BlockInputStreamPtr getInputStream(const DMContext & dm_context, + BlockInputStreamPtr getInputStream( + const DMContext & dm_context, const ColumnDefines & columns_to_read, const SegmentSnapshotPtr & segment_snap, const RowKeyRanges & read_ranges, @@ -129,7 +140,8 @@ class Segment : private boost::noncopyable UInt64 max_version, size_t expected_block_size); - BlockInputStreamPtr getInputStream(const DMContext & dm_context, + BlockInputStreamPtr getInputStream( + const DMContext & dm_context, const ColumnDefines & columns_to_read, const RowKeyRanges & read_ranges, const RSOperatorPtr & filter = {}, @@ -138,43 +150,56 @@ class Segment : private boost::noncopyable /// Return a stream which is suitable for exporting data. /// reorganize_block: put those rows with the same pk rows into the same block or not. - BlockInputStreamPtr getInputStreamForDataExport(const DMContext & dm_context, + BlockInputStreamPtr getInputStreamForDataExport( + const DMContext & dm_context, const ColumnDefines & columns_to_read, const SegmentSnapshotPtr & segment_snap, const RowKeyRange & data_range, size_t expected_block_size = DEFAULT_BLOCK_SIZE, bool reorganize_block = true) const; - BlockInputStreamPtr getInputStreamRaw(const DMContext & dm_context, + BlockInputStreamPtr getInputStreamRaw( + const DMContext & dm_context, const ColumnDefines & columns_to_read, const SegmentSnapshotPtr & segment_snap, bool do_range_filter, size_t expected_block_size = DEFAULT_BLOCK_SIZE); - BlockInputStreamPtr getInputStreamRaw(const DMContext & dm_context, const ColumnDefines & columns_to_read); + BlockInputStreamPtr getInputStreamRaw( + const DMContext & dm_context, + const ColumnDefines & columns_to_read); /// For those split, merge and mergeDelta methods, we should use prepareXXX/applyXXX combo in real production. /// split(), merge() and mergeDelta() are only used in test cases. SegmentPair split(DMContext & dm_context, const ColumnDefinesPtr & schema_snap) const; std::optional prepareSplit( - DMContext & dm_context, const ColumnDefinesPtr & schema_snap, const SegmentSnapshotPtr & segment_snap, WriteBatches & wbs) const; + DMContext & dm_context, + const ColumnDefinesPtr & schema_snap, + const SegmentSnapshotPtr & segment_snap, + WriteBatches & wbs) const; SegmentPair applySplit( - DMContext & dm_context, const SegmentSnapshotPtr & segment_snap, WriteBatches & wbs, SplitInfo & split_info) const; + DMContext & dm_context, + const SegmentSnapshotPtr & segment_snap, + WriteBatches & wbs, + SplitInfo & split_info) const; - static SegmentPtr merge(DMContext & dm_context, // + static SegmentPtr merge( + DMContext & dm_context, const ColumnDefinesPtr & schema_snap, const SegmentPtr & left, const SegmentPtr & right); - static StableValueSpacePtr prepareMerge(DMContext & dm_context, // + static StableValueSpacePtr prepareMerge( + DMContext & dm_context, const ColumnDefinesPtr & schema_snap, const SegmentPtr & left, const SegmentSnapshotPtr & left_snap, const SegmentPtr & right, const SegmentSnapshotPtr & right_snap, WriteBatches & wbs); - static SegmentPtr applyMerge(DMContext & dm_context, // + static SegmentPtr applyMerge( + DMContext & dm_context, const SegmentPtr & left, const SegmentSnapshotPtr & left_snap, const SegmentPtr & right, @@ -184,9 +209,15 @@ class Segment : private boost::noncopyable SegmentPtr mergeDelta(DMContext & dm_context, const ColumnDefinesPtr & schema_snap) const; StableValueSpacePtr prepareMergeDelta( - DMContext & dm_context, const ColumnDefinesPtr & schema_snap, const SegmentSnapshotPtr & segment_snap, WriteBatches & wbs) const; + DMContext & dm_context, + const ColumnDefinesPtr & schema_snap, + const SegmentSnapshotPtr & segment_snap, + WriteBatches & wbs) const; SegmentPtr applyMergeDelta( - DMContext & dm_context, const SegmentSnapshotPtr & segment_snap, WriteBatches & wbs, const StableValueSpacePtr & new_stable) const; + DMContext & dm_context, + const SegmentSnapshotPtr & segment_snap, + WriteBatches & wbs, + const StableValueSpacePtr & new_stable) const; /// Flush delta's cache packs. bool flushCache(DMContext & dm_context); @@ -234,14 +265,18 @@ class Segment : private boost::noncopyable void drop(const FileProviderPtr & file_provider) { stable->drop(file_provider); } RowsAndBytes getRowsAndBytesInRange( - DMContext & dm_context, const SegmentSnapshotPtr & segment_snap, const RowKeyRange & check_range, bool is_exact); + DMContext & dm_context, + const SegmentSnapshotPtr & segment_snap, + const RowKeyRange & check_range, + bool is_exact); DB::Timestamp getLastCheckGCSafePoint() { return last_check_gc_safe_point.load(std::memory_order_relaxed); } void setLastCheckGCSafePoint(DB::Timestamp gc_safe_point) { last_check_gc_safe_point.store(gc_safe_point, std::memory_order_relaxed); } private: - ReadInfo getReadInfo(const DMContext & dm_context, + ReadInfo getReadInfo( + const DMContext & dm_context, const ColumnDefines & read_columns, const SegmentSnapshotPtr & segment_snap, const RowKeyRanges & read_ranges, @@ -251,7 +286,8 @@ class Segment : private boost::noncopyable /// Create a stream which merged delta and stable streams together. template - static SkippableBlockInputStreamPtr getPlacedStream(const DMContext & dm_context, + static SkippableBlockInputStreamPtr getPlacedStream( + const DMContext & dm_context, const ColumnDefines & read_columns, const RowKeyRange & rowkey_range, const RSOperatorPtr & filter, @@ -264,23 +300,30 @@ class Segment : private boost::noncopyable /// Merge delta & stable, and then take the middle one. std::optional getSplitPointSlow( - DMContext & dm_context, const ReadInfo & read_info, const SegmentSnapshotPtr & segment_snap) const; + DMContext & dm_context, + const ReadInfo & read_info, + const SegmentSnapshotPtr & segment_snap) const; /// Only look up in the stable vs. std::optional getSplitPointFast(DMContext & dm_context, const StableSnapshotPtr & stable_snap) const; - std::optional prepareSplitLogical(DMContext & dm_context, // + std::optional prepareSplitLogical( + DMContext & dm_context, const ColumnDefinesPtr & schema_snap, const SegmentSnapshotPtr & segment_snap, RowKeyValue & split_point, WriteBatches & wbs) const; std::optional prepareSplitPhysical( - DMContext & dm_context, const ColumnDefinesPtr & schema_snap, const SegmentSnapshotPtr & segment_snap, WriteBatches & wbs) const; + DMContext & dm_context, + const ColumnDefinesPtr & schema_snap, + const SegmentSnapshotPtr & segment_snap, + WriteBatches & wbs) const; /// Make sure that all delta packs have been placed. /// Note that the index returned could be partial index, and cannot be updated to shared index. /// Returns - std::pair ensurePlace(const DMContext & dm_context, + std::pair ensurePlace( + const DMContext & dm_context, const StableSnapshotPtr & stable_snap, const DeltaValueReaderPtr & delta_reader, const RowKeyRanges & read_ranges, @@ -289,7 +332,8 @@ class Segment : private boost::noncopyable /// Reference the inserts/updates by delta tree. /// Returns fully placed or not. Some rows not match relevant_range are not placed. template - bool placeUpsert(const DMContext & dm_context, + bool placeUpsert( + const DMContext & dm_context, const StableSnapshotPtr & stable_snap, const DeltaValueReaderPtr & delta_reader, size_t delta_value_space_offset, @@ -299,7 +343,8 @@ class Segment : private boost::noncopyable /// Reference the deletes by delta tree. /// Returns fully placed or not. Some rows not match relevant_range are not placed. template - bool placeDelete(const DMContext & dm_context, + bool placeDelete( + const DMContext & dm_context, const StableSnapshotPtr & stable_snap, const DeltaValueReaderPtr & delta_reader, const RowKeyRange & delete_range, @@ -321,7 +366,7 @@ class Segment : private boost::noncopyable bool split_forbidden = false; - Logger * log; + Poco::Logger * log; }; } // namespace DM diff --git a/dbms/src/Storages/DeltaMerge/Tuple.h b/dbms/src/Storages/DeltaMerge/Tuple.h index c3eaa73afa8..11c5e324a41 100644 --- a/dbms/src/Storages/DeltaMerge/Tuple.h +++ b/dbms/src/Storages/DeltaMerge/Tuple.h @@ -1,21 +1,23 @@ #pragma once -#include - #include #include +#include + namespace DB { namespace DM { - struct ColumnAndValue { UInt16 column; UInt64 value; - ColumnAndValue(UInt16 column_, UInt64 value_) : column(column_), value(value_) {} + ColumnAndValue(UInt16 column_, UInt64 value_) + : column(column_) + , value(value_) + {} }; using ColumnAndValues = std::vector; @@ -25,9 +27,12 @@ struct RefTuple { ColumnAndValues values; - RefTuple(UInt16 column, UInt64 value) : values{ColumnAndValue(column, value)} {} + RefTuple(UInt16 column, UInt64 value) + : values{ColumnAndValue(column, value)} + {} - RefTuple(const ColumnAndValues & values_) : values(values_) + RefTuple(const ColumnAndValues & values_) + : values(values_) { std::sort(values.begin(), values.end(), [](const ColumnAndValue & a, const ColumnAndValue & b) { return a.column < b.column; }); } @@ -36,4 +41,4 @@ struct RefTuple using RefTuples = std::vector; } // namespace DM -} // namespace DB \ No newline at end of file +} // namespace DB diff --git a/release-centos7/build/build-tiflash-ci.sh b/release-centos7/build/build-tiflash-ci.sh index 548e22e3f18..066d253ee8a 100755 --- a/release-centos7/build/build-tiflash-ci.sh +++ b/release-centos7/build/build-tiflash-ci.sh @@ -11,11 +11,12 @@ fi command -v clang-format > /dev/null 2>&1 if [[ $? != 0 ]]; then - curl -o "/usr/local/bin/clang-format" http://fileserver.pingcap.net/download/builds/pingcap/tiflash/ci-cache/clang-format + curl -o "/usr/local/bin/clang-format" http://fileserver.pingcap.net/download/builds/pingcap/tiflash/ci-cache/clang-format-12 chmod +x "/usr/local/bin/clang-format" else echo "clang-format has been installed" fi +clang-format --version set -ueox pipefail