jt2594838 commented on code in PR #16699:
URL: https://github.com/apache/iotdb/pull/16699#discussion_r2558410722
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/crud/InsertTabletStatement.java:
##########
@@ -612,37 +612,60 @@ public void swapColumn(int src, int target) {
}
@Override
- public void rebuildArraysAfterExpansion(final int[] oldToNewMapping, final
int totalTagCount) {
- final int oldLength = oldToNewMapping.length;
- final int newLength = measurements.length;
+ public void rebuildArraysAfterExpansion(
+ final int[] newToOldMapping, final String[] newMeasurements) {
+ final int newLength = newToOldMapping.length;
+
+ // Call parent to rebuild base arrays
+ super.rebuildArraysAfterExpansion(newToOldMapping, newMeasurements);
// Save old arrays
- final Object[] oldColumns = columns;
final BitMap[] oldNullBitMaps = nullBitMaps;
-
- // Create new arrays: [TAG area: 0~totalTagCount] + [non-TAG area:
totalTagCount~newLength]
- columns = new Object[newLength];
- nullBitMaps = oldNullBitMaps != null ? new BitMap[newLength] : null;
-
- // Initialize all TAG columns with default empty arrays (STRING type)
- for (int tagIdx = 0; tagIdx < totalTagCount; tagIdx++) {
- columns[tagIdx] =
- CommonUtils.createValueColumnOfDataType(
- TSDataType.STRING, TsTableColumnCategory.TAG, rowCount);
- if (nullBitMaps != null) {
- nullBitMaps[tagIdx] = new BitMap(rowCount);
- nullBitMaps[tagIdx].markAll();
+ final Object[] oldColumns = columns;
+ final boolean[] oldMeasurementIsAligned = measurementIsAligned;
+
+ // Create new arrays
+ final BitMap[] newNullBitMaps = new BitMap[newLength];
+ final Object[] newColumns = oldColumns != null ? new Object[newLength] :
null;
+ final boolean[] newMeasurementIsAligned =
+ oldMeasurementIsAligned != null ? new boolean[newLength] : null;
+
+ // Rebuild arrays using mapping: newToOldMapping[newIdx] = oldIdx
+ // If oldIdx == -1, it's a missing TAG column, fill with default values
+ for (int newIdx = 0; newIdx < newLength; newIdx++) {
+ final int oldIdx = newToOldMapping[newIdx];
+ if (oldIdx == -1) {
+ // Create new BitMap with all positions marked (all null)
+ newNullBitMaps[newIdx] = new BitMap(rowCount);
+ newNullBitMaps[newIdx].markAll();
Review Comment:
Not relevant to this PR, but we may add an extension of BitMap like
AllMarkedBitMap, which cannot be marked/unmarked and always returns true when a
position is tested.
This could somehow reduce the memory footprint, because it will not store
any underlying array.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]