-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implment PageStorage * Refactor RegionPersister based on PageStorage * Remove some useless code, and dereference PageFile from Reader
- Loading branch information
1 parent
4b2264a
commit 722a1e5
Showing
17 changed files
with
1,611 additions
and
759 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
BasedOnStyle: Google | ||
Language: Cpp | ||
AlignAfterOpenBracket: true | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: { | ||
AfterClass: 'true' | ||
AfterControlStatement: 'true' | ||
AfterEnum : 'true' | ||
AfterFunction : 'true' | ||
AfterNamespace : 'true' | ||
AfterStruct : 'true' | ||
AfterUnion : 'true' | ||
BeforeCatch : 'true' | ||
BeforeElse : 'true' | ||
IndentBraces : 'false' | ||
} | ||
|
||
BreakConstructorInitializersBeforeComma: false | ||
Cpp11BracedListStyle: true | ||
ColumnLimit: 140 | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
ExperimentalAutoDetectBinPacking: true | ||
UseTab: Never | ||
TabWidth: 4 | ||
IndentWidth: 4 | ||
Standard: Cpp11 | ||
PointerAlignment: Middle | ||
MaxEmptyLinesToKeep: 2 | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
AllowShortFunctionsOnASingleLine: Inline | ||
#AllowShortFunctionsOnASingleLine: Empty | ||
AlwaysBreakTemplateDeclarations: true | ||
IndentCaseLabels: false | ||
#SpaceAfterTemplateKeyword: true | ||
#SortIncludes: true | ||
FixNamespaceComments: true | ||
|
||
ReflowComments: false | ||
AlignEscapedNewlinesLeft: true | ||
|
||
# Not changed: | ||
AccessModifierOffset: -4 | ||
AlignConsecutiveAssignments: true | ||
AlignConsecutiveDeclarations: true | ||
AlignOperands: false | ||
AlignTrailingComments: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: true | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
BreakBeforeBinaryOperators: All | ||
BreakBeforeTernaryOperators: true | ||
CommentPragmas: '^ IWYU pragma:' | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] | ||
IndentWidth: 4 | ||
IndentWrappedFunctionNames: false | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
NamespaceIndentation: None | ||
ObjCBlockIndentWidth: 4 | ||
ObjCSpaceAfterProperty: true | ||
ObjCSpaceBeforeProtocolList: true | ||
PenaltyBreakBeforeFirstCallParameter: 19 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 60 | ||
SpaceAfterCStyleCast: false | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInContainerLiterals: true | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
|
||
#include <unordered_map> | ||
|
||
#include <IO/BufferBase.h> | ||
#include <IO/MemoryReadWriteBuffer.h> | ||
|
||
#include <Storages/Page/PageDefines.h> | ||
|
||
namespace DB | ||
{ | ||
|
||
using MemHolder = std::shared_ptr<char>; | ||
inline MemHolder createMemHolder(char * memory, std::function<void(char *)> free) | ||
{ | ||
return std::shared_ptr<char>(memory, free); | ||
} | ||
|
||
struct Page | ||
{ | ||
PageId page_id; | ||
ByteBuffer data; | ||
|
||
MemHolder mem_holder; | ||
}; | ||
using Pages = std::vector<Page>; | ||
using PageMap = std::unordered_map<PageId, Page>; | ||
|
||
struct PageCache | ||
{ | ||
PageFileId file_id; | ||
UInt32 level; | ||
UInt32 size; | ||
UInt64 version; | ||
UInt64 offset; | ||
UInt64 checksum; | ||
|
||
bool isValid() { return file_id; } | ||
PageFileIdAndLevel fileIdLevel() const { return std::make_pair(file_id, level); } | ||
}; | ||
static_assert(std::is_trivially_copyable_v<PageCache>); | ||
|
||
using PageCacheMap = std::unordered_map<PageId, PageCache>; | ||
using PageCaches = std::vector<PageCache>; | ||
using PageIdAndCache = std::pair<PageId, PageCache>; | ||
using PageIdAndCaches = std::vector<PageIdAndCache>; | ||
|
||
} // namespace DB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#pragma once | ||
|
||
#include <unordered_set> | ||
#include <vector> | ||
|
||
#include <Core/Types.h> | ||
|
||
namespace DB | ||
{ | ||
|
||
#define MB 1048576ULL; | ||
|
||
static constexpr UInt64 PAGE_SIZE_STEP = (1 << 10) * 16; // 16 KB | ||
static constexpr UInt64 PAGE_BUFFER_SIZE = DBMS_DEFAULT_BUFFER_SIZE; | ||
static constexpr UInt64 PAGE_MAX_BUFFER_SIZE = 128 * MB; | ||
static constexpr UInt64 PAGE_SPLIT_SIZE = 1 * MB; | ||
static constexpr UInt64 PAGE_FILE_MAX_SIZE = 1024 * 2 * MB; | ||
static constexpr UInt64 PAGE_FILE_SMALL_SIZE = 2 * MB; | ||
static constexpr UInt64 PAGE_FILE_ROLL_SIZE = 128 * MB; | ||
|
||
static_assert(PAGE_SIZE_STEP >= ((1 << 10) * 16), "PAGE_SIZE_STEP should be at least 16 KB"); | ||
static_assert((PAGE_SIZE_STEP & (PAGE_SIZE_STEP - 1)) == 0, "PAGE_SIZE_STEP should be power of 2"); | ||
static_assert(PAGE_BUFFER_SIZE % PAGE_SIZE_STEP == 0, "PAGE_BUFFER_SIZE should be dividable by PAGE_SIZE_STEP"); | ||
|
||
using PageId = UInt64; | ||
using PageIds = std::vector<PageId>; | ||
using PageIdSet = std::unordered_set<PageId>; | ||
using PageFileId = UInt64; | ||
using PageFileIdAndLevel = std::pair<PageFileId, UInt32>; | ||
using PageFileIdAndLevels = std::vector<PageFileIdAndLevel>; | ||
|
||
struct ByteBuffer | ||
{ | ||
using Pos = char *; | ||
|
||
ByteBuffer() = default; | ||
ByteBuffer(Pos begin_pos_, Pos end_pos_) : begin_pos(begin_pos_), end_pos(end_pos_) {} | ||
|
||
inline Pos begin() const { return begin_pos; } | ||
inline Pos end() const { return end_pos; } | ||
inline size_t size() const { return end_pos - begin_pos; } | ||
|
||
private: | ||
Pos begin_pos; | ||
Pos end_pos; /// 1 byte after the end of the buffer | ||
}; | ||
|
||
/// https://stackoverflow.com/a/13938417 | ||
inline size_t alignPage(size_t n) | ||
{ | ||
return (n + PAGE_SIZE_STEP - 1) & ~(PAGE_SIZE_STEP - 1); | ||
} | ||
|
||
} // namespace DB |
Oops, something went wrong.