xml-xindice-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Greif" <jgr...@alumni.princeton.edu>
Subject Re: last-of-type() or max() function?
Date Wed, 13 Aug 2003 14:44:54 GMT
If you need the "last" id in order to create new unique ids, you can add a
Collection to your db which holds a single document, that document holding
an id counter.  When your application starts up, it asks for a reasonable
number of ids, N, by getting this document's current counter value and
incrementing it by N.  Then it uses the N ids as it creates new documents.
If it needs more than N, it makes a request for another bunch of id numbers.
In this way, as long as you can synchronize access to the counter document
(and do the retrieve and update in a single synchronized access),
distributed threads or processes can issue non-conflicting ids to new
documents.   This is also the high-performance way to do it in relational
databases.  (Oracle has a SEQUENCE object for the purpose, for instance).

If you have several different collections that need ids, you can put several
counter documents in your counter Collection, one for each set of ids, and
manipulate them separately.

Jeff

----- Original Message ----- 
From: "Vince Marco" <vmarco@mac.com>
To: <xindice-users@xml.apache.org>
Sent: Wednesday, August 13, 2003 5:55 AM
Subject: Re: last-of-type() or max() function?


> Yes.  I am aware of that.  Still, I need this functionality, and I
> haven't gotten the right XPath statement to do what I need in Xindice.
> My IDs are numbers appended to a letter to fit the XML name criteria.
>
> Any help?
>
> Vince
>
> > Vince Marco wrote:
> >> I'm new to XMLDB and need to retrieve the highest value in an ID
> >> field for a document type.  What is the best method of finding this
> >> using Xindice?  This would be akin to using a max() function in an
> >> RDBMS.
> >
> > You are aware that IDs in Xindice are by definition XML Names [1],
> > i.e.,
> > they are strings, not numbers? So that you're asking for the highest
> > value of a sorted list of Java Strings?
>
>


Mime
View raw message