You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Gary Gregory <ga...@gmail.com> on 2022/09/01 17:38:58 UTC

Re: Re: Trie with non-String keys

We can make the PT class have generic keys for the next release or create a
new class with both generic keys and values.

I would prefer 1. That keeps binary compatibility but breaks source
compatibility which is ok with me.

Gary

On Wed, Aug 31, 2022, 19:16 Willi Schönborn <w....@gmail.com> wrote:

> Yes, exactly. To be precise, I'm trying to use Kotlin data classes as keys,
> which are similar to Java records. They have ordered components and I'd
> require those components to be comparable.
>
> On 2022/08/15 20:03:00 Matt Sicker wrote:
> > Is this like a sort of composite key that‘s ultimately comparable similar
> to total ordering on strings?
> >
> > —
> > Matt Sicker
> >
> > > On Aug 15, 2022, at 08:36, Gary Gregory <ga...@gmail.com> wrote:
> > >
> > > Since a trie is traditionally used with strings, this is not
> surprising to
> > > me. What kind of key are you wanting to use?
> > >
> > > Gary
> > >
> > >> On Wed, Aug 3, 2022, 08:16 Willi Schönborn <w....@gmail.com> wrote:
> > >>
> > >> I was trying to see whether I could use AbstractPatriciaTrie to create
> a
> > >> trie for non-String keys.
> > >> Especially the existence of the KeyAnalyzer type suggested that I
> could do
> > >> this.
> > >> But the AbstractPatriciaTrie is package-private and not exposed.
> > >> Was that a conscious decision?
> > >>
> >
>

Re: Re: Trie with non-String keys

Posted by Gary Gregory <ga...@gmail.com>.
AbstractPatriciaTrie.

Gary

On Thu, Sep 1, 2022, 17:21 Willi Schönborn <w....@gmail.com> wrote:

> Wait, which abstract class were you referring to?
>
> On Thu, 1 Sep 2022, 23:20 Willi Schönborn, <w....@gmail.com> wrote:
>
> > I'd still need a way to instantiate a concrete trie given my own key
> > analyzer. I haven't found a way to do that right now.
> >
> > On Thu, 1 Sep 2022, 22:42 Gary Gregory, <ga...@gmail.com> wrote:
> >
> >> Hm, maybe the simplest thing to do is to make the abstract class public
> >> and
> >> let you implement a KeyAnalyzer subclass. Any thoughts on that?
> >>
> >> Gary
> >>
> >> On Thu, Sep 1, 2022, 13:40 Gary Gregory <ga...@gmail.com> wrote:
> >>
> >> > FWIW, typing as String is a bit restrictive, CharSequence would have
> >> been
> >> > more reasonable IMO. But we can change that for 4.5.0.
> >> >
> >> > Gary
> >> >
> >> > On Thu, Sep 1, 2022, 13:38 Gary Gregory <ga...@gmail.com>
> wrote:
> >> >
> >> >> We can make the PT class have generic keys for the next release or
> >> create
> >> >> a new class with both generic keys and values.
> >> >>
> >> >> I would prefer 1. That keeps binary compatibility but breaks source
> >> >> compatibility which is ok with me.
> >> >>
> >> >> Gary
> >> >>
> >> >> On Wed, Aug 31, 2022, 19:16 Willi Schönborn <w....@gmail.com>
> >> >> wrote:
> >> >>
> >> >>> Yes, exactly. To be precise, I'm trying to use Kotlin data classes
> as
> >> >>> keys,
> >> >>> which are similar to Java records. They have ordered components and
> >> I'd
> >> >>> require those components to be comparable.
> >> >>>
> >> >>> On 2022/08/15 20:03:00 Matt Sicker wrote:
> >> >>> > Is this like a sort of composite key that‘s ultimately comparable
> >> >>> similar
> >> >>> to total ordering on strings?
> >> >>> >
> >> >>> > —
> >> >>> > Matt Sicker
> >> >>> >
> >> >>> > > On Aug 15, 2022, at 08:36, Gary Gregory <ga...@gmail.com>
> wrote:
> >> >>> > >
> >> >>> > > Since a trie is traditionally used with strings, this is not
> >> >>> surprising to
> >> >>> > > me. What kind of key are you wanting to use?
> >> >>> > >
> >> >>> > > Gary
> >> >>> > >
> >> >>> > >> On Wed, Aug 3, 2022, 08:16 Willi Schönborn <w....@gmail.com>
> >> wrote:
> >> >>> > >>
> >> >>> > >> I was trying to see whether I could use AbstractPatriciaTrie to
> >> >>> create
> >> >>> a
> >> >>> > >> trie for non-String keys.
> >> >>> > >> Especially the existence of the KeyAnalyzer type suggested
> that I
> >> >>> could do
> >> >>> > >> this.
> >> >>> > >> But the AbstractPatriciaTrie is package-private and not
> exposed.
> >> >>> > >> Was that a conscious decision?
> >> >>> > >>
> >> >>> >
> >> >>>
> >> >>
> >>
> >
>

Re: Re: Trie with non-String keys

Posted by Willi Schönborn <w....@gmail.com>.
Wait, which abstract class were you referring to?

On Thu, 1 Sep 2022, 23:20 Willi Schönborn, <w....@gmail.com> wrote:

> I'd still need a way to instantiate a concrete trie given my own key
> analyzer. I haven't found a way to do that right now.
>
> On Thu, 1 Sep 2022, 22:42 Gary Gregory, <ga...@gmail.com> wrote:
>
>> Hm, maybe the simplest thing to do is to make the abstract class public
>> and
>> let you implement a KeyAnalyzer subclass. Any thoughts on that?
>>
>> Gary
>>
>> On Thu, Sep 1, 2022, 13:40 Gary Gregory <ga...@gmail.com> wrote:
>>
>> > FWIW, typing as String is a bit restrictive, CharSequence would have
>> been
>> > more reasonable IMO. But we can change that for 4.5.0.
>> >
>> > Gary
>> >
>> > On Thu, Sep 1, 2022, 13:38 Gary Gregory <ga...@gmail.com> wrote:
>> >
>> >> We can make the PT class have generic keys for the next release or
>> create
>> >> a new class with both generic keys and values.
>> >>
>> >> I would prefer 1. That keeps binary compatibility but breaks source
>> >> compatibility which is ok with me.
>> >>
>> >> Gary
>> >>
>> >> On Wed, Aug 31, 2022, 19:16 Willi Schönborn <w....@gmail.com>
>> >> wrote:
>> >>
>> >>> Yes, exactly. To be precise, I'm trying to use Kotlin data classes as
>> >>> keys,
>> >>> which are similar to Java records. They have ordered components and
>> I'd
>> >>> require those components to be comparable.
>> >>>
>> >>> On 2022/08/15 20:03:00 Matt Sicker wrote:
>> >>> > Is this like a sort of composite key that‘s ultimately comparable
>> >>> similar
>> >>> to total ordering on strings?
>> >>> >
>> >>> > —
>> >>> > Matt Sicker
>> >>> >
>> >>> > > On Aug 15, 2022, at 08:36, Gary Gregory <ga...@gmail.com> wrote:
>> >>> > >
>> >>> > > Since a trie is traditionally used with strings, this is not
>> >>> surprising to
>> >>> > > me. What kind of key are you wanting to use?
>> >>> > >
>> >>> > > Gary
>> >>> > >
>> >>> > >> On Wed, Aug 3, 2022, 08:16 Willi Schönborn <w....@gmail.com>
>> wrote:
>> >>> > >>
>> >>> > >> I was trying to see whether I could use AbstractPatriciaTrie to
>> >>> create
>> >>> a
>> >>> > >> trie for non-String keys.
>> >>> > >> Especially the existence of the KeyAnalyzer type suggested that I
>> >>> could do
>> >>> > >> this.
>> >>> > >> But the AbstractPatriciaTrie is package-private and not exposed.
>> >>> > >> Was that a conscious decision?
>> >>> > >>
>> >>> >
>> >>>
>> >>
>>
>

Re: Re: Trie with non-String keys

Posted by Willi Schönborn <w....@gmail.com>.
I'd still need a way to instantiate a concrete trie given my own key
analyzer. I haven't found a way to do that right now.

On Thu, 1 Sep 2022, 22:42 Gary Gregory, <ga...@gmail.com> wrote:

> Hm, maybe the simplest thing to do is to make the abstract class public and
> let you implement a KeyAnalyzer subclass. Any thoughts on that?
>
> Gary
>
> On Thu, Sep 1, 2022, 13:40 Gary Gregory <ga...@gmail.com> wrote:
>
> > FWIW, typing as String is a bit restrictive, CharSequence would have been
> > more reasonable IMO. But we can change that for 4.5.0.
> >
> > Gary
> >
> > On Thu, Sep 1, 2022, 13:38 Gary Gregory <ga...@gmail.com> wrote:
> >
> >> We can make the PT class have generic keys for the next release or
> create
> >> a new class with both generic keys and values.
> >>
> >> I would prefer 1. That keeps binary compatibility but breaks source
> >> compatibility which is ok with me.
> >>
> >> Gary
> >>
> >> On Wed, Aug 31, 2022, 19:16 Willi Schönborn <w....@gmail.com>
> >> wrote:
> >>
> >>> Yes, exactly. To be precise, I'm trying to use Kotlin data classes as
> >>> keys,
> >>> which are similar to Java records. They have ordered components and I'd
> >>> require those components to be comparable.
> >>>
> >>> On 2022/08/15 20:03:00 Matt Sicker wrote:
> >>> > Is this like a sort of composite key that‘s ultimately comparable
> >>> similar
> >>> to total ordering on strings?
> >>> >
> >>> > —
> >>> > Matt Sicker
> >>> >
> >>> > > On Aug 15, 2022, at 08:36, Gary Gregory <ga...@gmail.com> wrote:
> >>> > >
> >>> > > Since a trie is traditionally used with strings, this is not
> >>> surprising to
> >>> > > me. What kind of key are you wanting to use?
> >>> > >
> >>> > > Gary
> >>> > >
> >>> > >> On Wed, Aug 3, 2022, 08:16 Willi Schönborn <w....@gmail.com>
> wrote:
> >>> > >>
> >>> > >> I was trying to see whether I could use AbstractPatriciaTrie to
> >>> create
> >>> a
> >>> > >> trie for non-String keys.
> >>> > >> Especially the existence of the KeyAnalyzer type suggested that I
> >>> could do
> >>> > >> this.
> >>> > >> But the AbstractPatriciaTrie is package-private and not exposed.
> >>> > >> Was that a conscious decision?
> >>> > >>
> >>> >
> >>>
> >>
>

