This is an automated email from the ASF dual-hosted git repository.

SpriCoder pushed a commit to branch cPerformance
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 2f35cc51f779443911cb79c4e891d8542ebff7fb
Author: spricoder <[email protected]>
AuthorDate: Sun May 31 11:42:39 2026 +0800

    Wire RPC compression flag through Session to its connections
    
    The enableRPCCompression option set via Session::open(bool) or the session
    builder was never propagated to SessionConnection, whose flag was hardcoded
    to false, so the compact Thrift protocol never took effect. Thread the flag
    from the builder/open() into both the data SessionConnection and the
    node-discovery NodesSupplier client so compression actually applies.
---
 iotdb-client/client-cpp/src/main/Session.cpp           | 14 ++++++++++++--
 iotdb-client/client-cpp/src/main/Session.h             |  2 ++
 iotdb-client/client-cpp/src/main/SessionConnection.cpp |  3 +++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/iotdb-client/client-cpp/src/main/Session.cpp 
b/iotdb-client/client-cpp/src/main/Session.cpp
index a2b07ed7afb..6227bca4161 100644
--- a/iotdb-client/client-cpp/src/main/Session.cpp
+++ b/iotdb-client/client-cpp/src/main/Session.cpp
@@ -768,8 +768,14 @@ void Session::initNodesSupplier(const 
std::vector<std::string>& nodeUrls) {
   }
 
   if (enableAutoFetch_) {
-    nodesSupplier_ =
-        NodesSupplier::create(endPoints, username_, password_, useSSL_, 
trustCertFilePath_);
+    // Propagate the compression setting to the node-discovery client too, so 
the
+    // background "show cluster" refresh uses the same protocol as data 
sessions.
+    // Other parameters keep their library defaults to preserve existing 
behavior.
+    nodesSupplier_ = NodesSupplier::create(
+        endPoints, username_, password_, useSSL_, trustCertFilePath_, 
/*zoneId=*/"",
+        ThriftConnection::THRIFT_DEFAULT_BUFFER_SIZE, 
ThriftConnection::THRIFT_MAX_FRAME_SIZE,
+        ThriftConnection::CONNECTION_TIMEOUT_IN_MS, enableRPCCompression_,
+        getVersionString(version));
   } else {
     nodesSupplier_ = make_shared<StaticNodesSupplier>(endPoints);
   }
@@ -944,6 +950,10 @@ void Session::open(bool enableRPCCompression, int 
connectionTimeoutInMs) {
     return;
   }
 
+  // Honor compression requested either via the builder or this open() call, so
+  // the negotiated protocol (compact vs binary) actually reflects the setting.
+  enableRPCCompression_ = enableRPCCompression_ || enableRPCCompression;
+
   try {
     initDefaultSessionConnection();
   } catch (const exception& e) {
diff --git a/iotdb-client/client-cpp/src/main/Session.h 
b/iotdb-client/client-cpp/src/main/Session.h
index cedfaeba196..4a629565af0 100644
--- a/iotdb-client/client-cpp/src/main/Session.h
+++ b/iotdb-client/client-cpp/src/main/Session.h
@@ -595,6 +595,7 @@ private:
   std::string database_;
   bool enableAutoFetch_ = true;
   bool enableRedirection_ = true;
+  bool enableRPCCompression_ = false;
   std::shared_ptr<INodesSupplier> nodesSupplier_;
   friend class SessionConnection;
   friend class TableSession;
@@ -772,6 +773,7 @@ public:
     this->database_ = builder->database;
     this->enableAutoFetch_ = builder->enableAutoFetch;
     this->enableRedirection_ = builder->enableRedirections;
+    this->enableRPCCompression_ = builder->enableRPCCompression;
     this->connectTimeoutMs_ = builder->connectTimeoutMs;
     this->nodeUrls_ = builder->nodeUrls;
     this->useSSL_ = builder->useSSL;
diff --git a/iotdb-client/client-cpp/src/main/SessionConnection.cpp 
b/iotdb-client/client-cpp/src/main/SessionConnection.cpp
index a7fa3beb6ff..1746d2049cb 100644
--- a/iotdb-client/client-cpp/src/main/SessionConnection.cpp
+++ b/iotdb-client/client-cpp/src/main/SessionConnection.cpp
@@ -39,6 +39,9 @@ SessionConnection::SessionConnection(Session* session_ptr, 
const TEndPoint& endp
       retryIntervalMs(retryInterval), connectionTimeoutInMs(connectionTimeout),
       sqlDialect(std::move(dialect)), database(std::move(db)) {
   this->zoneId = zoneId.empty() ? getSystemDefaultZoneId() : zoneId;
+  // Inherit the compression setting negotiated by the owning Session so the
+  // chosen Thrift protocol (compact when compression is on) is consistent.
+  this->enableRPCCompression = session->enableRPCCompression_;
   endPointList.push_back(endpoint);
   init(endPoint, session->useSSL_, session->trustCertFilePath_);
 }

Reply via email to