Re: [MarkLogic Dev General] fn:current-dateTime()

2017-01-05 Thread Wayne Feick
If you're trying to figure out how long things take to run, you could 
use xdmp:elapsed-time().


   http://docs.marklogic.com/xdmp:elapsed-time

Be aware that lazy/delayed evaluation can result in confusing results. 
You can avoid that with xdmp:eager().


   http://docs.marklogic.com/xdmp:eager



On 01/05/2017 09:44 AM, David Lee wrote:


This is correct functionality.

Within a single XQuery statement fn:current-dateTime will return the 
same value. This is defined in the W3C XQuery specifications.  The 
specifications do not cover the concept of multiple 'statements' or 
'transactions' or spawn/eval/invoke etc -- those are higher level 
vendor specific concepts.  The behavior you are seeing is exactly what 
should be expected.


Within any 'statement' fn:current-dateTime() is guaranteed to be the 
same;  In different statements it may be different (depending on the 
precision of the time format and how fast the statements are executed.)


A minimal case to try is this:

- Single Xquery Statement.

fn:current-dateTime(),

xdmp:sleep(1000),

fn:current-dateTime()

->>> This will produce the same results for both

vs

 Multiple XQuery Statements (note ";" vs "," )

fn:current-dateTime();

xdmp:sleep(1000);

fn:current-dateTime();

-> The second time will be approx. 1 second greater than the first.

*From:*general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] *On Behalf Of *sweet frd

*Sent:* Thursday, January 05, 2017 2:00 AM
*To:* MarkLogic Developer Discussion <general@developer.marklogic.com>
*Subject:* Re: [MarkLogic Dev General] fn:current-dateTime()

Hi All,

Please find the below code snippet in which i have created an invoke 
and module xquery with same fn:current-dateTime() logging and 
returning result.


As a result I can able to see the timestamp is different :

   1. when an other xquery is called using invoke

   2. when an other xquery is called using spawn

   3. when using spawn function for both local and other module 
xquery function


*Sample :*

import module namespace check = "http://marklogic.com/check; at 
"/a/common/check_now.xqy";


declare function local:dateTime(){

(

fn:current-dateTime(),

xdmp:log(("local fun",fn:current-dateTime()))

)

};

*let $check := fn:current-dateTime()*

let $time := cts:uri-match("*")

let $time := cts:search(doc(),())

let $check1 := xdmp:invoke("/a/common/now.xqy")

let $check11 := xdmp:spawn("/a/common/now.xqy")

*let $check2 := fn:current-dateTime()*

let $check3 := local:dateTime()

let $check4 := check:dateTime()

let $check5 := xdmp:spawn-function(function(){local:dateTime()})

let $check6 := xdmp:spawn-function(function(){check:dateTime()})

return 
("Result",$check,"aaa",$check1,"aaa11",$check11,"bbb",$check2,"ccc",$check3,"ddd",$check4,"spawn 
eee",$check5, "fff",$check6)


Verify the result and marklogic logs..

Regards,

N. Sumathi.

On Thu, Nov 17, 2016 at 6:53 AM, Florent Georges <li...@fgeorges.org 
<mailto:li...@fgeorges.org>> wrote:


Hi,

The current date and time is the same through the evaluation of the
entire query.  So if "submodule.xay" is a library module, imported in
the main module, that will give you the exact same value.

If it is not a library module, and you invoke, spawn, schedule a task,
eval or anything else, it depends on that "anything else"...

Regards,

--
Florent Georges
http://fgeorges.org/
http://h2o.consulting/ - New website!



On 17 November 2016 at 12:46, sweet frd wrote:
> Hi All,
>
> I have a module somemodule.xqy which has the following line for
logic
>
> fn:current-dateTime()
>
>
> Will there be a difference in output for the below scenarios
>
> (a) Invoke the above xquery (somemodule.xqy) in main module
>
> (b) Directly invoke the function fn:current-dateTime() in the
main module
>
>
> Regards,
> N. Sumathi.
>

> ___
> General mailing list
> General@developer.marklogic.com
<mailto:General@developer.marklogic.com>
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
___
General mailing list
General@developer.marklogic.com
<mailto:General@developer.marklogic.com>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general



___
General mailing list
General@developer.marklogic.com
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general


___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] fn:current-dateTime()

