Fix partial insert handling for null measurements#17879
Open
Caideyipi wants to merge 2 commits into
Open
Conversation
jt2594838
reviewed
Jun 9, 2026
jt2594838
left a comment
Contributor
There was a problem hiding this comment.
Use a unified entry point to make null-related judgments instead of scattering them around.
Comment on lines
+441
to
+449
| protected Object[] initTabletValuesForSplit(int columnSize, int rowSize, TSDataType[] dataTypes) { | ||
| Object[] values = initTabletValues(columnSize, rowSize, dataTypes); | ||
| for (int i = 0; i < values.length; i++) { | ||
| if (!hasColumnForSplit(i)) { | ||
| values[i] = null; | ||
| } | ||
| } | ||
| return values; | ||
| } |
Contributor
There was a problem hiding this comment.
May init nulls directly in initTabletValues, avoid creating unnecessary objects
|
|
||
| public boolean isValidMeasurement(int i) { | ||
| return measurementSchemas != null | ||
| return measurements != null |
Contributor
There was a problem hiding this comment.
How could measurements be null?
Comment on lines
+340
to
+370
| private static int getValidMeasurementNumber(InsertRowNode insertNode, boolean countFieldOnly) { | ||
| int count = 0; | ||
| for (int i = 0; i < insertNode.getMeasurements().length; i++) { | ||
| if (isValidMeasurement(insertNode, i, countFieldOnly)) { | ||
| count++; | ||
| } | ||
| } | ||
| return count; | ||
| } | ||
|
|
||
| private static int getValidMeasurementNumber( | ||
| InsertTabletNode insertNode, boolean countFieldOnly) { | ||
| int count = 0; | ||
| for (int i = 0; i < insertNode.getMeasurements().length; i++) { | ||
| if (isValidMeasurement(insertNode, i, countFieldOnly) && insertNode.getColumns()[i] != null) { | ||
| count++; | ||
| } | ||
| } | ||
| return count; | ||
| } | ||
|
|
||
| private static boolean isValidMeasurement( | ||
| InsertNode insertNode, int index, boolean countFieldOnly) { | ||
| return insertNode.getMeasurements()[index] != null | ||
| && (!countFieldOnly || isFieldMeasurement(insertNode, index)); | ||
| } | ||
|
|
||
| private static boolean isFieldMeasurement(InsertNode insertNode, int index) { | ||
| return insertNode.getColumnCategories() == null | ||
| || insertNode.getColumnCategories()[index] == TsTableColumnCategory.FIELD; | ||
| } |
Contributor
There was a problem hiding this comment.
May encapsulate these methods into InsertNode to reduce redundancy and improve clarity.
Comment on lines
69
to
84
| public static long getRowRecordSize(List<TSDataType> dataTypes, Object[] value) { | ||
| int emptyRecordCount = 0; | ||
| return getRowRecordSize(dataTypes, value, null); | ||
| } | ||
|
|
||
| public static long getRowRecordSize( | ||
| List<TSDataType> dataTypes, Object[] value, TsTableColumnCategory[] columnCategories) { | ||
| int dataTypeIndex = 0; | ||
| long memSize = 0L; | ||
| for (int i = 0; i < value.length; i++) { | ||
| if (value[i] == null) { | ||
| emptyRecordCount++; | ||
| if (value[i] == null || !isFieldColumn(columnCategories, i)) { | ||
| continue; | ||
| } | ||
| memSize += getRecordSize(dataTypes.get(i - emptyRecordCount), value[i], false); | ||
| memSize += getRecordSize(dataTypes.get(dataTypeIndex++), value[i], false); | ||
| } | ||
| return memSize; | ||
| } |
Contributor
There was a problem hiding this comment.
dataTypes is null-free?
If you enforce some restrictions on it now, you should add some comment to mention it.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary:
Tests: