Documentation
To run experiments with XCheck-Java, follow the following steps (some steps are optional):
- Download and install
- Prepare the query engine
- Write an experiment
- Configure the experiment's setting
- Run the experiment
- Check the experiment's outcomes
Download XCheck-Java package (XCheck-Java.zip) from the download page. To install XCheck-Java, just unzip the package. The output is a folder called XCheck-Java containing the following:
- a folder adapters with engines' adapters;
- a folder documentation containing this documentation;
- a folder experiments including examples of experiments and their outcomes;
- a folder schema for DTDs;
- a folder source for Java sources of XCheck-Java;
- a folder style for CSS styles;
- the class files of XCheck-Java;
- the GNU General Public License;
- the XCheck-Java configuration document (config.xml).
Read the GNU General Public License (file License in XCheck-Java or in source folders) before proceding.
XCheck-Java runs a given experiment on a given query engine. XCheck-Java works both with query engines that are command-line tools or that define an API. In the former case, all you have to do is to write an adapter for the specific engine to test. This is an XML document that contains information about the engine, in particular the command to run the engine and optional commands to run before and after the execution of the experiment.
To write an adapter, write an XML document describing the engine to test according to the DTD adapter.dtd contained in folder schema and put the adapter in folder adapters. This folder already contains some examples.
Whenever the query engine to test is available as an API, proceed as follows:
- Write an adapter document containing the description of the engine (excluding the execution command).
- Define a Java class, let's call it XCheckMyEngine, that inherits from the abstract class XCheckVoid (contained in XCheckVoid.java in the source folder).
- Override the following methods:
-
Document parseInputDocument(int j, String target). This method parses the input XML document. The parameter int j is the index of the document and String target is the name of the file containing the document to parse. The output is an org.w3c.dom Document object corresponding to the
input document. If an error occurs while parsing the document, then save the error message in variable errorMessageDocument[j] and notify that there was an error for this document by setting errorDocument[j] to Boolean value true.
-
Object executeInputQuery(int j, Document document, String query). This method executes a query. The parameter int j is the index of the query, Document document is the input document on which the query should run, and String query is the query string to execute. The method returns an object with the query result. If an error occurs while parsing the query, then save the error message in variable errorMessageQuery[j] and notify that there was an error for this query by setting errorQuery[j] to Boolean value true.
-
void serializeResult(Object result, String resultFileName, Document document) This method serializes the query result. The parameter Object result is the query result to serialize, String resultFileName is the name of the result file, and Document document is the input document (this parameter might be useful to create the serializer).
- Add to the class XCheckMyEngine the following main method:
public static void main(String[] args) {
XCheckMyEngine myEngine = new XCheckMyEngine();
myEngine.check(args);
}
The method check, inherited from XCheckVoid, executes the test for the engine defined in the above described overridden methods.
- Compile the resulting Java file and put the bytecode class files in the main folder XCheck-Java. If you prefer to use a different folder to run XCheck-Java, then override the field xcheckHome inherited from XCheckVoid class.
Folder source contains two examples: XCheckJAXP.java for the Java API for XML Processing (JAXP) and XCheckBaseX for BaseX.
XCheck-Java defines an experiment as a list of queries. These queries can be either self-containing statements, e.g. the XQuery statement doc("auction.xml")//items, or they can be queries that need to be processed on a target document to specify, for instance the XPath query //items or the equivalent XSLT statement:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:copy-of select="//items"/>
</xsl:template>
</xsl:stylesheet>
In the latter case, the target documents are specified in the experiment document.
An experiment is described in an XML document that should be valid with respect to the DTD experiment.dtd contained in folder schema. To write a new experiment do the following:
- create a new folder for the experiment in the folder experiment;
- write an XML document called experiment.xml describing your experiment (the document must validate experiment.dtd) and put it in the created folder;
- you may include queries in the experiment document or in separated files. In the latter case, create a folder queries in the folder for the experiment in put the query files in there;
- create a folder documents in the folder for the experiment and put XML documents to query in there. In this folder you can also add document schemas if they are relevant for the querying.
Folder experiments of XCheck-java contains some examples.
The execution of XCheck-Java can be configured using the XML document config.xml contained in folder XCheck-Java. This documents is valid with respect to the DTD config.dtd included in folder schema. The configuration parameters are:
- runs. The number of times the evaluation of each query must be repeated. The greater is this parameter, the more accurate are the estimated processing times. Values are integers greater than 0.
- xml. Option to save the query processing times in XML format. Values are yes or no.
- plot. Option to generate Gnuplot plots using the query processing times.
Values are yes, no, or noImage. Value 'noImage' generates only Gnuplot files (DAT and GPL files) and no Gnuplot plots (PNG images). If you do not have Gnuplot on your system, set this option to value 'no'.
- times. Option to measure query processing times. Values are yes or no.. Notice that whenever value is 'no' neither the XML document containing the times nor the corresponding plots are generated.
- answers. Option to save the query answers. Values are yes or no.
- parse. Option to save the document parsing times. Values are yes or no.
- execute. Option to save the query execution times. Values are yes or no.
- serialize. Option to save the query result serialization times. Values are yes or no.
- overall. Option to save the overall times. Values are yes or no.
- checkOutcome. Values are yes or no. If value is 'yes', then the user is prompted whenever a folder named outcome already exists in the current experiment folder. If value is 'no', then the folder outcome, if it exists, is overwritten.
- gnuplotPath. The optional path to Gnuplot program. E.g., /usr/bin
If this element is missing or empty, then the string 'gnuplot'
is used to run Gnuplot. If you do not have Gnuplot on your system, set the above option plot to value 'no'.
XCheck-Java works both with query engines that are command-line tools or that define an API. In the former case run XCheck-Java as follows:
java XCheck engine experiment
where engine in the engine's adapter name and experiment is the name of the experiment folder.
In the latter case run XCheck-Java as follows:
java XCheckMyEngine engine experiment
where XCheckMyEngine is the Java class created as described in section Prepare the query engine, engine in the engine's adapter name, and experiment is the name of the experiment folder.
XCheck-Java stores the outcomes of the performed experiment in a folder called outcome_engine, where engine is the name of the tested query engine. This folder is stored in the folder created for the experiment. The outcomes include:
- An XHTML document called outcome.html containing the engine's performance in terms of different query evaluation times (in tabular and graphical formats), the engine's query answers, and the caught errors (if any). Notice that XCheck-Java keeps track of different query evaluation times (document parsing, query processing, result serialization, overall evaluation time) when it runs on API-based engines, and it records the overall evaluation time only when it runs on command-line engines;
- an XML document called outcome.xml containing, in XML format, the engine's performance in terms of different query evaluation times;
- a folder called answers with query answers;
- a folder called plots with performance plots.
All this output can be configured by the user (see section Configure the experiment's setting). Folder experiments contains examples of performed experiments.