Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

First you need to find a name for the new query.

 

Code Block
titleExample
query Q_1 {
	//... 
}

...

There are several ways to connect operators to an operator graph. One way is to use the Subscribe-expression. The arrow of a Subscribe-expression gives a hint for the direction of data flow (e.g. auction->window). If an operator has more than one output in this context, you can specify an output port by using the OutputPort-expression (e.g. filter:1). The input port is automatically increased when a source is subscribed. Another way to connect operators is by using the constructors or methods of operator classes. For example, by using the methods it is possible to manually change or set an input port.

...

Code Block
titleMore complex example
query Q_2(dorewrite = false, runquery = true) {    
    double memoryInGB = runtime.totalMemory / 1073741824.0;    
        
    long windowSize = 10;    
    if (memoryInGB < 1) 
        windowSize = 5;    
                            
    ElementWindow windowOp{size = windowSize};
    
    Aggregate aggregateOp{
        aggregations = [["AVG", bid.PRICE, "AVG_PRICE"]],
        group_by = [bid.AUCTION]};
    
    Operator[] sinks();    
    for (int i = 1; i<=5; i++) {
        sinks += new ODLSelect{predicate = "bid.AUCTION = "+i};
    }        
        
    bid -> windowOp -> aggregateOp -> sinks;
}

Multiple

...

queries

Normally one query is installed in Odysseus when executing a qdlQDL-query. However, sometimes it might be useful to create several queries in a loop. Therefore you can call methods in a qdlQDL-query to manually create queries. In this context you should set the metadata ‘autoauto_create’ to falsecreate to false.

Code Block
titleExample
query Q_3 (auto_create=false){    
    for (int i = 1; i<=5; i++) {
        ODLSelect select{predicate = "bid.AUCTION = "+i};
        bid -> select;
        start(select);
    }
}

Grammar

Code Block
titleGrammar
QDLModel               ::= (Namespace)* (Query | Class | Interface)*.                          
Query                  ::= "query" ID ("(" (Metadata ("," Metadata))* ")")? StatementBlock.                                                      
SubscribeExpression    ::= Expression ("->" | "<-") Expression.
PortExpression         ::= Expression ":" Expression.