Page tree
Skip to end of metadata
Go to start of metadata

This operator calculated a list of top elements regarding a scoring function. Only if the top elements change, an output will be produced. Additionally, the object that triggered the new calculation is send to output

Outputschema is List<TUPLE>, TUPLE

Remark: Use [] or elementAt to access elements in List and in TUPLE

Parameter:

  • scoringFunction [Expression]: An expression that must return a numerical value
  • k [Integer]: Number of elements that should be treated
  • descending [Boolean]: The standardcase is that the higher the score, the higher the rank. Set to false if the higher the score, the lower the rank.

Example:

PARSER PQL
#ADDQUERY
out = TOPK({
          k = 10,
          scoringfunction = 'price'                        
        },
        ELEMENTWINDOW({
            size = 5                              
          },
          bid
        )                  
      )
      
      
out2 = MAP({
            expressions = [
#LOOP i 0 upto 9
              ['elementAt(topk[${i}],1)','top_${i+1}_auction'],
              ['elementAt(topk[0],2)','top_${i+1}_bidder'],
              ['elementAt(topk[0],4)','top_${i+1}_price'],
#ENDLOOP,
              'topk'
            ], 
                ALLOWNULL = true, 
                SUPPRESSERRORS = true         
          },
          out
        )

  • No labels