Skip to content

Commit f330d08

Browse files
committed
[core] Optimize DataFileMeta.keyStats to EMPTY_STATS to reduce memory usage
1 parent bc25e88 commit f330d08

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

paimon-core/src/main/java/org/apache/paimon/stats/SimpleStats.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.paimon.data.BinaryArray;
2323
import org.apache.paimon.data.BinaryRow;
2424
import org.apache.paimon.data.GenericRow;
25+
import org.apache.paimon.data.InternalArray;
2526
import org.apache.paimon.data.InternalRow;
2627
import org.apache.paimon.types.ArrayType;
2728
import org.apache.paimon.types.BigIntType;
@@ -93,10 +94,15 @@ public InternalRow toRow() {
9394
}
9495

9596
public static SimpleStats fromRow(InternalRow row) {
96-
return new SimpleStats(
97-
deserializeBinaryRow(row.getBinary(0)),
98-
deserializeBinaryRow(row.getBinary(1)),
99-
BinaryArray.fromLongArray(row.getArray(2)));
97+
BinaryRow minValues = deserializeBinaryRow(row.getBinary(0));
98+
BinaryRow maxValues = deserializeBinaryRow(row.getBinary(1));
99+
InternalArray nullCounts = row.getArray(2);
100+
if (minValues.getFieldCount() == 0
101+
&& maxValues.getFieldCount() == 0
102+
&& nullCounts.size() == 0) {
103+
return EMPTY_STATS;
104+
}
105+
return new SimpleStats(minValues, maxValues, BinaryArray.fromLongArray(nullCounts));
100106
}
101107

102108
@Override

0 commit comments

Comments
 (0)