Skip to content

Commit

Permalink
fix properties value in wrong order
Browse files Browse the repository at this point in the history
  • Loading branch information
miyuan-ljr committed Nov 27, 2024
1 parent 70ca8e1 commit 873173c
Showing 1 changed file with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,25 @@ public void adjustRowkeyColumnName(Map<String, Long> columnNameIdxMap) {
this.rowKeyBitMap = byteArray;
}

// Support class, which is used for column name sorted
private static class ColumnNameValuePair implements Comparable<ColumnNameValuePair> {
long number;
// we could use idx here, and adjust obj after compare
String name;
ObObj obj;

ColumnNameValuePair(long number, String name, ObObj obj) {
this.number = number;
this.name = name;
this.obj = obj;
}

@Override
public int compareTo(ColumnNameValuePair other) {
return Long.compare(this.number, other.number);
}
}

public void adjustPropertiesColumnName(Map<String, Long> columnNameIdxMap) {
if (!ignoreEncodePropertiesColumnNames) {
this.propertiesBitLen = columnNameIdxMap.size();
Expand All @@ -301,15 +320,17 @@ public void adjustPropertiesColumnName(Map<String, Long> columnNameIdxMap) {
}
}

List<ColumnNamePair> pairs = new ArrayList<>();
List<ColumnNameValuePair> pairs = new ArrayList<>();
for (int i = 0; i < columnNameIdx.size(); i++) {
pairs.add(new ColumnNamePair(columnNameIdx.get(i), propertiesValues.get(i)));
pairs.add(new ColumnNameValuePair(columnNameIdx.get(i), propertiesNames.get(i), propertiesValues.get(i)));
}

Collections.sort(pairs);

propertiesNames = new ArrayList<>(pairs.size());
propertiesValues = new ArrayList<>(pairs.size());
for (ColumnNamePair pair : pairs) {
for (ColumnNameValuePair pair : pairs) {
propertiesNames.add(pair.name);
propertiesValues.add(pair.obj);
}

Expand Down

0 comments on commit 873173c

Please sign in to comment.