You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Michael McCandless (JIRA)" <ji...@apache.org> on 2011/04/30 22:59:03 UTC

[jira] [Created] (LUCENE-3058) FST should allow more than one output for the same input

FST should allow more than one output for the same input
--------------------------------------------------------

                 Key: LUCENE-3058
                 URL: https://issues.apache.org/jira/browse/LUCENE-3058
             Project: Lucene - Java
          Issue Type: Improvement
            Reporter: Michael McCandless
            Assignee: Michael McCandless
             Fix For: 4.0


For the block tree terms dict, it turns out I need this case.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


Re: (LUCENE-3058) FST should allow more than one output for the same input

Posted by Michael McCandless <lu...@mikemccandless.com>.
On Tue, May 3, 2011 at 8:21 AM, Dawid Weiss
<da...@cs.put.poznan.pl> wrote:

> It's similar to operator priorities -- I just like to
> have explicit brackets instead of relying on my degenerating memory...

I don't normally do this (adding ()'s around operators just to be
sure).... but I think I will now start doing so!

The bit shift operators in java always freak me out.  They are too powerful.

Mike

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


Re: (LUCENE-3058) FST should allow more than one output for the same input

Posted by Dawid Weiss <da...@cs.put.poznan.pl>.
I usually do an explicit check for nulls and that's why I allowed myself to
bring the issue up. It's similar to operator priorities -- I just like to
have explicit brackets instead of relying on my degenerating memory... As
for sorting, I don't like to rely on the default hashCode/equals exactly for
the reasons you mentioned and prefer explicit comparators. It's really a
pity there is no full hashcode/equals delegation model in java util
collections, it would be a nice addition.

On Tue, May 3, 2011 at 10:41 AM, Uwe Schindler (JIRA) <ji...@apache.org>wrote:

>
>    [
> https://issues.apache.org/jira/browse/LUCENE-3058?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13028109#comment-13028109]
>
> Uwe Schindler commented on LUCENE-3058:
> ---------------------------------------
>
> :-) It always confuses me, too. But if you think more about it, it makes
> sense to return false. But it's the same always for me: Whenever I write
> equals() methods, this question pops up. But now I mostly copy code like the
> one above from other classes. But you have to note: The above equals() code
> is only 100% suitable for final classes, else it could happen that a
> subclass that extends some fields is equal. But thats more a theoretical
> discussion. E.g. Lucene's Queries always check
> this.getClass()==other.getClass().
>
> > FST should allow more than one output for the same input
> > --------------------------------------------------------
> >
> >                 Key: LUCENE-3058
> >                 URL: https://issues.apache.org/jira/browse/LUCENE-3058
> >             Project: Lucene - Java
> >          Issue Type: Improvement
> >            Reporter: Michael McCandless
> >            Assignee: Michael McCandless
> >             Fix For: 4.0
> >
> >         Attachments: LUCENE-3058.patch, LUCENE-3058.patch
> >
> >
> > For the block tree terms dict, it turns out I need this case.
>
> --
> This message is automatically generated by JIRA.
> For more information on JIRA, see: http://www.atlassian.com/software/jira
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>

[jira] [Updated] (LUCENE-3058) FST should allow more than one output for the same input

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

Michael McCandless updated LUCENE-3058:
---------------------------------------

    Attachment: LUCENE-3058.patch

New patch; no change -- just more friendly for "patch" (looks like svn diff not hg diff).

> FST should allow more than one output for the same input
> --------------------------------------------------------
>
>                 Key: LUCENE-3058
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3058
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>             Fix For: 4.0
>
>         Attachments: LUCENE-3058.patch, LUCENE-3058.patch
>
>
> For the block tree terms dict, it turns out I need this case.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Commented] (LUCENE-3058) FST should allow more than one output for the same input

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

Michael McCandless commented on LUCENE-3058:
--------------------------------------------

OK thanks Uwe... I'll commit.

