Skip to content

Commit 84e0c68

Browse files
authored
Merge pull request #328 from oceanbase/control_if_use_put_opt
add config to control if use put opt
2 parents 0d27b08 + dbc1b68 commit 84e0c68

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

src/main/java/com/alipay/oceanbase/hbase/OHTable.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ public class OHTable implements Table {
160160
*/
161161
private int maxKeyValueSize;
162162

163+
/**
164+
* whether to enable put optimization path
165+
*/
166+
private boolean enablePutOptimization;
167+
163168
// i.e., doPut checks the writebuffer every X Puts.
164169

165170
/**
@@ -460,6 +465,8 @@ private void finishSetUp() {
460465
(this.operationTimeout != HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT));
461466
this.maxKeyValueSize = this.configuration.getInt(MAX_KEYVALUE_SIZE_KEY,
462467
MAX_KEYVALUE_SIZE_DEFAULT);
468+
this.enablePutOptimization = this.configuration.getBoolean(HBASE_HTABLE_USE_PUT_OPTIMIZATION,
469+
HBASE_HTABLE_USE_PUT_OPTIMIZATION_DEFAULT);
463470
}
464471

465472
public static OHConnectionConfiguration setUserDefinedNamespace(String tableNameString,
@@ -793,7 +800,7 @@ private void innerBatchImpl(final List<? extends Row> actions, final Object[] re
793800
} catch (Exception e) {
794801
throw new IOException(tableNameString + " table occurred unexpected error." , e);
795802
}
796-
} else if (OHBaseFuncUtils.isAllPut(opType, actions) && OHBaseFuncUtils.isHBasePutPefSupport(obTableClient)) {
803+
} else if (OHBaseFuncUtils.isAllPut(opType, actions) && OHBaseFuncUtils.isHBasePutPefSupport(obTableClient, enablePutOptimization)) {
797804
// only support Put now
798805
ObHbaseRequest request = buildHbaseRequest(actions, opType);
799806
try {
@@ -1357,7 +1364,7 @@ private void doPut(List<Put> puts, OHOperationType opType) throws IOException {
13571364
validatePut(put);
13581365
checkFamilyViolation(put.getFamilyCellMap().keySet(), true);
13591366
}
1360-
if (OHBaseFuncUtils.isHBasePutPefSupport(obTableClient)) {
1367+
if (OHBaseFuncUtils.isHBasePutPefSupport(obTableClient, enablePutOptimization)) {
13611368
flushCommitsV2(puts, opType);
13621369
} else {
13631370
flushCommits(puts, opType);

src/main/java/com/alipay/oceanbase/hbase/constants/OHConstants.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ public final class OHConstants {
160160
* Default is false (disabled).
161161
*/
162162
public static final String HBASE_HTABLE_AUTO_FILL_TIMESTAMP_IN_CLIENT = "hbase.htable.auto.fill.timestamp.in.client";
163+
164+
/**
165+
* use to specify whether to enable put optimization path.
166+
* Default is true (enabled).
167+
*/
168+
public static final String HBASE_HTABLE_USE_PUT_OPTIMIZATION = "hbase.htable.use.put.optimization";
169+
163170
/*-------------------------------------------------------------------------------------------------------------*/
164171

165172
/**
@@ -191,4 +198,6 @@ public final class OHConstants {
191198

192199
public static final int DEFAULT_SOCKET_TIMEOUT = 20000; // 20 seconds
193200

201+
public static final boolean HBASE_HTABLE_USE_PUT_OPTIMIZATION_DEFAULT = true;
202+
194203
}

src/main/java/com/alipay/oceanbase/hbase/util/OHBaseFuncUtils.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ public static byte[][] extractFamilyFromQualifier(byte[] qualifier) throws Excep
5252
return new byte[][] { family, newQualifier };
5353
}
5454

55-
public static boolean isHBasePutPefSupport(ObTableClient tableClient) {
55+
public static boolean isHBasePutPefSupport(ObTableClient tableClient, boolean enablePutOptimization) {
56+
// If client-side optimization is disabled, return false directly
57+
if (!enablePutOptimization) {
58+
return false;
59+
}
60+
5661
if (tableClient.isOdpMode()) {
5762
// server version support and distributed capacity is enabled and odp version support
5863
return ObGlobal.isHBasePutPerfSupport()

src/test/java/com/alipay/oceanbase/hbase/secondary/OHTableFillTimestampInClientTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ public static void finish() throws Exception {
5353
dropTable();
5454
}
5555

56-
@Before
57-
public void prepareCase() throws Exception {
58-
truncateTable();
59-
}
60-
6156
/**
6257
* Create dynamic partition table for testing
6358
*/

0 commit comments

Comments
 (0)