Skip to content

Commit 9e8b0da

Browse files
authored
fix properties value in wrong order (#246)
1 parent 4f5f373 commit 9e8b0da

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/ObTableSingleOpEntity.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,25 @@ public void adjustRowkeyColumnName(Map<String, Long> columnNameIdxMap) {
283283
this.rowKeyBitMap = byteArray;
284284
}
285285

286+
// Support class, which is used for column name sorted
287+
private static class ColumnNameValuePair implements Comparable<ColumnNameValuePair> {
288+
long number;
289+
// we could use idx here, and adjust obj after compare
290+
String name;
291+
ObObj obj;
292+
293+
ColumnNameValuePair(long number, String name, ObObj obj) {
294+
this.number = number;
295+
this.name = name;
296+
this.obj = obj;
297+
}
298+
299+
@Override
300+
public int compareTo(ColumnNameValuePair other) {
301+
return Long.compare(this.number, other.number);
302+
}
303+
}
304+
286305
public void adjustPropertiesColumnName(Map<String, Long> columnNameIdxMap) {
287306
if (!ignoreEncodePropertiesColumnNames) {
288307
this.propertiesBitLen = columnNameIdxMap.size();
@@ -301,15 +320,17 @@ public void adjustPropertiesColumnName(Map<String, Long> columnNameIdxMap) {
301320
}
302321
}
303322

304-
List<ColumnNamePair> pairs = new ArrayList<>();
323+
List<ColumnNameValuePair> pairs = new ArrayList<>();
305324
for (int i = 0; i < columnNameIdx.size(); i++) {
306-
pairs.add(new ColumnNamePair(columnNameIdx.get(i), propertiesValues.get(i)));
325+
pairs.add(new ColumnNameValuePair(columnNameIdx.get(i), propertiesNames.get(i), propertiesValues.get(i)));
307326
}
308327

309328
Collections.sort(pairs);
310329

330+
propertiesNames = new ArrayList<>(pairs.size());
311331
propertiesValues = new ArrayList<>(pairs.size());
312-
for (ColumnNamePair pair : pairs) {
332+
for (ColumnNameValuePair pair : pairs) {
333+
propertiesNames.add(pair.name);
313334
propertiesValues.add(pair.obj);
314335
}
315336

0 commit comments

Comments
 (0)