Skip to content

Commit 0876dbd

Browse files
authored
Merge pull request #211 from Zhou-jw/hbase_2.0_test
fix [multi cf] put random binary column, qualifier unexpectedly expan…
2 parents f0f2f0d + 04cd3e3 commit 0876dbd

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

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

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,46 +2111,50 @@ private com.alipay.oceanbase.rpc.mutation.Mutation buildMutation(Cell kv,
21112111
ObTableOperationType operationType,
21122112
boolean isTableGroup,
21132113
byte[] family, Long TTL) {
2114-
Cell new_cell = kv;
2114+
Cell newCell = kv;
21152115
if (isTableGroup && family != null) {
2116-
new_cell = modifyQualifier(kv, (Bytes.toString(family) + "." + Bytes.toString(CellUtil
2117-
.cloneQualifier(kv))).getBytes());
2116+
byte[] oldQualifier = CellUtil.cloneQualifier(kv);
2117+
byte[] newQualifier = new byte[family.length + 1/* length of "." */ + oldQualifier.length];
2118+
System.arraycopy(family, 0, newQualifier, 0, family.length);
2119+
newQualifier[family.length] = 0x2E; // 0x2E in utf-8 is "."
2120+
System.arraycopy(oldQualifier, 0, newQualifier, family.length + 1, oldQualifier.length);
2121+
newCell = modifyQualifier(kv, newQualifier);
21182122
}
21192123
Cell.Type kvType = kv.getType();
21202124
switch (kvType) {
21212125
case Put:
2122-
String[] property_columns = V_COLUMNS;
2123-
Object[] property = new Object[] { CellUtil.cloneValue(new_cell) };
2126+
String[] propertyColumns = V_COLUMNS;
2127+
Object[] property = new Object[] { CellUtil.cloneValue(newCell) };
21242128
if (TTL != Long.MAX_VALUE) {
2125-
property_columns = PROPERTY_COLUMNS;
2126-
property = new Object[] { CellUtil.cloneValue(new_cell), TTL };
2129+
propertyColumns = PROPERTY_COLUMNS;
2130+
property = new Object[] { CellUtil.cloneValue(newCell), TTL };
21272131
}
21282132
return com.alipay.oceanbase.rpc.mutation.Mutation.getInstance(operationType,
21292133
ROW_KEY_COLUMNS,
2130-
new Object[] { CellUtil.cloneRow(new_cell), CellUtil.cloneQualifier(new_cell),
2131-
new_cell.getTimestamp() }, property_columns, property);
2134+
new Object[] { CellUtil.cloneRow(newCell), CellUtil.cloneQualifier(newCell),
2135+
newCell.getTimestamp() }, propertyColumns, property);
21322136
case Delete:
21332137
return com.alipay.oceanbase.rpc.mutation.Mutation.getInstance(DEL, ROW_KEY_COLUMNS,
2134-
new Object[] { CellUtil.cloneRow(new_cell), CellUtil.cloneQualifier(new_cell),
2135-
new_cell.getTimestamp() }, null, null);
2138+
new Object[] { CellUtil.cloneRow(newCell), CellUtil.cloneQualifier(newCell),
2139+
newCell.getTimestamp() }, null, null);
21362140
case DeleteColumn:
21372141
return com.alipay.oceanbase.rpc.mutation.Mutation.getInstance(DEL, ROW_KEY_COLUMNS,
2138-
new Object[] { CellUtil.cloneRow(new_cell), CellUtil.cloneQualifier(new_cell),
2139-
-new_cell.getTimestamp() }, null, null);
2142+
new Object[] { CellUtil.cloneRow(newCell), CellUtil.cloneQualifier(newCell),
2143+
-newCell.getTimestamp() }, null, null);
21402144
case DeleteFamily:
21412145
return com.alipay.oceanbase.rpc.mutation.Mutation.getInstance(
21422146
DEL,
21432147
ROW_KEY_COLUMNS,
2144-
new Object[] { CellUtil.cloneRow(new_cell),
2145-
isTableGroup ? CellUtil.cloneQualifier(new_cell) : null,
2146-
-new_cell.getTimestamp() }, null, null);
2148+
new Object[] { CellUtil.cloneRow(newCell),
2149+
isTableGroup ? CellUtil.cloneQualifier(newCell) : null,
2150+
-newCell.getTimestamp() }, null, null);
21472151
case DeleteFamilyVersion:
21482152
return com.alipay.oceanbase.rpc.mutation.Mutation.getInstance(
21492153
DEL,
21502154
ROW_KEY_COLUMNS,
2151-
new Object[] { CellUtil.cloneRow(new_cell),
2152-
isTableGroup ? CellUtil.cloneQualifier(new_cell) : null,
2153-
new_cell.getTimestamp() }, null, null);
2155+
new Object[] { CellUtil.cloneRow(newCell),
2156+
isTableGroup ? CellUtil.cloneQualifier(newCell) : null,
2157+
newCell.getTimestamp() }, null, null);
21542158
default:
21552159
throw new IllegalArgumentException("illegal mutation type " + operationType);
21562160
}
@@ -2292,18 +2296,18 @@ public static ObTableOperation buildObTableOperation(Cell kv,
22922296
ObTableOperationType operationType,
22932297
Long TTL) {
22942298
Cell.Type kvType = kv.getType();
2295-
String[] property_columns = V_COLUMNS;
2299+
String[] propertyColumns = V_COLUMNS;
22962300
Object[] property = new Object[] { CellUtil.cloneValue(kv) };
22972301
if (TTL != Long.MAX_VALUE) {
2298-
property_columns = PROPERTY_COLUMNS;
2302+
propertyColumns = PROPERTY_COLUMNS;
22992303
property = new Object[] { CellUtil.cloneValue(kv), TTL };
23002304
}
23012305
switch (kvType) {
23022306
case Put:
23032307
return getInstance(
23042308
operationType,
23052309
new Object[] { CellUtil.cloneRow(kv), CellUtil.cloneQualifier(kv),
2306-
kv.getTimestamp() }, property_columns, property);
2310+
kv.getTimestamp() }, propertyColumns, property);
23072311
case Delete:
23082312
return getInstance(
23092313
DEL,

0 commit comments

Comments
 (0)