Counter module

View: New views
15 Messages — Rating Filter:   Alert me  

Counter module

by Joe Wicentowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I just tested the counter module (using rev 10276) and found it quite
interesting.  It's a persistent counter - whose value persists across
queries, something otherwise impossible in the anti-side-effect world
of XQuery.  I have a couple of questions/observations:

1. The function documentation defines the counter:create() parameter,
$counter-name as "The node or a string path pointing to a resource in
the database" and gives it a type of item().

a. "The node" is a bit vague - would "The name of the node" or perhaps
even "The name of the counter" be more precise and descriptive?  I was
able to create a counter using counter:create('joe').

b. I wasn't sure how to interpret "a string path pointing to a
resource in the database".  Does this mean that
counter:create('/db/test.xml') should have some effect on that
resource in the database?

2. Should the type for all of the counter functions' $counter-name
parameters be xs:string instead of item()?  Is there a case where
$counter-name would be anything other than a string?

3. I find that counter:next-value() returns '-1' if the supplied
$counter-name hasn't yet been created.  Perhaps the function
documentation's "return" information could be updated to say, "Returns
-1 if the supplied $counter-name hasn't yet been created with
counter:create()".

4. counter:next-value() contains a typo: "its' " should be "its", sans
apostrophe.

Thanks,
Joe


p.s. Given the reports about build problems, I tried doing a 'build
clean', svn update, and 'build' on rev 10276, and there were no
problems.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Counter module

by Joe Wicentowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Let me add a minor stylistic suggestion:

5. Might "counter" be a better name for the module than "counters"?
It seems most modules are named in the singular.  The only exception,
it appears, is "backups".

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Counter module

by Dannes Wessels-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Wed, Oct 28, 2009 at 1:02 PM, Joe Wicentowski <joewiz@...> wrote:
Let me add a minor stylistic suggestion:

5. Might "counter" be a better name for the module than "counters"?
It seems most modules are named in the singular.  The only exception,
it appears, is "backups".


Thank you for your input! I The code was contributed just recently, I moved the code to modules just yesterday. I think your suggestions make sense, I'll have a look when I have time.

Internally, things might be redesigned a bit. I guess that using NIO would things (1) faster and (2) more robust. I have little just little experience however with setting this stuff up, so I need some help/pointers for this....

regards

Dannes

--
eXist-db Native XML Database - http://exist-db.org
Join us on linked-in: http://www.linkedin.com/groups?gid=35624

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Counter module

by Loren Cahlander :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think that the name should remain singular.  Generally a name of an object should represent an instance of the object and not a collection of the object.

On Oct 28, 2009, at 09:09 AM, Dannes Wessels wrote:

Hi,

On Wed, Oct 28, 2009 at 1:02 PM, Joe Wicentowski <joewiz@...> wrote:
Let me add a minor stylistic suggestion:

5. Might "counter" be a better name for the module than "counters"?
It seems most modules are named in the singular.  The only exception,
it appears, is "backups".


Thank you for your input! I The code was contributed just recently, I moved the code to modules just yesterday. I think your suggestions make sense, I'll have a look when I have time.

Internally, things might be redesigned a bit. I guess that using NIO would things (1) faster and (2) more robust. I have little just little experience however with setting this stuff up, so I need some help/pointers for this....

regards

Dannes

--
eXist-db Native XML Database - http://exist-db.org
Join us on linked-in: http://www.linkedin.com/groups?gid=35624
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Counter module

by Dannes Wessels-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Joe,

On 28 Oct 2009, at 12:50 , Joe Wicentowski wrote:

1. The function documentation defines the counter:create() parameter,
$counter-name as "The node or a string path pointing to a resource in
the database" and gives it a type of item().

a. "The node" is a bit vague - would "The name of the node" or perhaps
even "The name of the counter" be more precise and descriptive?  I was
able to create a counter using counter:create('joe').

b. I wasn't sure how to interpret "a string path pointing to a
resource in the database".  Does this mean that
counter:create('/db/test.xml') should have some effect on that
resource in the database?

Internally all was handled as string, but having item() here makes the functions most easy to use.....

2. Should the type for all of the counter functions' $counter-name
parameters be xs:string instead of item()?  Is there a case where
$counter-name would be anything other than a string?

no just convenience.

3. I find that counter:next-value() returns '-1' if the supplied
$counter-name hasn't yet been created.  Perhaps the function
documentation's "return" information could be updated to say, "Returns
-1 if the supplied $counter-name hasn't yet been created with
counter:create()".

ok

4. counter:next-value() contains a typo: "its' " should be "its", sans
apostrophe.

right :-)

Okay I 'll refactor the name and the package location as well. Thnx for your input and ideas!

Kind regards

Dannes

--
eXist-db Native XML Database - http://exist-db.org









------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Counter module

by Dannes Wessels-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

okay,

I updated the code.

D.

On 28 Oct 2009, at 15:09 , Dannes Wessels wrote:

Hi,

On Wed, Oct 28, 2009 at 1:02 PM, Joe Wicentowski <joewiz@...> wrote:
Let me add a minor stylistic suggestion:

5. Might "counter" be a better name for the module than "counters"?
It seems most modules are named in the singular.  The only exception,
it appears, is "backups".


Thank you for your input! I The code was contributed just recently, I moved the code to modules just yesterday. I think your suggestions make sense, I'll have a look when I have time.

Internally, things might be redesigned a bit. I guess that using NIO would things (1) faster and (2) more robust. I have little just little experience however with setting this stuff up, so I need some help/pointers for this....

regards

Dannes

--
eXist-db Native XML Database - http://exist-db.org
Join us on linked-in: http://www.linkedin.com/groups?gid=35624

Kind regards

Dannes

--
eXist-db Native XML Database - http://exist-db.org









------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Counter module

by thomas.0007 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Dannes,
 
The build from the trunk fails with two errors:
 
    [javac] D:\work 2009\eXist-1.3dev\test\src\org\exist\xquery\functions\util\CounterTest.java:9: package org.exist.xquery.modules.counters does not exist
    [javac] import org.exist.xquery.modules.counters.CountersModule;
    [javac]                                         ^
    [javac] D:\work 2009\eXist-1.3dev\test\src\org\exist\xquery\functions\util\CounterTest.java:25: cannot find symbol
    [javac] symbol  : variable CountersModule
    [javac] location: class org.exist.xquery.functions.util.CounterTest
    [javac]     private final static String IMPORT = "import module namespace counter=\"" + CountersModule.NAMESPACE_URI + "\" " +
    [javac]
            ^
 
Thomas

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Counter module

by Dannes Wessels-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The code is now in org.exist.xquery.modules.counter.CounterModule ...

On 28 Oct 2009, at 22:47 , Thomas White wrote:

   [javac] D:\work 2009\eXist-1.3dev\test\src\org\exist\xquery\functions\util\CounterTest.java:9: package org.exist.xquery.modules.counters does not exist
    [javac] import org.exist.xquery.modules.counters.CountersModule;
    [javac]                                         ^
    [javac] D:\work 2009\eXist-1.3dev\test\src\org\exist\xquery\functions\util\CounterTest.java:25: cannot find symbol
    [javac] symbol  : variable CountersModule
    [javac] location: class org.exist.xquery.functions.util.CounterTest
    [javac]     private final static String IMPORT = "import module namespace counter=\"" + CountersModule.NAMESPACE_URI + "\" " +
    [javac]

Kind regards

Dannes

--
eXist-db Native XML Database - http://exist-db.org









------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Counter module

by Joe Wicentowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dannes,

On Wed, Oct 28, 2009 at 3:46 PM, Dannes Wessels <dizzzz@...> wrote:
> Okay I 'll refactor the name and the package location as well. Thnx for your
> input and ideas!

Wow, that was quick!  Thank you!  I'm glad the feedback was helpful.
I just updated to rev. 10280 and confirmed that the build worked and
the function name and documentation are all perfect to my eye.

I did notice that counter:create() on an existing counter returns the
existing value, rather than resetting the counter.  For example, in
the sandbox:

1. counter:create('joe') => 0
2. counter:next-value('joe') => 1
3. counter:create('joe') => 1
4. counter:create('joe', xs:long('123')) => 1

I don't know why, but I intuitively expected that 3 and 4 would result
in 0 and 123, respectively, i.e that create() would destroy and reset
the value.  Of course, nothing in the documentation gave me that
impression.  In any case, I wonder if it would be worth making this
behavior (what happens when you counter:create() a pre-existing
counter) explicit?  Something like, "If the counter already exists, it
will retain its value, and it won't be reset."

>> 2. Should the type for all of the counter functions' $counter-name
>> parameters be xs:string instead of item()?  Is there a case where
>> $counter-name would be anything other than a string?
>
> no just convenience.

Cool, so now I can create all sorts of fun counters!

1. counter:create( <hiDannes/> )
2. counter:create( attribute bye {'Dannes'} )
3. counter:create( <?hi dannes="1.0" ?> )
4. counter:create( <!-- ok, enough silly jokes! thanks, Dannes! :) --> )