2017-01-05 Thread David Lee
This is correct functionality.
Within a single XQuery statement fn:current-dateTime will return the same 
value. This is defined in the W3C XQuery specifications.  The specifications do 
not cover the concept of multiple 'statements' or 'transactions' or 
spawn/eval/invoke etc -- those are higher level vendor specific concepts.  The 
behavior you are seeing is exactly what should be expected.
Within any 'statement' fn:current-dateTime() is guaranteed to be the same;  In 
different statements it may be different (depending on the precision of the 
time format and how fast the statements are executed.)

A minimal case to try is this:


- Single Xquery Statement.
fn:current-dateTime(),
xdmp:sleep(1000),
fn:current-dateTime()
->>> This will produce the same results for both

vs
  Multiple XQuery Statements (note ";" vs "," )
fn:current-dateTime();
xdmp:sleep(1000);
fn:current-dateTime();

->  The second time will be approx. 1 second greater than the first.








From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of sweet frd
Sent: Thursday, January 05, 2017 2:00 AM
To: MarkLogic Developer Discussion <general@developer.marklogic.com>
Subject: Re: [MarkLogic Dev General] fn:current-dateTime()

Hi All,

Please find the below code snippet in which i have created an invoke and module 
xquery with same fn:current-dateTime() logging and returning result.

As a result I can able to see the timestamp is different :
   1. when an other xquery is called using invoke
   2. when an other xquery is called using spawn
   3. when using spawn function for both local and other module xquery 
function

Sample :
import module namespace check = "http://marklogic.com/check; at 
"/a/common/check_now.xqy";

declare function local:dateTime(){
(
fn:current-dateTime(),
xdmp:log(("local fun",fn:current-dateTime()))
)
};

let $check := fn:current-dateTime()
let $time := cts:uri-match("*")
let $time := cts:search(doc(),())
let $check1 := xdmp:invoke("/a/common/now.xqy")
let $check11 := xdmp:spawn("/a/common/now.xqy")
let $check2 := fn:current-dateTime()
let $check3 := local:dateTime()
let $check4 := check:dateTime()
let $check5 := xdmp:spawn-function(function(){local:dateTime()})
let $check6 := xdmp:spawn-function(function(){check:dateTime()})
return 
("Result",$check,"aaa",$check1,"aaa11",$check11,"bbb",$check2,"ccc",$check3,"ddd",$check4,"spawn
 eee",$check5, "fff",$check6)

Verify the result and marklogic logs..

Regards,
N. Sumathi.


On Thu, Nov 17, 2016 at 6:53 AM, Florent Georges 
<li...@fgeorges.org<mailto:li...@fgeorges.org>> wrote:
Hi,

The current date and time is the same through the evaluation of the
entire query.  So if "submodule.xay" is a library module, imported in
the main module, that will give you the exact same value.

If it is not a library module, and you invoke, spawn, schedule a task,
eval or anything else, it depends on that "anything else"...

Regards,

--
Florent Georges
http://fgeorges.org/
http://h2o.consulting/ - New website!


On 17 November 2016 at 12:46, sweet frd wrote:
> Hi All,
>
> I have a module somemodule.xqy which has the following line for logic
>
> fn:current-dateTime()
>
>
> Will there be a difference in output for the below scenarios
>
> (a) Invoke the above xquery (somemodule.xqy) in main module
>
> (b) Directly invoke the function fn:current-dateTime() in the main module
>
>
> Regards,
> N. Sumathi.
>
> ___
> General mailing list
> General@developer.marklogic.com<mailto:General@developer.marklogic.com>
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
___
General mailing list
General@developer.marklogic.com<mailto:General@developer.marklogic.com>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general

___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] fn:current-dateTime()

2017-01-04 Thread sweet frd
Hi All,

Please find the below code snippet in which i have created an invoke and
module xquery with same fn:current-dateTime() logging and returning result.

As a result I can able to see the timestamp is different :
   1. when an other xquery is called using invoke
   2. when an other xquery is called using spawn
   3. when using spawn function for both local and other module xquery
function

*Sample :*
import module namespace check = "http://marklogic.com/check; at
"/a/common/check_now.xqy";

declare function local:dateTime(){
(
fn:current-dateTime(),
xdmp:log(("local fun",fn:current-dateTime()))
)
};

