You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

In this tutorial you will learn to write simple queries that filter elements and attributes.

We will use the same setting as in Tutorial: Simple Query Processing. So you should follow steps 1-4.

Selection

With the selection operator you can filter out elements that are not relevant for further processing. Create a new Odysseus Script file with the PQL template and name it query2.

The first example will select only those auction, that are created by the seller with the id 1:

out = SELECT({predicate='seller=1'}, nexmark:auction)

Execute the script and show the output as table. After some time, you should see only auctions opened by the seller with the id 1

In this script you define a SELECT-Operator. In Procedural Query Language (PQL) each operator is identified by a name. Inside the operator there are two parts. The first part is the configuration inbetween "{" and "}". The seconds part is the source part, i.e. here the sources are listed that should deliver the input.

In this example the used source is nexmark:auction (A selection can only filter out elements from one source, so no further sources can be used in a selection). In the configuration area predicate describes the predicate that should be used in the selection. For each incoming event the predicate is evaluated and the event is send to the next operator if the predicate evaluates to true. In other cases the event will be discarded.

If you look at the query plan, you will see, the following

The filter step is done by the top most operator Select.

Now modify the query and change the predicate to 'seller=1 || seller=2'. This meens you are only interested in auctions opened by seller 1 or seller 2.

Remove the old query and execute the new script. The output should look like in the following.

More complex predicates can be defined. See Mathematical Functions for further information.

  • No labels