Skip to content

Commit af96e89

Browse files
authored
lsop encode opt (#339)
* opt for lsop getPayLoadContentSize * add performa test for ObTableLsOperationRequest encode * use ObByteBuf to encode lsop * lsop request encode perf opt * add default bytes cache for obkvparam and ohtablefilter * Revert "add default bytes cache for obkvparam and ohtablefilter" This reverts commit 8a555ef. * add default bytes cache for obkvparam and ohtablefilter * fix bug for indexName encode
1 parent c9a8c08 commit af96e89

File tree

17 files changed

+1278
-168
lines changed

17 files changed

+1278
-168
lines changed

src/main/java/com/alipay/oceanbase/rpc/protocol/payload/AbstractPayload.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.alipay.oceanbase.rpc.protocol.payload;
1919

20+
import com.alipay.oceanbase.rpc.util.ObByteBuf;
2021
import com.alipay.oceanbase.rpc.util.Serialization;
2122
import io.netty.buffer.ByteBuf;
2223

@@ -37,14 +38,18 @@
3738
public abstract class AbstractPayload implements ObPayload {
3839

3940
private static final AtomicInteger CHANNELID = new AtomicInteger(1);
41+
protected static final long INVALID_PAYLOAD_CONTENT_SIZE = -1;
4042
private long uniqueId;
4143
private long sequence;
4244
private Integer channelId = null;
4345
protected long tenantId = 1;
4446
private long version = 1;
4547
protected long timeout = RPC_OPERATION_TIMEOUT.getDefaultLong();
4648
protected int groupId = 0;
47-
49+
// for perf opt
50+
protected long payLoadContentSize = INVALID_PAYLOAD_CONTENT_SIZE;
51+
protected static volatile byte[] defaultEncodeBytes = null;
52+
protected static volatile long defaultPayLoadSize = INVALID_PAYLOAD_CONTENT_SIZE;
4853
/*
4954
* Get pcode.
5055
*/
@@ -183,4 +188,22 @@ protected int encodeHeader(byte[] bytes, int idx) {
183188
return idx;
184189
}
185190

191+
protected void encodeHeader(ObByteBuf buf) {
192+
encodeObUniVersionHeader(buf, getVersion(), getPayloadContentSize());
193+
}
194+
195+
// for perf opt
196+
protected byte[] encodeDefaultBytes() {
197+
if (defaultEncodeBytes == null) {
198+
synchronized (this.getClass()) {
199+
if (defaultEncodeBytes == null) {
200+
defaultEncodeBytes = encode();
201+
}
202+
}
203+
}
204+
return defaultEncodeBytes;
205+
}
206+
207+
protected boolean isUseDefaultEncode() { return false; }
208+
186209
}

0 commit comments

Comments
 (0)