Hi there,

I'm evaluating Sedna and have troubles executing some queries. To be 
more precisely, I'm using Sedna 3.1.126, Sedna XML:DB API 1.2 RC3, Sun 
JDK 1.6.0_11 on Windows XP Professional x86. The problem mainly occurrs 
on larger collections (more than 300,000 xml files) and for more complex 
XQueries.

The error message I get looks like:

Client did not understand instruction 1196639556, body length = 0.
Exception in thread "main" java.lang.NullPointerException
        at net.cfoster.sedna.xmldb.n.a(Unknown Source)
        at net.cfoster.sedna.xmldb.i.hasMoreResources(Unknown Source)
        at net.cfoster.sedna.xmldb.x.hasMoreResources(Unknown Source)
        [...]
Client did not understand instruction 1196639556, body length = 1312890957.
Exception in thread "Thread-0" java.lang.NullPointerException
        at net.cfoster.sedna.xmldb.n.a(Unknown Source)
        at net.cfoster.sedna.xmldb.y.e(Unknown Source)
        at net.cfoster.sedna.xmldb.t.a(Unknown Source)
        at net.cfoster.sedna.xmldb.j.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:619)

One XQuery which does not work as expected (it works fine for smaller 
collections!) is:

let $role := "customer"
 let $type := "invoice"
 for $yearAndMonth in fn:distinct-values(index-scan("index_0", $type, 
"EQ")[...@date][fn:matches(@sum, 
"^[0-9]+(\.[0-9]+)?$")]/fn:substring(@date, 1, 7))
 let $headers := (
  for $header in index-scan("index_1", $role, 
"EQ")[names/name/text()][references/referen...@type = 
$type][fn:matches(@date, fn:concat("^", 
$yearAndMonth))][fn:matches(@sum, "^[0-9]+(\.[0-9]+)?$")]]
  order by $header/references/referen...@type = $type][fn:matches(@date, 
fn:concat("^", $yearAndMonth))][fn:matches(@sum, 
"^[0-9]+(\.[0-9]+)?$")]/xs:double(@sum) descending
  return
  $header
 )
 let $topHeader := fn:subsequence($headers, 1, 1)
 let $date := fn:string($topHeader/references/referen...@type = 
$type][fn:matches(@date, fn:concat("^", 
$yearAndMonth))][fn:matches(@sum, "^[0-9]+(\.[0-9]+)?$")]/@date)
 let $name := $topHeader/names/na...@role = $role]/text()
 let $sum := $topHeader/references/referen...@type = 
$type][fn:matches(@date, fn:concat("^", 
$yearAndMonth))][fn:matches(@sum, "^[0-9]+(\.[0-9]+)?$")]/xs:double(@sum)
 order by $yearAndMonth ascending
 return
 <resultSet><date>{ $date }</date><name>{ $name }</name><sum>{ 
fn:round-half-to-even($sum, 2) }</sum></resultSet>

Both indizes I use in this query are created with:

create index "index_0"
 on fn:collection("test")/header/references/reference
 by @type
 as xs:string

create index "index_1"
 on fn:collection("test")/header
 by names/name/@role
 as xs:string

The important lines of the Java code to execute XQueries are:

public class Sedna {
    private Collection collection;

    public void connect() {
        Database database = (Database) 
Class.forName("net.cfoster.sedna.DatabaseImpl").newInstance();
        DatabaseManager.registerDatabase(database);
        collection = 
DatabaseManager.getCollection("xmldb:sedna://localhost:5050/test/test", 
"SYSTEM", "MANAGER");
    }

    public void execute(String xQuery) {
        XQueryService xQueryService = (XQueryService) 
collection.getService("XQueryService", "1.0");
        ResourceSet resourceSet = xQueryService.query(xQuery);
        ResourceIterator resourceIterator = resourceSet.getIterator();
        StringBuffer stringBuffer = new StringBuffer();

        while (resourceIterator.hasMoreResources() == true) {
            Resource resource = resourceIterator.nextResource();
            stringBuffer.append(resource.getContent().toString());
            stringBuffer.append('\n');
        }

        return stringBuffer.toString();
    }

    public void disconnect() {
        collection.close();
    }
}

Does anybody know what I could try to avoid this error? Is there 
something I've missed or a workaround for this problem? How can I tune 
Sedna and/or my XQuery to improve performance?

Thanks a lot!

Andreas Meinl


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Sedna-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sedna-discussion

Reply via email to