Skip to content

Commit

Permalink
only disabled custom serialization for non-clickhouse cases
Browse files Browse the repository at this point in the history
  • Loading branch information
zliang-min committed Jul 26, 2024
1 parent 25b1f5b commit bd0f19b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
4 changes: 4 additions & 0 deletions src/Client/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@ void Connection::sendData(const Block & block, const String & name, bool scalar)
maybe_compressed_out = out;

block_out = std::make_unique<NativeWriter>(*maybe_compressed_out, block.cloneEmpty(), server_revision);
if (compatible_with_clickhouse)
block_out->setCompatibleWithClickHouse();
}

if (scalar)
Expand Down Expand Up @@ -1107,6 +1109,8 @@ void Connection::setCompatibleWithClickHouse()
block_logs_in->setCompatibleWithClickHouse();
if (block_profile_events_in)
block_profile_events_in->setCompatibleWithClickHouse();
if (block_out)
block_out->setCompatibleWithClickHouse();
}
/// proton: ends

Expand Down
29 changes: 16 additions & 13 deletions src/Formats/NativeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,22 @@ Block NativeReader::read()

SerializationPtr serialization;
/// proton: starts
/// if (server_revision >= DBMS_MIN_REVISION_WITH_CUSTOM_SERIALIZATION)
/// {
/// auto info = column.type->createSerializationInfo({});
///
/// UInt8 has_custom;
/// readBinary(has_custom, istr);
/// if (has_custom)
/// info->deserializeFromKindsBinary(istr);
///
/// serialization = column.type->getSerialization(*info);
/// }
/// else
/// proton: ends
/// Because our drivers does not support custom serialization, we can only check the serialization when `compatible_with_clickhouse` is `true`,
/// i.e. this reader is reading packets from clickhouse (for ClickHouse external tables).
if (compatible_with_clickhouse &&
/// proton: ends
server_revision >= DBMS_MIN_REVISION_WITH_CUSTOM_SERIALIZATION)
{
auto info = column.type->createSerializationInfo({});

UInt8 has_custom;
readBinary(has_custom, istr);
if (has_custom)
info->deserializeFromKindsBinary(istr);

serialization = column.type->getSerialization(*info);
}
else
{
serialization = column.type->getDefaultSerialization();
}
Expand Down
8 changes: 8 additions & 0 deletions src/Formats/NativeWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class NativeWriter

static String getContentType() { return "application/octet-stream"; }

/// proton: starts
void setCompatibleWithClickHouse() { compatible_with_clickhouse = true; }
/// proton: ends

private:
WriteBuffer & ostr;
Block header;
Expand All @@ -40,6 +44,10 @@ class NativeWriter
size_t initial_size_of_file; /// The initial size of the data file, if `append` done. Used for the index.
/// If you need to write index, then `ostr` must be a CompressedWriteBuffer.
CompressedWriteBuffer * ostr_concrete = nullptr;

/// proton: starts
bool compatible_with_clickhouse{false};
/// proton: ends
};

}

0 comments on commit bd0f19b

Please sign in to comment.