getting the first and last element of an index

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

getting the first and last element of an index

Johan Brichau-3
Hi,

I'm currently looking to solve something:
What is the most efficient way to get the first and the last element of a collection when there is an equality index defined on that collection?

Obviously I should be able to retrieve the object without traversing the entire collection.
Using a regular sorted collection is not an option since it is too large, so I need it the have the order defined via an index.

thanks for any hints
Johan
Reply | Threaded
Open this post in threaded view
|

Re: getting the first and last element of an index

Johan Brichau-3
Hi again,

Here is what I have found so far:

((elementsCollection _indexedPaths select:[:e | e isKindOf: RangeEqualityIndex])
        detect:[:e | e pathComponentsString = 'end']) btreeRoot lastValue

This seems to give me the last value on the index defined over the 'end' variable.

Johan

On 25 Jun 2013, at 19:51, Johan Brichau <[hidden email]> wrote:

> Hi,
>
> I'm currently looking to solve something:
> What is the most efficient way to get the first and the last element of a collection when there is an equality index defined on that collection?
>
> Obviously I should be able to retrieve the object without traversing the entire collection.
> Using a regular sorted collection is not an option since it is too large, so I need it the have the order defined via an index.
>
> thanks for any hints
> Johan

Reply | Threaded
Open this post in threaded view
|

Re: getting the first and last element of an index

Dale Henrichs-3
Johan,

Yeah, we haven't exposed access to the first/last values of an indexed collection, but you are heading in the right direction ...

Now that I'm finished monkeying with gemsource and ss3, I'll take a look and whip something up to be included in the GemStone-Indexing-Extensions package ... maybe something like:

  nsc detectFirstOn: 'path'.
  nsc detectLastOn: 'path'.

Dale

----- Original Message -----
| From: "Johan Brichau" <[hidden email]>
| To: "GemStone Seaside beta discussion" <[hidden email]>
| Sent: Wednesday, June 26, 2013 1:14:14 AM
| Subject: Re: [GS/SS Beta] getting the first and last element of an index
|
| Hi again,
|
| Here is what I have found so far:
|
| ((elementsCollection _indexedPaths select:[:e | e isKindOf:
| RangeEqualityIndex])
| detect:[:e | e pathComponentsString = 'end']) btreeRoot lastValue
|
| This seems to give me the last value on the index defined over the
| 'end' variable.
|
| Johan
|
| On 25 Jun 2013, at 19:51, Johan Brichau <[hidden email]> wrote:
|
| > Hi,
| >
| > I'm currently looking to solve something:
| > What is the most efficient way to get the first and the last
| > element of a collection when there is an equality index defined on
| > that collection?
| >
| > Obviously I should be able to retrieve the object without
| > traversing the entire collection.
| > Using a regular sorted collection is not an option since it is too
| > large, so I need it the have the order defined via an index.
| >
| > thanks for any hints
| > Johan
|
|
Reply | Threaded
Open this post in threaded view
|

Re: getting the first and last element of an index

Johan Brichau-3
Hi Dale,

Seems like I am indeed doing something wrong because the #lastValue message is giving me an error:

InterpreterError 2003: An indexable object or NSC <aBtreeBasicLeafNode> was referenced with an index <-3> that was out of range.

On 26 Jun 2013, at 11:35, Dale K. Henrichs <[hidden email]> wrote:

> Johan,
>
> Yeah, we haven't exposed access to the first/last values of an indexed collection, but you are heading in the right direction ...
>
> Now that I'm finished monkeying with gemsource and ss3, I'll take a look and whip something up to be included in the GemStone-Indexing-Extensions package ... maybe something like:
>
>  nsc detectFirstOn: 'path'.
>  nsc detectLastOn: 'path'.
>
> Dale
>
> ----- Original Message -----
> | From: "Johan Brichau" <[hidden email]>
> | To: "GemStone Seaside beta discussion" <[hidden email]>
> | Sent: Wednesday, June 26, 2013 1:14:14 AM
> | Subject: Re: [GS/SS Beta] getting the first and last element of an index
> |
> | Hi again,
> |
> | Here is what I have found so far:
> |
> | ((elementsCollection _indexedPaths select:[:e | e isKindOf:
> | RangeEqualityIndex])
> | detect:[:e | e pathComponentsString = 'end']) btreeRoot lastValue
> |
> | This seems to give me the last value on the index defined over the
> | 'end' variable.
> |
> | Johan
> |
> | On 25 Jun 2013, at 19:51, Johan Brichau <[hidden email]> wrote:
> |
> | > Hi,
> | >
> | > I'm currently looking to solve something:
> | > What is the most efficient way to get the first and the last
> | > element of a collection when there is an equality index defined on
> | > that collection?
> | >
> | > Obviously I should be able to retrieve the object without
> | > traversing the entire collection.
> | > Using a regular sorted collection is not an option since it is too
> | > large, so I need it the have the order defined via an index.
> | >
> | > thanks for any hints
> | > Johan
> |
> |

Reply | Threaded
Open this post in threaded view
|

Re: getting the first and last element of an index

Johan Brichau-3
Hm, never mind... this seems to be the case only when the collection itself is empty.

So far, it seems my code snippet is doing the job. But I need to verify a bit more.

On 28 Jun 2013, at 11:17, Johan Brichau <[hidden email]> wrote:

