@@ -138,8 +138,9 @@ public class Session implements ISession {
138138 */
139139 private long queryTimeoutInMs = -1 ;
140140
141- protected boolean enableRPCCompaction ;
142- protected boolean enableRPCCompression ;
141+ protected boolean enableThriftRpcCompaction ;
142+ protected boolean enableIoTDBRpcCompression = true ;
143+ protected int tabletCompressionMinRowSize = 10 ;
143144 protected int connectionTimeoutInMs ;
144145 protected ZoneId zoneId ;
145146 protected int thriftDefaultBufferSize ;
@@ -454,8 +455,9 @@ public Session(AbstractSessionBuilder builder) {
454455 this .defaultEndPoint = new TEndPoint (builder .host , builder .rpcPort );
455456 this .enableQueryRedirection = builder .enableRedirection ;
456457 }
457- this .enableRPCCompaction = builder .isThriftRpcCompactionEnabled ;
458- this .enableRPCCompression = builder .isIoTDBRpcCompressionEnabled ;
458+ this .enableThriftRpcCompaction = builder .isThriftRpcCompactionEnabled ;
459+ this .enableIoTDBRpcCompression = builder .isIoTDBRpcCompressionEnabled ;
460+ this .tabletCompressionMinRowSize = builder .tabletCompressionMinRowSize ;
459461 this .compressionType = builder .compressionType ;
460462 this .columnEncodersMap = builder .columnEncodersMap ;
461463 this .enableRedirection = builder .enableRedirection ;
@@ -584,7 +586,7 @@ private List<TEndPoint> getNodeUrls() {
584586
585587 @ Override
586588 public synchronized void open (
587- boolean enableRPCCompression ,
589+ boolean enableThriftRpcCompaction ,
588590 int connectionTimeoutInMs ,
589591 Map <String , TEndPoint > deviceIdToEndpoint ,
590592 INodeSupplier nodesSupplier )
@@ -594,7 +596,7 @@ public synchronized void open(
594596 }
595597
596598 this .availableNodes = nodesSupplier ;
597- this .enableRPCCompression = enableRPCCompression ;
599+ this .enableThriftRpcCompaction = enableThriftRpcCompaction ;
598600 this .connectionTimeoutInMs = connectionTimeoutInMs ;
599601 setDefaultSessionConnection (constructSessionConnection (this , defaultEndPoint , zoneId ));
600602 getDefaultSessionConnection ().setEnableRedirect (enableQueryRedirection );
@@ -609,7 +611,7 @@ public synchronized void open(
609611
610612 @ Override
611613 public synchronized void open (
612- boolean enableRPCCompression ,
614+ boolean enableThriftRpcCompaction ,
613615 int connectionTimeoutInMs ,
614616 Map <String , TEndPoint > deviceIdToEndpoint ,
615617 Map <IDeviceID , TEndPoint > tableModelDeviceIdToEndpoint ,
@@ -620,7 +622,7 @@ public synchronized void open(
620622 }
621623
622624 this .availableNodes = nodesSupplier ;
623- this .enableRPCCompression = enableRPCCompression ;
625+ this .enableThriftRpcCompaction = enableThriftRpcCompaction ;
624626 this .connectionTimeoutInMs = connectionTimeoutInMs ;
625627 setDefaultSessionConnection (constructSessionConnection (this , defaultEndPoint , zoneId ));
626628 getDefaultSessionConnection ().setEnableRedirect (enableQueryRedirection );
@@ -3004,8 +3006,11 @@ private TSInsertTabletReq genTSInsertTabletReq(Tablet tablet, boolean sorted, bo
30043006 request .setPrefixPath (tablet .getDeviceId ());
30053007 request .setIsAligned (isAligned );
30063008
3009+ boolean trulyEnableRpcCompression =
3010+ enableIoTDBRpcCompression && tablet .getRowSize () >= tabletCompressionMinRowSize ;
3011+
30073012 List <Byte > encodingTypes ;
3008- if (enableRPCCompression ) {
3013+ if (trulyEnableRpcCompression ) {
30093014 encodingTypes = new ArrayList <>(tablet .getSchemas ().size () + 1 );
30103015 encodingTypes .add (this .columnEncodersMap .get (TSDataType .INT64 ).serialize ());
30113016 for (IMeasurementSchema measurementSchema : tablet .getSchemas ()) {
@@ -3021,11 +3026,11 @@ private TSInsertTabletReq genTSInsertTabletReq(Tablet tablet, boolean sorted, bo
30213026
30223027 TabletEncoder encoder =
30233028 new TabletEncoder (
3024- enableRPCCompression ? this .compressionType : CompressionType .UNCOMPRESSED ,
3029+ trulyEnableRpcCompression ? this .compressionType : CompressionType .UNCOMPRESSED ,
30253030 encodingTypes .stream ().map (TSEncoding ::deserialize ).collect (Collectors .toList ()));
30263031
3027- request .setIsCompressed (this . enableRPCCompression );
3028- if (this . enableRPCCompression ) {
3032+ request .setIsCompressed (trulyEnableRpcCompression );
3033+ if (trulyEnableRpcCompression ) {
30293034 request .setCompressType (compressionType .serialize ());
30303035 request .setEncodingTypes (encodingTypes );
30313036 }
@@ -4238,12 +4243,12 @@ protected void setDefaultSessionConnection(SessionConnection defaultSessionConne
42384243 this .defaultSessionConnection = defaultSessionConnection ;
42394244 }
42404245
4241- public boolean isEnableRPCCompaction () {
4242- return enableRPCCompaction ;
4246+ public boolean isEnableThriftRpcCompaction () {
4247+ return enableThriftRpcCompaction ;
42434248 }
42444249
4245- public void setEnableRPCCompaction (boolean enableRPCCompaction ) {
4246- this .enableRPCCompaction = enableRPCCompaction ;
4250+ public void setEnableThriftRpcCompaction (boolean enableThriftRpcCompaction ) {
4251+ this .enableThriftRpcCompaction = enableThriftRpcCompaction ;
42474252 }
42484253
42494254 public static class Builder extends AbstractSessionBuilder {
0 commit comments