Re: Re: Trie with non-String keys

Posted by Gary Gregory <ga...@gmail.com>.
Hm, maybe the simplest thing to do is to make the abstract class public and
let you implement a KeyAnalyzer subclass. Any thoughts on that?

Gary

On Thu, Sep 1, 2022, 13:40 Gary Gregory <ga...@gmail.com> wrote:

> FWIW, typing as String is a bit restrictive, CharSequence would have been
> more reasonable IMO. But we can change that for 4.5.0.
>
> Gary
>
> On Thu, Sep 1, 2022, 13:38 Gary Gregory <ga...@gmail.com> wrote:
>
>> We can make the PT class have generic keys for the next release or create
>> a new class with both generic keys and values.
>>
>> I would prefer 1. That keeps binary compatibility but breaks source
>> compatibility which is ok with me.
>>
>> Gary
>>
>> On Wed, Aug 31, 2022, 19:16 Willi Schönborn <w....@gmail.com>
>> wrote:
>>
>>> Yes, exactly. To be precise, I'm trying to use Kotlin data classes as
>>> keys,
>>> which are similar to Java records. They have ordered components and I'd
>>> require those components to be comparable.
>>>
>>> On 2022/08/15 20:03:00 Matt Sicker wrote:
>>> > Is this like a sort of composite key that‘s ultimately comparable
>>> similar
>>> to total ordering on strings?
>>> >
>>> > —
>>> > Matt Sicker
>>> >
>>> > > On Aug 15, 2022, at 08:36, Gary Gregory <ga...@gmail.com> wrote:
>>> > >
>>> > > Since a trie is traditionally used with strings, this is not
>>> surprising to
>>> > > me. What kind of key are you wanting to use?
>>> > >
>>> > > Gary
>>> > >
>>> > >> On Wed, Aug 3, 2022, 08:16 Willi Schönborn <w....@gmail.com> wrote:
>>> > >>
>>> > >> I was trying to see whether I could use AbstractPatriciaTrie to
>>> create
>>> a
>>> > >> trie for non-String keys.
>>> > >> Especially the existence of the KeyAnalyzer type suggested that I
>>> could do
>>> > >> this.
>>> > >> But the AbstractPatriciaTrie is package-private and not exposed.
>>> > >> Was that a conscious decision?
>>> > >>
>>> >
>>>
>>

Re: Re: Trie with non-String keys

Posted by Gary Gregory <ga...@gmail.com>.
FWIW, typing as String is a bit restrictive, CharSequence would have been
more reasonable IMO. But we can change that for 4.5.0.

Gary

On Thu, Sep 1, 2022, 13:38 Gary Gregory <ga...@gmail.com> wrote:

> We can make the PT class have generic keys for the next release or create
> a new class with both generic keys and values.
>
> I would prefer 1. That keeps binary compatibility but breaks source
> compatibility which is ok with me.
>
> Gary
>
> On Wed, Aug 31, 2022, 19:16 Willi Schönborn <w....@gmail.com>
> wrote:
>
>> Yes, exactly. To be precise, I'm trying to use Kotlin data classes as
>> keys,
>> which are similar to Java records. They have ordered components and I'd
>> require those components to be comparable.
>>
>> On 2022/08/15 20:03:00 Matt Sicker wrote:
>> > Is this like a sort of composite key that‘s ultimately comparable
>> similar
>> to total ordering on strings?
>> >
>> > —
>> > Matt Sicker
>> >
>> > > On Aug 15, 2022, at 08:36, Gary Gregory <ga...@gmail.com> wrote:
>> > >
>> > > Since a trie is traditionally used with strings, this is not
>> surprising to
>> > > me. What kind of key are you wanting to use?
>> > >
>> > > Gary
>> > >
>> > >> On Wed, Aug 3, 2022, 08:16 Willi Schönborn <w....@gmail.com> wrote:
>> > >>
>> > >> I was trying to see whether I could use AbstractPatriciaTrie to
>> create
>> a
>> > >> trie for non-String keys.
>> > >> Especially the existence of the KeyAnalyzer type suggested that I
>> could do
>> > >> this.
>> > >> But the AbstractPatriciaTrie is package-private and not exposed.
>> > >> Was that a conscious decision?
>> > >>
>> >
>>
>