Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] properties value in wrong order #246

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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