[ 
https://issues.apache.org/jira/browse/LUCENE-5192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13754040#comment-13754040
 ] 

Shai Erera commented on LUCENE-5192:
------------------------------------

In that case it should change to:

{code:java}
if (docValues != null) {
  if (!fi.hasDocValues()) {
    // First time we are seeing doc values type for
    // this field:
    fi.setDocValuesType(docValues);

    // must also update docValuesType map so it's
    // aware of this field's DocValueType 
    globalFieldNumbers.setDocValuesType(fi.number, name, docValues);
  } else if (docValues != fi.getDocValuesType()) {
    // THROW EX
  }
}
{code}

Or, we do this:

{code:java}
if (docValues != null) {
  // only pay the synchronization cost if fi does not already have a DVType
  boolean updateGlobal = !fi.hasDocValues();
  fi.setDocValuesType(docValues); // this will also perform the consistency 
check.
  if (updateGlobal) {
    globalFieldNumbers.set(...);
  }
}
{code}

Since FieldInfo.setDVType is also called from DocFieldsProcessor, I prefer to 
try and keep the consistency check in one place.
                
> FieldInfos.Builder failed to catch adding field with different DV type under 
> some circumstances
> -----------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-5192
>                 URL: https://issues.apache.org/jira/browse/LUCENE-5192
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/index
>            Reporter: Shai Erera
>            Assignee: Shai Erera
>             Fix For: 5.0, 4.5
>
>         Attachments: LUCENE-5192.patch, LUCENE-5192.patch
>
>
> I found it while working on LUCENE-5189. I'll attach a patch with a simple 
> testcase which reproduces the problem and a fix.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to