about performance
Wednesday, 20 July 2011 · 4 messages
LW
Lusha Wang20 Jul 2011 19:52 #
Hello Everyone
When I tried the online basex demo, no mater how frequent I submit the query, i can always get results. However, in my own machine, i started the basex server, and then I use php script to query the server, sometimes, no results are returned. Is there any way to solve this problem? Thanks a lot.
Sincerely
Serena
CG
Christian Grün20 Jul 2011 19:59 #
Serena,
thanks for your e-mail, and.. Sorry, it's difficult to give you advice without any reproducible code [1]. Please take some time and send us a small code example that allows us to find out what's going wrong.
Best,
Christian
[1] http://sscce.org/
Quoted text · Lusha Wang · 18 lines
On Wed, Jul 20, 2011 at 7:52 PM, Lusha Wang <lwang40 at syr.edu> wrote: > Hello Everyone > When I tried the online basex demo, no mater how frequent I submit > the query, i can always get results. However, in my own machine, i started > the basex server, and then I use php script to query the server, sometimes, > no results are returned. Is there any way to solve this problem? Thanks a > lot. > > > Sincerely > Serena > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >
CG
Christian Grün20 Jul 2011 20:16 #
Serena,
this is better than nothing, but I still need more info (at least an input document that allows me to run your query out of the box) to get a clue what might go on.
Christian
___________________________
2011/7/20 Lusha Wang <lwang40 at syr.edu>:
Quoted text · Christian Grün · 86 lines
> hI Christian > I feel like this is not about my code. Because most of the time I can get results correctly. But I still pasted my code in the following: > > <html> > <body> > <?php > > include("BaseXClient.php"); > $start=$_GET['start']; > $end = $_GET['end']; > //$type=$_GET['type']; > > > if($start!=null && $end!=null) > { > echo "all entites that are within this time period:".$start."--".$end."<br>"; > > > $cmd='for $Document in doc("newdf")//Document[xs:date(./Date/text()) <=xs:date("'.$end.'") and xs:date(./Date/text()) >=xs:date("'.$start.'")] return <Document>{ for $d in $Document/HasDomain/@domain/data() where $Document/HasDomain return <Domain>{attribute{"id"}{$d}, attribute{"data"}{doc("newdf")//Domain[@id/data()=$d]/Name/text()}}</Domain>, for $u in $Document/HasURL/@url/data() where $Document/HasURL return <URL>{attribute{"id"}{$u}, attribute{"data"}{doc("newdf")//URL[@id/data()=$u]/Name/text()} }</URL>, for $i in $Document/HasIP/@ip/data() where $Document/HasIP return <IP>{attribute{"id"}{$i}, attribute{"data"}{doc("newdf")//Ip[@id/data()=$i]/Name/text()}}</IP>, $Document/Time,$Document/Author,$Document/IsReply}</Document>'; > } > > > > // commands to be performed > > $replace_string=array("<Document>"=>" ","</Document>"=>" ","<Domain"=>" ","/>"=>" ","<URL"=>" ","<IP"=>" ","<Author"=>" ","<Time>"=>" ","</Time>"=>" "); > try { > > set_time_limit(0); > ini_set('max_execution_time',1000); > // create session > $session = new Session("localhost", 1984, "admin", "admin"); > if($cmd!=null) > { > > $query = $session->query($cmd); > print $query->init(); > $count=0; > if(!$query->more()) echo "no results"; > while($query->more()) { > $result=$query->next(); > $result=strtr($result,$replace_string); > echo $result."<br>"; > > } > > print $query->close(); > } > print $session->close(); > } catch (Exception $e) { > // print exception > print $e->getMessage(); > } > ?> > </body> > </html> > ________________________________________ > From: Christian Grün [christian.gruen at gmail.com] > Sent: Wednesday, July 20, 2011 12:59 PM > To: Lusha Wang > Cc: basex-talk at mailman.uni-konstanz.de > Subject: Re: [basex-talk] about performance > > Serena, > > thanks for your e-mail, and.. Sorry, it's difficult to give you advice > without any reproducible code [1]. Please take some time and send us a > small code example that allows us to find out what's going wrong. > > Best, > Christian > > [1] http://sscce.org/ > ___________________________ > > On Wed, Jul 20, 2011 at 7:52 PM, Lusha Wang <lwang40 at syr.edu> wrote: >> Hello Everyone >> When I tried the online basex demo, no mater how frequent I submit >> the query, i can always get results. However, in my own machine, i started >> the basex server, and then I use php script to query the server, sometimes, >> no results are returned. Is there any way to solve this problem? Thanks a >> lot. >> >> >> Sincerely >> Serena
CG
Christian Grün20 Jul 2011 20:45 #
I got your example working after closing one element in your example document. Still I couldn't reproduce the problem you encountered. Note, however, that you are calling " $query->more() " twice without retrieving the first result.
If your problem persists, please try to run your code with the stable version of BaseX (http://files.basex.org/releases/latest/), and give us some more hints.
Christian
Quoted text · Lusha Wang · 106 lines
On Wed, Jul 20, 2011 at 8:28 PM, Lusha Wang <lwang40 at syr.edu> wrote: > <?xml version="1.0" encoding="UTF-8"?> > <root> > ... > From: Christian Grün [christian.gruen at gmail.com] > Sent: Wednesday, July 20, 2011 1:16 PM > To: Lusha Wang; BaseX > Subject: Re: [basex-talk] about performance > > Serena, > > this is better than nothing, but I still need more info (at least an > input document that allows me to run your query out of the box) to get > a clue what might go on. > > Christian > ___________________________ > > 2011/7/20 Lusha Wang <lwang40 at syr.edu>: >> hI Christian >> I feel like this is not about my code. Because most of the time I can get results correctly. But I still pasted my code in the following: >> >> <html> >> <body> >> <?php >> >> include("BaseXClient.php"); >> $start=$_GET['start']; >> $end = $_GET['end']; >> //$type=$_GET['type']; >> >> >> if($start!=null && $end!=null) >> { >> echo "all entites that are within this time period:".$start."--".$end."<br>"; >> >> >> $cmd='for $Document in doc("newdf")//Document[xs:date(./Date/text()) <=xs:date("'.$end.'") and xs:date(./Date/text()) >=xs:date("'.$start.'")] return <Document>{ for $d in $Document/HasDomain/@domain/data() where $Document/HasDomain return <Domain>{attribute{"id"}{$d}, attribute{"data"}{doc("newdf")//Domain[@id/data()=$d]/Name/text()}}</Domain>, for $u in $Document/HasURL/@url/data() where $Document/HasURL return <URL>{attribute{"id"}{$u}, attribute{"data"}{doc("newdf")//URL[@id/data()=$u]/Name/text()} }</URL>, for $i in $Document/HasIP/@ip/data() where $Document/HasIP return <IP>{attribute{"id"}{$i}, attribute{"data"}{doc("newdf")//Ip[@id/data()=$i]/Name/text()}}</IP>, $Document/Time,$Document/Author,$Document/IsReply}</Document>'; >> } >> >> >> >> // commands to be performed >> >> $replace_string=array("<Document>"=>" ","</Document>"=>" ","<Domain"=>" ","/>"=>" ","<URL"=>" ","<IP"=>" ","<Author"=>" ","<Time>"=>" ","</Time>"=>" "); >> try { >> >> set_time_limit(0); >> ini_set('max_execution_time',1000); >> // create session >> $session = new Session("localhost", 1984, "admin", "admin"); >> if($cmd!=null) >> { >> >> $query = $session->query($cmd); >> print $query->init(); >> $count=0; >> if(!$query->more()) echo "no results"; >> while($query->more()) { >> $result=$query->next(); >> $result=strtr($result,$replace_string); >> echo $result."<br>"; >> >> } >> >> print $query->close(); >> } >> print $session->close(); >> } catch (Exception $e) { >> // print exception >> print $e->getMessage(); >> } >> ?> >> </body> >> </html> >> ________________________________________ >> From: Christian Grün [christian.gruen at gmail.com] >> Sent: Wednesday, July 20, 2011 12:59 PM >> To: Lusha Wang >> Cc: basex-talk at mailman.uni-konstanz.de >> Subject: Re: [basex-talk] about performance >> >> Serena, >> >> thanks for your e-mail, and.. Sorry, it's difficult to give you advice >> without any reproducible code [1]. Please take some time and send us a >> small code example that allows us to find out what's going wrong. >> >> Best, >> Christian >> >> [1] http://sscce.org/ >> ___________________________ >> >> On Wed, Jul 20, 2011 at 7:52 PM, Lusha Wang <lwang40 at syr.edu> wrote: >>> Hello Everyone >>> When I tried the online basex demo, no mater how frequent I submit >>> the query, i can always get results. However, in my own machine, i started >>> the basex server, and then I use php script to query the server, sometimes, >>> no results are returned. Is there any way to solve this problem? Thanks a >>> lot. >>> >>> >>> Sincerely >>> Serena >
Written for BaseX 6.7. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery