Skip to content

Comments

API, Core: Align offsets of field stats with Design doc / Spec#15432

Open
nastra wants to merge 1 commit intoapache:mainfrom
nastra:content-stats-update-offsets
Open

API, Core: Align offsets of field stats with Design doc / Spec#15432
nastra wants to merge 1 commit intoapache:mainfrom
nastra:content-stats-update-offsets

Conversation

@nastra
Copy link
Contributor

@nastra nastra commented Feb 24, 2026

This aligns the offsets in the impl with the offets mentioned in the design doc and the Spec. The offsets are starting at 1 and are describing the offset of the field ID from the base stats structure, whereas the Java impl was using the offsets based on their position (0-based) within the stats structure.

}

public static Types.StructType fieldStatsFor(Type type, int fieldId) {
public static Types.StructType fieldStatsFor(Type type, int baseFieldId) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we used to always pass baseFieldId + 1 here instead of just the baseFieldId

@nastra nastra requested review from Fokko and danielcweeks February 24, 2026 14:56
@nastra nastra force-pushed the content-stats-update-offsets branch from 139be61 to 87bc9cf Compare February 24, 2026 15:15
Copy link
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch @nastra 🙌

assertThatThrownBy(() -> assertThat(fieldStats.get(10, Long.class)))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Invalid statistic offset: 10");
.hasMessage("Invalid statistic position: 10");
Copy link
Contributor

@huaxingao huaxingao Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the line below, should it use VALUE_COUNT.offset() - 1?

record.set(LOWER_BOUND.offset(), fieldStats.lowerBound());
record.set(UPPER_BOUND.offset(), fieldStats.upperBound());
record.set(EXACT_BOUNDS.offset(), fieldStats.hasExactBounds());
record.set(VALUE_COUNT.offset() - 1, fieldStats.valueCount());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we can probably introduce a position method in the enum definition. its implementation would just be offset() - 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants