You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Danish Contractor (JIRA)" <ji...@apache.org> on 2009/11/04 16:09:32 UTC

[jira] Created: (LUCENE-2028) FilteredTermEnum.Java - The first term in the enumeration is skipped.

FilteredTermEnum.Java - The first term in the enumeration is skipped.
---------------------------------------------------------------------

                 Key: LUCENE-2028
                 URL: https://issues.apache.org/jira/browse/LUCENE-2028
             Project: Lucene - Java
          Issue Type: Bug
          Components: Search
    Affects Versions: 2.4.1
         Environment: JDK 1.6 
            Reporter: Danish Contractor


The Filtered Term Enumeration seems to skip the first term present in the enumerator. 
The problem lies in the next() function, which moves does not do anything with the first value of currentTerm set by the setEnum() method.

The setEnum() function sets a value to the currentTerm and returns. An implementation of WildCardTermEnum, for example calls the next() method where the currentTerm is set to null and the enumerator moves to the next value. The first term is not read.

In my local workspace, I have modified the two methods - setEnum() and next() as follows:

protected void setEnum(TermEnum actualEnum) throws IOException {
        this.actualEnum = actualEnum;
        this.startedReading=false;
        // Find the first term that matches
        Term term = actualEnum.term();
        if (term != null && termCompare(term)) 
            currentTerm = term;
        else next();
    }

/** Increments the enumeration to the next element.  True if one exists. */
    public boolean next() throws IOException {
        if (actualEnum == null) return false; // the actual enumerator is not initialized!
        if(currentTerm!=null &&!startedReading) //check if first term read
        {
        	startedReading=true;
        	return true;
        }
        currentTerm = null;
        while (currentTerm == null) {
            if (endEnum()) return false;
            if (actualEnum.next()) {
                Term term = actualEnum.term();
                if (termCompare(term)) {
                    currentTerm = term;
                    return true;
                }
            }
            else return false;
        }
        currentTerm = null;
        return false;
    }

I have added a boolean variable called startedReading that is a member of the FilteredTermEnum class and is set to false. Once the currentTerm set by setEnum is read, I set this value to true and the code continues as before.

I have run a few of my own test cases and it returns the results  I was looking for which were missing earlier as they happened to be the first term in the enumerator.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-2028) FilteredTermEnum.Java - The first term in the enumeration is skipped.

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-2028?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12773550#action_12773550 ] 

Uwe Schindler commented on LUCENE-2028:
---------------------------------------

There is nothing wrong with FilteredTermEnum. All TermEnums in Lucene behave like this. After creating them, they point to the first term in the enum and you have to call next() *after* consuming this term.

> FilteredTermEnum.Java - The first term in the enumeration is skipped.
> ---------------------------------------------------------------------
>
>                 Key: LUCENE-2028
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2028
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 2.4.1
>         Environment: JDK 1.6 
>            Reporter: Danish Contractor
>         Attachments: FilteredTermEnum.java
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The Filtered Term Enumeration seems to skip the first term present in the enumerator. 
> The problem lies in the next() function, which moves does not do anything with the first value of currentTerm set by the setEnum() method.
> The setEnum() function sets a value to the currentTerm and returns. An implementation of WildCardTermEnum, for example calls the next() method where the currentTerm is set to null and the enumerator moves to the next value. The first term is not read.
> In my local workspace, I have modified the next()  method as follows:
> /** Increments the enumeration to the next element.  True if one exists. */
>     public boolean next() throws IOException {
>         if (actualEnum == null) return false; // the actual enumerator is not initialized!
>         if(currentTerm!=null &&!startedReading) //check if first term read
>         {
>         	startedReading=true;
>         	return true;
>         }
>         currentTerm = null;
>         while (currentTerm == null) {
>             if (endEnum()) return false;
>             if (actualEnum.next()) {
>                 Term term = actualEnum.term();
>                 if (termCompare(term)) {
>                     currentTerm = term;
>                     return true;
>                 }
>             }
>             else return false;
>         }
>         currentTerm = null;
>         return false;
>     }
> I have added a boolean variable called startedReading that is a member of the FilteredTermEnum class and is set to false. Once the currentTerm set by setEnum is read, I set this value to true and the code continues as before.
> I have run a few of my own test cases and it returns the results  I was looking for which were missing earlier as they happened to be the first term in the enumerator.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Updated: (LUCENE-2028) FilteredTermEnum.Java - The first term in the enumeration is skipped.

