You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "Christopher Currens (Created) (JIRA)" <ji...@apache.org> on 2012/03/23 23:23:27 UTC

[jira] [Created] (LUCENENET-481) Port Contrib.MemoryIndex

Port Contrib.MemoryIndex
------------------------

                 Key: LUCENENET-481
                 URL: https://issues.apache.org/jira/browse/LUCENENET-481
             Project: Lucene.Net
          Issue Type: New Feature
    Affects Versions: Lucene.Net 3.0.3
            Reporter: Christopher Currens


We need to port MemoryIndex from contrib, if we want to be able to port a few other contrib libraries.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (LUCENENET-481) Port Contrib.MemoryIndex

Posted by "Christopher Currens (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENENET-481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13238661#comment-13238661 ] 

Christopher Currens commented on LUCENENET-481:
-----------------------------------------------

If you're talking about the termComparator, that wasn't made generic until 3.1.  The comparator in 3.0.3 can't be ported the way it is anyway because of Java's type system, but I just want to make sure you're porting 3.0.3 to keep everything in line with the rest of the .NET versions.  You'll find that the 3.x version in java uses a few other additions to the main lucene library that aren't yet available in 3.0.3.

This problem should be easily solved without reflection.  The comparator used basically requires that it be a {{KeyValuePair<TKey, TValue>}}, or more specifically, a {{KeyValuePair<string, TValue>}}.  There are actually only 2 different types that uses that termComparator: {{KeyValuePair<string, ArrayIntList>[]}} and {{KeyValuePair<string,Info>[]}}.  An exception to that is the {{private static sort(Dictionary<K,V>)}} method, but that can be solved with a static method, a type constraint (which is already implied in the java version) and some type inference (as a nicety).  I had ported most of this at one point (somewhere on my home computer), and if memory serves me correctly, I think this is how I solved this problem.

You can use this if you want:

{code}
class KvpComparer
{
    public static int Comparer<TKey, TValue>(KeyValuePair<TKey, TValue> x, KeyValuePair<TKey, TValue> y)
        where TKey : IComparable<TKey>
    {
        if (x.Equals(y)) return 0;
        return x.Key.CompareTo(y.Key);
    }
}

sealed class KvpComparer<T> : KvpComparer, IComparer<KeyValuePair<string, T>>
{
    public int Compare(KeyValuePair<string, T> x, KeyValuePair<string, T> y)
    {
        return Comparer(x, y);
    }
}
{code}

You can create the two instances you need for the {{<string,Info>}} and {{<string,ArrayIntList>}} types.  For the {{Map.Entry<K,V>[] sort(HashMap<K,V> map}} method, constrain {{K}} to {{IComparable<K>}}, and then you can use it like {{Array.Sort(entries, KvpComparer.Compare)}}, which is nice because it's one less object you need to create (or more) for each type passed into sort.  Alternatively, since the {{sort}} method is private, and only uses those two types, you can just change the signature and pass in one of the comparers instead, removing the base class from the equation.
                
> Port Contrib.MemoryIndex
> ------------------------
>
>                 Key: LUCENENET-481
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-481
>             Project: Lucene.Net
>          Issue Type: New Feature
>    Affects Versions: Lucene.Net 3.0.3
>            Reporter: Christopher Currens
>
> We need to port MemoryIndex from contrib, if we want to be able to port a few other contrib libraries.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (LUCENENET-481) Port Contrib.MemoryIndex

Posted by "Troy Howard (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENENET-481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13238584#comment-13238584 ] 

Troy Howard commented on LUCENENET-481:
---------------------------------------

I started in on porting this, however this one has a few challenges to replicate exact behaviour. 

It uses Java wildcard generics in a Comparator<T> implementation, of which there is no .NET equivalent. I could probably replicate behaviour using Reflection but I'm not sure how that will impact performance vs it's Java equivalent. May need to redesign a little to accomodate .NET type system.
                
> Port Contrib.MemoryIndex
> ------------------------
>
>                 Key: LUCENENET-481
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-481
>             Project: Lucene.Net
>          Issue Type: New Feature
>    Affects Versions: Lucene.Net 3.0.3
>            Reporter: Christopher Currens
>
> We need to port MemoryIndex from contrib, if we want to be able to port a few other contrib libraries.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (LUCENENET-481) Port Contrib.MemoryIndex

Posted by "Christopher Currens (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENENET-481?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christopher Currens updated LUCENENET-481:
------------------------------------------

    Fix Version/s: Lucene.Net 3.0.3
    
> Port Contrib.MemoryIndex
> ------------------------
>
>                 Key: LUCENENET-481
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-481
>             Project: Lucene.Net
>          Issue Type: New Feature
>    Affects Versions: Lucene.Net 3.0.3
>            Reporter: Christopher Currens
>             Fix For: Lucene.Net 3.0.3
>
>
> We need to port MemoryIndex from contrib, if we want to be able to port a few other contrib libraries.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (LUCENENET-481) Port Contrib.MemoryIndex

Posted by "Christopher Currens (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENENET-481?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christopher Currens resolved LUCENENET-481.
-------------------------------------------

    Resolution: Fixed

I hope you don't mind, but I had so much free time this week, I went ahead and ported this.  It's been a few days since I mentioned I might be doing this on the mailing list in the email titled "Lucene.NET 3.0.3 Release Date", so I hope you had at least seen it before this happened (no one has yet to respond to the email).

Tests and Library have been ported.  Everything looks pretty good, There were a few weird things related to term comparisons, so there are some small minor differences between the Java, but it's fairly obvious with the constraints listed.
                
> Port Contrib.MemoryIndex
> ------------------------
>
>                 Key: LUCENENET-481
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-481
>             Project: Lucene.Net
>          Issue Type: New Feature
>    Affects Versions: Lucene.Net 3.0.3
>            Reporter: Christopher Currens
>             Fix For: Lucene.Net 3.0.3
>
>
> We need to port MemoryIndex from contrib, if we want to be able to port a few other contrib libraries.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira