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

Make ordinals start at 0. #5946

Closed
wants to merge 1 commit into from

Conversation

jpountz
Copy link
Contributor

@jpountz jpountz commented Apr 25, 2014

Our ordinals currently start at 1, like FieldCache did in older Lucene versions.
However, Lucene 4.2 changed it in order to make ordinals start at 0, using -1
as the ordinal for the missing value. We should switch to the same numbering as
Lucene for consistency. This also allows to remove some abstraction on top of
Lucene doc values.

Close #5871

Our ordinals currently start at 1, like FieldCache did in older Lucene versions.
However, Lucene 4.2 changed it in order to make ordinals start at 0, using -1
as the ordinal for the missing value. We should switch to the same numbering as
Lucene for consistency. This also allows to remove some abstraction on top of
Lucene doc values.

Close elastic#5871
@@ -259,7 +259,7 @@ public void appendOrdinals(int docID, LongsRef ords) {
}

private final int maxDoc;
private long currentOrd = 0;
private long currentOrd = Ordinals.MIN_ORDINAL - 1;
Copy link
Member

Choose a reason for hiding this comment

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

Minor, as it's the same value, but why not define this as MISSING_ORDINAL instead of MIN_ORDINAL - 1? It does make sense to keep it this way if there is a reasonable expectation that MISSING_ORDINAL is not necessarily -1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think a lot of code would break if MISSING_ORDINAL was not -1, but I did it this way because the expectation in this context is that after the first increment, currentOrd will be equal to MIN_ORDINAL. I don't mind changing it if you think it makes more sense though, I was not sure myself what would make the most sense between MISSING_ORDINAL and MIN_ORDINAL - 1.

Copy link
Member

Choose a reason for hiding this comment

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

I think the justification is completely valid and I am fine with it as-is.

@s1monw
Copy link
Contributor

s1monw commented Apr 26, 2014

this change LGTM why can't this go into 1.2?

@martijnvg
Copy link
Member

LGTM and I think this should go in 1.2 as well?

@jpountz jpountz added v1.2.0 and removed v1.3.0 labels Apr 27, 2014
@jpountz
Copy link
Contributor Author

jpountz commented Apr 27, 2014

I just updated the tags. :-) Will push soon.

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.

Field data: Ordinals should start with 0
5 participants