Posted by "Danish Contractor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-2028?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Danish Contractor updated LUCENE-2028:
--------------------------------------

    Description: 
The Filtered Term Enumeration seems to skip the first term present in the enumerator. 
The problem lies in the next() function, which moves does not do anything with the first value of currentTerm set by the setEnum() method.

The setEnum() function sets a value to the currentTerm and returns. An implementation of WildCardTermEnum, for example calls the next() method where the currentTerm is set to null and the enumerator moves to the next value. The first term is not read.

In my local workspace, I have modified the next()  method as follows:

/** Increments the enumeration to the next element.  True if one exists. */
    public boolean next() throws IOException {
        if (actualEnum == null) return false; // the actual enumerator is not initialized!
        if(currentTerm!=null &&!startedReading) //check if first term read
        {
        	startedReading=true;
        	return true;
        }
        currentTerm = null;
        while (currentTerm == null) {
            if (endEnum()) return false;
            if (actualEnum.next()) {
                Term term = actualEnum.term();
                if (termCompare(term)) {
                    currentTerm = term;
                    return true;
                }
            }
            else return false;
        }
        currentTerm = null;
        return false;
    }

I have added a boolean variable called startedReading that is a member of the FilteredTermEnum class and is set to false. Once the currentTerm set by setEnum is read, I set this value to true and the code continues as before.

I have run a few of my own test cases and it returns the results  I was looking for which were missing earlier as they happened to be the first term in the enumerator.


  was:
The Filtered Term Enumeration seems to skip the first term present in the enumerator. 
The problem lies in the next() function, which moves does not do anything with the first value of currentTerm set by the setEnum() method.

The setEnum() function sets a value to the currentTerm and returns. An implementation of WildCardTermEnum, for example calls the next() method where the currentTerm is set to null and the enumerator moves to the next value. The first term is not read.

In my local workspace, I have modified the two methods - setEnum() and next() as follows:

protected void setEnum(TermEnum actualEnum) throws IOException {
        this.actualEnum = actualEnum;
        this.startedReading=false;
        // Find the first term that matches
        Term term = actualEnum.term();
        if (term != null && termCompare(term)) 
            currentTerm = term;
        else next();
    }

/** Increments the enumeration to the next element.  True if one exists. */
    public boolean next() throws IOException {
        if (actualEnum == null) return false; // the actual enumerator is not initialized!
        if(currentTerm!=null &&!startedReading) //check if first term read
        {
        	startedReading=true;
        	return true;
        }
        currentTerm = null;
        while (currentTerm == null) {
            if (endEnum()) return false;
            if (actualEnum.next()) {
                Term term = actualEnum.term();
                if (termCompare(term)) {
                    currentTerm = term;
                    return true;
                }
            }
            else return false;
        }
        currentTerm = null;
        return false;
    }

I have added a boolean variable called startedReading that is a member of the FilteredTermEnum class and is set to false. Once the currentTerm set by setEnum is read, I set this value to true and the code continues as before.

I have run a few of my own test cases and it returns the results  I was looking for which were missing earlier as they happened to be the first term in the enumerator.



> FilteredTermEnum.Java - The first term in the enumeration is skipped.
> ---------------------------------------------------------------------
>
>                 Key: LUCENE-2028
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2028
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 2.4.1
>         Environment: JDK 1.6 
>            Reporter: Danish Contractor
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The Filtered Term Enumeration seems to skip the first term present in the enumerator. 
> The problem lies in the next() function, which moves does not do anything with the first value of currentTerm set by the setEnum() method.
> The setEnum() function sets a value to the currentTerm and returns. An implementation of WildCardTermEnum, for example calls the next() method where the currentTerm is set to null and the enumerator moves to the next value. The first term is not read.
> In my local workspace, I have modified the next()  method as follows:
> /** Increments the enumeration to the next element.  True if one exists. */
>     public boolean next() throws IOException {
>         if (actualEnum == null) return false; // the actual enumerator is not initialized!
>         if(currentTerm!=null &&!startedReading) //check if first term read
>         {
>         	startedReading=true;
>         	return true;
>         }
>         currentTerm = null;
>         while (currentTerm == null) {
>             if (endEnum()) return false;
>             if (actualEnum.next()) {
>                 Term term = actualEnum.term();
>                 if (termCompare(term)) {
>                     currentTerm = term;
>                     return true;
>                 }
>             }
>             else return false;
>         }
>         currentTerm = null;
>         return false;
>     }
> I have added a boolean variable called startedReading that is a member of the FilteredTermEnum class and is set to false. Once the currentTerm set by setEnum is read, I set this value to true and the code continues as before.
> I have run a few of my own test cases and it returns the results  I was looking for which were missing earlier as they happened to be the first term in the enumerator.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Closed: (LUCENE-2028) FilteredTermEnum.Java - The first term in the enumeration is skipped.

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-2028?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Uwe Schindler closed LUCENE-2028.
---------------------------------

    Resolution: Invalid

> FilteredTermEnum.Java - The first term in the enumeration is skipped.
> ---------------------------------------------------------------------
>
>                 Key: LUCENE-2028
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2028
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 2.4.1
>         Environment: JDK 1.6 
>            Reporter: Danish Contractor
>         Attachments: FilteredTermEnum.java
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The Filtered Term Enumeration seems to skip the first term present in the enumerator. 
> The problem lies in the next() function, which moves does not do anything with the first value of currentTerm set by the setEnum() method.
> The setEnum() function sets a value to the currentTerm and returns. An implementation of WildCardTermEnum, for example calls the next() method where the currentTerm is set to null and the enumerator moves to the next value. The first term is not read.
> In my local workspace, I have modified the next()  method as follows:
> /** Increments the enumeration to the next element.  True if one exists. */
>     public boolean next() throws IOException {
>         if (actualEnum == null) return false; // the actual enumerator is not initialized!
>         if(currentTerm!=null &&!startedReading) //check if first term read
>         {
>         	startedReading=true;
>         	return true;
>         }
>         currentTerm = null;
>         while (currentTerm == null) {
>             if (endEnum()) return false;
>             if (actualEnum.next()) {
>                 Term term = actualEnum.term();
>                 if (termCompare(term)) {
>                     currentTerm = term;
>                     return true;
>                 }
>             }
>             else return false;
>         }
>         currentTerm = null;
>         return false;
>     }
> I have added a boolean variable called startedReading that is a member of the FilteredTermEnum class and is set to false. Once the currentTerm set by setEnum is read, I set this value to true and the code continues as before.
> I have run a few of my own test cases and it returns the results  I was looking for which were missing earlier as they happened to be the first term in the enumerator.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Updated: (LUCENE-2028) FilteredTermEnum.Java - The first term in the enumeration is skipped.

Posted by "Danish Contractor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-2028?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Danish Contractor updated LUCENE-2028:
--------------------------------------

    Attachment: FilteredTermEnum.java

My version of the file.

> FilteredTermEnum.Java - The first term in the enumeration is skipped.
> ---------------------------------------------------------------------
>
>                 Key: LUCENE-2028
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2028
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 2.4.1
>         Environment: JDK 1.6 
>            Reporter: Danish Contractor
>         Attachments: FilteredTermEnum.java
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The Filtered Term Enumeration seems to skip the first term present in the enumerator. 
> The problem lies in the next() function, which moves does not do anything with the first value of currentTerm set by the setEnum() method.
> The setEnum() function sets a value to the currentTerm and returns. An implementation of WildCardTermEnum, for example calls the next() method where the currentTerm is set to null and the enumerator moves to the next value. The first term is not read.
> In my local workspace, I have modified the next()  method as follows:
> /** Increments the enumeration to the next element.  True if one exists. */
>     public boolean next() throws IOException {
>         if (actualEnum == null) return false; // the actual enumerator is not initialized!
>         if(currentTerm!=null &&!startedReading) //check if first term read
>         {
>         	startedReading=true;
>         	return true;
>         }
>         currentTerm = null;
>         while (currentTerm == null) {
>             if (endEnum()) return false;
>             if (actualEnum.next()) {
>                 Term term = actualEnum.term();
>                 if (termCompare(term)) {
>                     currentTerm = term;
>                     return true;
>                 }
>             }
>             else return false;
>         }
>         currentTerm = null;
>         return false;
>     }
> I have added a boolean variable called startedReading that is a member of the FilteredTermEnum class and is set to false. Once the currentTerm set by setEnum is read, I set this value to true and the code continues as before.
> I have run a few of my own test cases and it returns the results  I was looking for which were missing earlier as they happened to be the first term in the enumerator.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org