> FST should allow more than one output for the same input
> --------------------------------------------------------
>
>                 Key: LUCENE-3058
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3058
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>             Fix For: 4.0
>
>         Attachments: LUCENE-3058.patch, LUCENE-3058.patch, LUCENE-3058.patch
>
>
> For the block tree terms dict, it turns out I need this case.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Resolved] (LUCENE-3058) FST should allow more than one output for the same input

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

Michael McCandless resolved LUCENE-3058.
----------------------------------------

    Resolution: Fixed

> FST should allow more than one output for the same input
> --------------------------------------------------------
>
>                 Key: LUCENE-3058
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3058
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>             Fix For: 4.0
>
>         Attachments: LUCENE-3058.patch, LUCENE-3058.patch
>
>
> For the block tree terms dict, it turns out I need this case.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Issue Comment Edited] (LUCENE-3058) FST should allow more than one output for the same input

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

Dawid Weiss edited comment on LUCENE-3058 at 5/3/11 8:35 AM:
-------------------------------------------------------------

Looks good to me. One note: possible NPE here (-null passes all instanceofs-):
{code}
+    @Override
+    public boolean equals(Object _other) {
+      if (_other instanceof TwoLongs) {
+        final TwoLongs other = (TwoLongs) _other;
+        return first == other.first && second == other.second;
+      } else {
+        return false;
+      }
+    }
{code}

      was (Author: dweiss):
    Looks good to me. One note: possible NPE here (null passes all instanceofs):
{code}
+    @Override
+    public boolean equals(Object _other) {
+      if (_other instanceof TwoLongs) {
+        final TwoLongs other = (TwoLongs) _other;
+        return first == other.first && second == other.second;
+      } else {
+        return false;
+      }
+    }
{code}
  
> FST should allow more than one output for the same input
> --------------------------------------------------------
>
>                 Key: LUCENE-3058
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3058
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>             Fix For: 4.0
>
>         Attachments: LUCENE-3058.patch, LUCENE-3058.patch
>
>
> For the block tree terms dict, it turns out I need this case.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Commented] (LUCENE-3058) FST should allow more than one output for the same input

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

Dawid Weiss commented on LUCENE-3058:
-------------------------------------

Handslap! And this is why you should always refresh your memory before posting something that lasts for millenia... Crawling back to my cave right now.

> FST should allow more than one output for the same input
> --------------------------------------------------------
>
>                 Key: LUCENE-3058
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3058
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>             Fix For: 4.0
>
>         Attachments: LUCENE-3058.patch, LUCENE-3058.patch
>
>
> For the block tree terms dict, it turns out I need this case.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Reopened] (LUCENE-3058) FST should allow more than one output for the same input

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

Michael McCandless reopened LUCENE-3058:
----------------------------------------


Reopening -- this commit has generics violations in TestFSTs.

> FST should allow more than one output for the same input
> --------------------------------------------------------
>
>                 Key: LUCENE-3058
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3058
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>             Fix For: 4.0
>
>         Attachments: LUCENE-3058.patch, LUCENE-3058.patch
>
>
> For the block tree terms dict, it turns out I need this case.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Commented] (LUCENE-3058) FST should allow more than one output for the same input

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

Uwe Schindler commented on LUCENE-3058:
---------------------------------------

:-) It always confuses me, too. But if you think more about it, it makes sense to return false. But it's the same always for me: Whenever I write equals() methods, this question pops up. But now I mostly copy code like the one above from other classes. But you have to note: The above equals() code is only 100% suitable for final classes, else it could happen that a subclass that extends some fields is equal. But thats more a theoretical discussion. E.g. Lucene's Queries always check this.getClass()==other.getClass().

> FST should allow more than one output for the same input
> --------------------------------------------------------
>
>                 Key: LUCENE-3058
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3058
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>             Fix For: 4.0
>
>         Attachments: LUCENE-3058.patch, LUCENE-3058.patch
>
>
> For the block tree terms dict, it turns out I need this case.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Updated] (LUCENE-3058) FST should allow more than one output for the same input

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

Michael McCandless updated LUCENE-3058:
---------------------------------------

    Attachment: LUCENE-3058.patch

I think we should just suppress the warning?  

> FST should allow more than one output for the same input
> --------------------------------------------------------
>
>                 Key: LUCENE-3058
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3058
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>             Fix For: 4.0
>
>         Attachments: LUCENE-3058.patch, LUCENE-3058.patch, LUCENE-3058.patch
>
>
> For the block tree terms dict, it turns out I need this case.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Updated] (LUCENE-3058) FST should allow more than one output for the same input

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

Michael McCandless updated LUCENE-3058:
---------------------------------------

    Attachment: LUCENE-3058.patch

Patch.

It was a small change to Builder, to accept same input multiple times in a row.  I added an optional "merge" method to Outputs, and made a new UpToTwoIntOutputs class that handles one or two ints per input.

> FST should allow more than one output for the same input
> --------------------------------------------------------
>
>                 Key: LUCENE-3058
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3058
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>             Fix For: 4.0
>
>         Attachments: LUCENE-3058.patch
>
>
> For the block tree terms dict, it turns out I need this case.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Commented] (LUCENE-3058) FST should allow more than one output for the same input

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

Uwe Schindler commented on LUCENE-3058:
---------------------------------------

After reviewing, this seems the only solution. The cast is guarded by the instanceof check, but compiler does not know this.

Only the (Object) cast in second param is not needed:

{code}
@SuppressWarnings("unchecked") final Builder<Object> b = (Builder<Object>) builder;
b.add(pair.input, _outputs.get(twoLongs.first));
b.add(pair.input, _outputs.get(twoLongs.second));
{code}

> FST should allow more than one output for the same input
> --------------------------------------------------------
>
>                 Key: LUCENE-3058
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3058
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>             Fix For: 4.0
>
>         Attachments: LUCENE-3058.patch, LUCENE-3058.patch, LUCENE-3058.patch
>
>
> For the block tree terms dict, it turns out I need this case.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Commented] (LUCENE-3058) FST should allow more than one output for the same input

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

Dawid Weiss commented on LUCENE-3058:
-------------------------------------

Looks good to me. One note: possible NPE here (null passes all instanceofs):
{code}
+    @Override
+    public boolean equals(Object _other) {
+      if (_other instanceof TwoLongs) {
+        final TwoLongs other = (TwoLongs) _other;
+        return first == other.first && second == other.second;
+      } else {
+        return false;
+      }
+    }
{code}

> FST should allow more than one output for the same input
> --------------------------------------------------------
>
>                 Key: LUCENE-3058
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3058
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>             Fix For: 4.0
>
>         Attachments: LUCENE-3058.patch, LUCENE-3058.patch
>
>
> For the block tree terms dict, it turns out I need this case.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Resolved] (LUCENE-3058) FST should allow more than one output for the same input

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

Michael McCandless resolved LUCENE-3058.
----------------------------------------

    Resolution: Fixed

> FST should allow more than one output for the same input
> --------------------------------------------------------
>
>                 Key: LUCENE-3058
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3058
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>             Fix For: 4.0
>
>         Attachments: LUCENE-3058.patch, LUCENE-3058.patch, LUCENE-3058.patch
>
>
> For the block tree terms dict, it turns out I need this case.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Commented] (LUCENE-3058) FST should allow more than one output for the same input

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

Uwe Schindler commented on LUCENE-3058:
---------------------------------------

bq. null passes all instanceofs

Definitely NOT! [http://stackoverflow.com/questions/2950319/is-null-check-needed-before-calling-instanceof]

> FST should allow more than one output for the same input
> --------------------------------------------------------
>
>                 Key: LUCENE-3058
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3058
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>             Fix For: 4.0
>
>         Attachments: LUCENE-3058.patch, LUCENE-3058.patch
>
>
> For the block tree terms dict, it turns out I need this case.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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