*let $check := fn:current-dateTime()*
let $time := cts:uri-match("*")
let $time := cts:search(doc(),())
let $check1 := xdmp:invoke("/a/common/now.xqy")
let $check11 := xdmp:spawn("/a/common/now.xqy")
*let $check2 := fn:current-dateTime()*
let $check3 := local:dateTime()
let $check4 := check:dateTime()
let $check5 := xdmp:spawn-function(function(){local:dateTime()})
let $check6 := xdmp:spawn-function(function(){check:dateTime()})
return
("Result",$check,"aaa",$check1,"aaa11",$check11,"bbb",$check2,"ccc",$check3,"ddd",$check4,"spawn
eee",$check5, "fff",$check6)

Verify the result and marklogic logs..

Regards,
N. Sumathi.


On Thu, Nov 17, 2016 at 6:53 AM, Florent Georges  wrote:

> Hi,
>
> The current date and time is the same through the evaluation of the
> entire query.  So if "submodule.xay" is a library module, imported in
> the main module, that will give you the exact same value.
>
> If it is not a library module, and you invoke, spawn, schedule a task,
> eval or anything else, it depends on that "anything else"...
>
> Regards,
>
> --
> Florent Georges
> http://fgeorges.org/
> http://h2o.consulting/ - New website!
>
>
> On 17 November 2016 at 12:46, sweet frd wrote:
> > Hi All,
> >
> > I have a module somemodule.xqy which has the following line for logic
> >
> > fn:current-dateTime()
> >
> >
> > Will there be a difference in output for the below scenarios
> >
> > (a) Invoke the above xquery (somemodule.xqy) in main module
> >
> > (b) Directly invoke the function fn:current-dateTime() in the main module
> >
> >
> > Regards,
> > N. Sumathi.
> >
> > ___
> > General mailing list
> > General@developer.marklogic.com
> > Manage your subscription at:
> > http://developer.marklogic.com/mailman/listinfo/general
> >
> ___
> General mailing list
> General@developer.marklogic.com
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


[MarkLogic Dev General] fn:current-dateTime() (sweet frd)

2016-11-17 Thread Gary Vidal
fn:current-dateTime() will never change within the same
session/transaction.
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] fn:current-dateTime()

2016-11-17 Thread Florent Georges
Hi,

The current date and time is the same through the evaluation of the
entire query.  So if "submodule.xay" is a library module, imported in
the main module, that will give you the exact same value.

If it is not a library module, and you invoke, spawn, schedule a task,
eval or anything else, it depends on that "anything else"...

Regards,

-- 
Florent Georges
http://fgeorges.org/
http://h2o.consulting/ - New website!


On 17 November 2016 at 12:46, sweet frd wrote:
> Hi All,
>
> I have a module somemodule.xqy which has the following line for logic
>
> fn:current-dateTime()
>
>
> Will there be a difference in output for the below scenarios
>
> (a) Invoke the above xquery (somemodule.xqy) in main module
>
> (b) Directly invoke the function fn:current-dateTime() in the main module
>
>
> Regards,
> N. Sumathi.
>
> ___
> General mailing list
> General@developer.marklogic.com
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] fn:current-dateTime()

2016-11-17 Thread Geert Josten
Hi,

No, the output will be the same. In fact all calls to that function throughout 
the request will return the same value (effectively the request timestamp). 
Wrapping the call in another function will create a marginal overhead though, 
but depending on how often it would get called, not by much, or not noticeable 
at all..

Cheers,
Geert

From: 
<general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>>
 on behalf of sweet frd 
<sumathisumi...@gmail.com<mailto:sumathisumi...@gmail.com>>
Reply-To: MarkLogic Developer Discussion 
<general@developer.marklogic.com<mailto:general@developer.marklogic.com>>
Date: Thursday, November 17, 2016 at 12:46 PM
To: MarkLogic Developer Discussion 
<general@developer.marklogic.com<mailto:general@developer.marklogic.com>>
Subject: [MarkLogic Dev General] fn:current-dateTime()

Hi All,

I have a module somemodule.xqy which has the following line for logic

fn:current-dateTime()


Will there be a difference in output for the below scenarios

(a) Invoke the above xquery (somemodule.xqy) in main module

(b) Directly invoke the function fn:current-dateTime() in the main module


Regards,
N. Sumathi.
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


[MarkLogic Dev General] fn:current-dateTime()

2016-11-17 Thread sweet frd
Hi All,

I have a module somemodule.xqy which has the following line for logic

fn:current-dateTime()


Will there be a difference in output for the below scenarios

(a) Invoke the above xquery (somemodule.xqy) in main module

(b) Directly invoke the function fn:current-dateTime() in the main module


Regards,
N. Sumathi.
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general