-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FLASH-795 support chblock encode type #383
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0a8aaa7
support chblock encode type for cop request
windtalker 2b61791
fix timestamp bug for ch block encode
windtalker e70e4b2
add unsupported type for chblock encode
windtalker 3e998eb
refine code
windtalker 1903248
fix build error
windtalker 5e21aeb
address comments
windtalker 63b2776
Merge branch 'master' into chblock_encode
windtalker 3ac5520
Merge branch 'master' into chblock_encode
windtalker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule tipb
updated
4 files
+294 −290 | go-tipb/expression.pb.go | |
+61 −56 | go-tipb/select.pb.go | |
+3 −2 | proto/expression.proto | |
+2 −0 | proto/select.proto |
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,80 @@ | ||
#include <DataStreams/IBlockInputStream.h> | ||
#include <DataStreams/NativeBlockInputStream.h> | ||
#include <Flash/Coprocessor/CHBlockChunkCodec.h> | ||
#include <IO/ReadBufferFromString.h> | ||
|
||
namespace DB | ||
{ | ||
|
||
class CHBlockChunkCodecStream : public ChunkCodecStream | ||
{ | ||
public: | ||
explicit CHBlockChunkCodecStream(const std::vector<tipb::FieldType> & field_types) : ChunkCodecStream(field_types) | ||
{ | ||
output = std::make_unique<WriteBufferFromOwnString>(); | ||
} | ||
|
||
String getString() override | ||
{ | ||
std::stringstream ss; | ||
return output->str(); | ||
} | ||
void clear() override { output = std::make_unique<WriteBufferFromOwnString>(); } | ||
void encode(const Block & block, size_t start, size_t end) override; | ||
std::unique_ptr<WriteBufferFromOwnString> output; | ||
}; | ||
|
||
void writeData(const IDataType & type, const ColumnPtr & column, WriteBuffer & ostr, size_t offset, size_t limit) | ||
{ | ||
/** If there are columns-constants - then we materialize them. | ||
* (Since the data type does not know how to serialize / deserialize constants.) | ||
*/ | ||
ColumnPtr full_column; | ||
|
||
if (ColumnPtr converted = column->convertToFullColumnIfConst()) | ||
full_column = converted; | ||
else | ||
full_column = column; | ||
|
||
IDataType::OutputStreamGetter output_stream_getter = [&](const IDataType::SubstreamPath &) { return &ostr; }; | ||
type.serializeBinaryBulkWithMultipleStreams(*full_column, output_stream_getter, offset, limit, false, {}); | ||
} | ||
|
||
void CHBlockChunkCodecStream::encode(const Block & block, size_t start, size_t end) | ||
{ | ||
// Encode data in chunk by arrow encode | ||
if (start != 0 || end != block.rows()) | ||
throw Exception("CHBlock encode only support encode whole block"); | ||
block.checkNumberOfRows(); | ||
size_t columns = block.columns(); | ||
size_t rows = block.rows(); | ||
|
||
writeVarUInt(columns, *output); | ||
writeVarUInt(rows, *output); | ||
|
||
for (size_t i = 0; i < columns; i++) | ||
{ | ||
const ColumnWithTypeAndName & column = block.safeGetByPosition(i); | ||
|
||
writeStringBinary(column.name, *output); | ||
writeStringBinary(column.type->getName(), *output); | ||
|
||
if (rows) | ||
writeData(*column.type, column.column, *output, 0, 0); | ||
} | ||
} | ||
|
||
std::unique_ptr<ChunkCodecStream> CHBlockChunkCodec::newCodecStream(const std::vector<tipb::FieldType> & field_types) | ||
{ | ||
return std::make_unique<CHBlockChunkCodecStream>(field_types); | ||
} | ||
|
||
Block CHBlockChunkCodec::decode(const tipb::Chunk & chunk, const DAGSchema &) | ||
{ | ||
const String & row_data = chunk.rows_data(); | ||
ReadBufferFromString read_buffer(row_data); | ||
NativeBlockInputStream block_in(read_buffer, 0); | ||
return block_in.read(); | ||
} | ||
|
||
} // 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,16 @@ | ||
#pragma once | ||
|
||
#include <Flash/Coprocessor/ChunkCodec.h> | ||
|
||
namespace DB | ||
{ | ||
|
||
class CHBlockChunkCodec : public ChunkCodec | ||
{ | ||
public: | ||
CHBlockChunkCodec() = default; | ||
Block decode(const tipb::Chunk &, const DAGSchema &) override; | ||
std::unique_ptr<ChunkCodecStream> newCodecStream(const std::vector<tipb::FieldType> & field_types) override; | ||
}; | ||
|
||
} // 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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arrow?