@ Override public DatalogProgram translate ( IQ initialQuery ) { IQ orderLiftedQuery = liftOrderBy ( initialQuery ) ; Optional < MutableQueryModifiers > optionalModifiers = extractTopQueryModifiers ( orderLiftedQuery ) ; // Mutable DatalogProgram dProgram ; if ( optionalModifiers . isPresent ( ) ) { MutableQueryModifiers mutableModifiers = optionalModifiers . get ( ) ; dProgram = datalogFactory . getDatalogProgram ( mutableModifiers ) ; } else { dProgram = datalogFactory . getDatalogProgram ( ) ; } normalizeIQ ( orderLiftedQuery ) . forEach ( q -> translate ( q , dProgram ) ) ; // CQIEs are mutable dProgram . getRules ( ) . forEach ( q -> unfoldJoinTrees ( q . getBody ( ) ) ) ; return dProgram ; }
Translate an intermediate query tree into a Datalog program .