Joe

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Counter module

by Wolfgang Meier-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> I don't know why, but I intuitively expected that 3 and 4 would result
> in 0 and 123, respectively, i.e that create() would destroy and reset
> the value.

I agree. Sometimes you need a way to reset a counter to a given value.

> 4. counter:create( <!-- ok, enough silly jokes! thanks, Dannes! :) --> )

Before we forget it, I would also like to thank Jasper for contributing
the original code of this module.

Wolfgang

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Counter module

by Dannes Wessels-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Thu, Oct 29, 2009 at 9:03 AM, Wolfgang <wolfgang@...> wrote:
> I don't know why, but I intuitively expected that 3 and 4 would result
> in 0 and 123, respectively, i.e that create() would destroy and reset
> the value.

I agree. Sometimes you need a way to reset a counter to a given value.


we could add counter:reset($counter-name) for this?
and.... there is no other way for getting the current value of a counter than... calling create() on an existing counter.

 
> 4. counter:create( "I prefer normal strings here" )

Before we forget it, I would also like to thank Jasper for contributing
the original code of this module.


Yes, I did only perform some integration steps here..... Jasper contributed the code......

regards

Dannes

--
eXist-db Native XML Database - http://exist-db.org
Join us on linked-in: http://www.linkedin.com/groups?gid=35624

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Counter module

by Jasper.Linthorst :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

RE: [Exist-open] Counter module

Hi All,
Great to see that the counter module has landed... ;)

I agree with most of the previous comments, but I think that its a good thing that there is no (easy) way to retrieve the current value of a counter (most like sequences in PostGres). Since counters will probably be used as keys, we want to make sure these are generated in a serialized context, and don't want people to have xqueries in which they create a counter and later on use a current() function to retrieve the latest value of a counter, which in a multi-threaded environment could easily return a different value... It all comes down to common sense in the end, but for me that was the main reason not to implement a current function.

Jasper

-----Oorspronkelijk bericht-----
Van: Dannes Wessels [dizzzz@...]
Verzonden: do 29-10-2009 9:24
Aan: Wolfgang
CC: jasper.linthorst@...; exist-open@...
Onderwerp: Re: [Exist-open] Counter module

Hi,

On Thu, Oct 29, 2009 at 9:03 AM, Wolfgang <wolfgang@...> wrote:

> > I don't know why, but I intuitively expected that 3 and 4 would result
> > in 0 and 123, respectively, i.e that create() would destroy and reset
> > the value.
>
> I agree. Sometimes you need a way to reset a counter to a given value.
>


we could add counter:reset($counter-name) for this?
and.... there is no other way for getting the current value of a counter
than... calling create() on an existing counter.



>  > 4. counter:create( "I prefer normal strings here" )
>
> Before we forget it, I would also like to thank Jasper for contributing
> the original code of this module.
>


Yes, I did only perform some integration steps here..... Jasper contributed
the code......

regards

Dannes

--
eXist-db Native XML Database - http://exist-db.org
Join us on linked-in: http://www.linkedin.com/groups?gid=35624


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Counter module

by Evgeny Gazdovsky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What do you think about combining counters and cache for global variables?

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Counter module

by Dannes Wessels-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hho

On Thu, Oct 29, 2009 at 11:23 AM, Evgeny Gazdovsky <gazdovsky@...> wrote:
What do you think about combining counters and cache for global variables?


interesting, but there are some differences:

- counters need to be persistent
- persistency write speed of counters need to be high
- only simple type variables (long) need to be stored, no xml fragments

cheers

Dannes


--
eXist-db Native XML Database - http://exist-db.org
Join us on linked-in: http://www.linkedin.com/groups?gid=35624

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

why does a smaller db take longer to back up?

by Paul Kelly-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I just restored a DB and then deleted a bunch of stuff. After the  
deletion the db took longer to back up.

Here are some daily backup daily files to illustrate:

-rw-r--r--  1 root root 306692294 2009-11-05 19:27  
backup-2009-11-05T1905.zip
-rw-r--r--  1 root root 259171801 2009-11-06 19:32  
backup-2009-11-06T1905.zip
-rw-r--r--  1 root root 288484000 2009-11-07 19:40  
backup-2009-11-07T1905.zip
-rw-r--r--  1 root root 302397133 2009-11-08 19:44  
backup-2009-11-08T1905.zip

As you see the DB is almost back to its original size of four days ago  
but takes 17 minutes longer to back up. Why is that?

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open