> Hi Dale,
>
> Seems like I am indeed doing something wrong because the #lastValue message is giving me an error:
>
> InterpreterError 2003: An indexable object or NSC <aBtreeBasicLeafNode> was referenced with an index <-3> that was out of range.
>
> On 26 Jun 2013, at 11:35, Dale K. Henrichs <[hidden email]> wrote:
>
>> Johan,
>>
>> Yeah, we haven't exposed access to the first/last values of an indexed collection, but you are heading in the right direction ...
>>
>> Now that I'm finished monkeying with gemsource and ss3, I'll take a look and whip something up to be included in the GemStone-Indexing-Extensions package ... maybe something like:
>>
>> nsc detectFirstOn: 'path'.
>> nsc detectLastOn: 'path'.
>>
>> Dale
>>
>> ----- Original Message -----
>> | From: "Johan Brichau" <[hidden email]>
>> | To: "GemStone Seaside beta discussion" <[hidden email]>
>> | Sent: Wednesday, June 26, 2013 1:14:14 AM
>> | Subject: Re: [GS/SS Beta] getting the first and last element of an index
>> |
>> | Hi again,
>> |
>> | Here is what I have found so far:
>> |
>> | ((elementsCollection _indexedPaths select:[:e | e isKindOf:
>> | RangeEqualityIndex])
>> | detect:[:e | e pathComponentsString = 'end']) btreeRoot lastValue
>> |
>> | This seems to give me the last value on the index defined over the
>> | 'end' variable.
>> |
>> | Johan
>> |
>> | On 25 Jun 2013, at 19:51, Johan Brichau <[hidden email]> wrote:
>> |
>> | > Hi,
>> | >
>> | > I'm currently looking to solve something:
>> | > What is the most efficient way to get the first and the last
>> | > element of a collection when there is an equality index defined on
>> | > that collection?
>> | >
>> | > Obviously I should be able to retrieve the object without
>> | > traversing the entire collection.
>> | > Using a regular sorted collection is not an option since it is too
>> | > large, so I need it the have the order defined via an index.
>> | >
>> | > thanks for any hints
>> | > Johan
>> |
>> |
>

Reply | Threaded
Open this post in threaded view
|

Re: getting the first and last element of an index

Dale Henrichs-3
Johan,

When I looked at the implementers of lastValue, I was suspicious that there might be boundary condition issues:) Also for a general solution the #firstOnPath: and #lastOnPath: (Richard Sargent suggested the names and i think they are names) methods need to work whether or not one has defined an index ...

Dale
----- Original Message -----
| From: "Johan Brichau" <[hidden email]>
| To: "GemStone Seaside beta discussion" <[hidden email]>
| Sent: Friday, June 28, 2013 2:21:26 AM
| Subject: Re: [GS/SS Beta] getting the first and last element of an index
|
| Hm, never mind... this seems to be the case only when the collection
| itself is empty.
|
| So far, it seems my code snippet is doing the job. But I need to
| verify a bit more.
|
| On 28 Jun 2013, at 11:17, Johan Brichau <[hidden email]> wrote:
|
| > Hi Dale,
| >
| > Seems like I am indeed doing something wrong because the #lastValue
| > message is giving me an error:
| >
| > InterpreterError 2003: An indexable object or NSC
| > <aBtreeBasicLeafNode> was referenced with an index <-3> that was
| > out of range.
| >
| > On 26 Jun 2013, at 11:35, Dale K. Henrichs
| > <[hidden email]> wrote:
| >
| >> Johan,
| >>
| >> Yeah, we haven't exposed access to the first/last values of an
| >> indexed collection, but you are heading in the right direction
| >> ...
| >>
| >> Now that I'm finished monkeying with gemsource and ss3, I'll take
| >> a look and whip something up to be included in the
| >> GemStone-Indexing-Extensions package ... maybe something like:
| >>
| >> nsc detectFirstOn: 'path'.
| >> nsc detectLastOn: 'path'.
| >>
| >> Dale
| >>
| >> ----- Original Message -----
| >> | From: "Johan Brichau" <[hidden email]>
| >> | To: "GemStone Seaside beta discussion"
| >> | <[hidden email]>
| >> | Sent: Wednesday, June 26, 2013 1:14:14 AM
| >> | Subject: Re: [GS/SS Beta] getting the first and last element of
| >> | an index
| >> |
| >> | Hi again,
| >> |
| >> | Here is what I have found so far:
| >> |
| >> | ((elementsCollection _indexedPaths select:[:e | e isKindOf:
| >> | RangeEqualityIndex])
| >> | detect:[:e | e pathComponentsString = 'end']) btreeRoot
| >> | lastValue
| >> |
| >> | This seems to give me the last value on the index defined over
| >> | the
| >> | 'end' variable.
| >> |
| >> | Johan
| >> |
| >> | On 25 Jun 2013, at 19:51, Johan Brichau <[hidden email]>
| >> | wrote:
| >> |
| >> | > Hi,
| >> | >
| >> | > I'm currently looking to solve something:
| >> | > What is the most efficient way to get the first and the last
| >> | > element of a collection when there is an equality index
| >> | > defined on
| >> | > that collection?
| >> | >
| >> | > Obviously I should be able to retrieve the object without
| >> | > traversing the entire collection.
| >> | > Using a regular sorted collection is not an option since it is
| >> | > too
| >> | > large, so I need it the have the order defined via an index.
| >> | >
| >> | > thanks for any hints
| >> | > Johan
| >> |
| >> |
| >
|
|