Sharing key indexes

Sharing key indexes by Michael Kay.

From the post:

For ever and a day, Saxon has tried to ensure that when several transformations are run using the same stylesheet and the same source document(s), any indexes built for those documents are reused across transformations. This has always required some careful juggling of Java weak references to ensure that the indexes are dropped from memory as soon as either the executable stylesheet or the source document are no longer needed.

I’ve now spotted a flaw in this design. It wasn’t reported by a user, and it didn’t arise from a test case, it simply occurred to me as a theoretical possibility, and I have now written a test case that shows it actually happens. The flaw is this: if the definition of the key includes a reference to a global variable or a stylesheet parameter, then the content of the index depends on the values of global variables, and these are potentially different in different transformations using the same stylesheet.

Michael discovers a very obscure bug entirely on his own and yet resolves to fix it.

That is so unusual that I thought it merited mentioning.

It should give you great confidence in Saxon.

How that impacts your confidence on other software I cannot say.

Comments are closed.