@SuppressWarnings({"unchecked","rawtypes"}) private static PipelineOp distinctTermScanJoin(final PipelineOp left,final List<NV> anns,Predicate pred,final DatasetNode dataset,final Long cutoffLimitIsIgnored,final VarNode distinctTermScanVar,final Properties queryHints,final AST2BOpContext ctx){
  final IVariable distinctVar=distinctTermScanVar.getValueExpression();
  anns.add(new NV(DistinctTermScanOp.Annotations.DISTINCT_VAR,distinctVar));
  final Constant<IV> mockConst=new Constant<IV>(TermId.mockIV(VTE.URI));
  final IPredicate mockPred=pred.asBound(distinctVar,mockConst);
  final SPOKeyOrder keyOrder=SPOKeyOrder.getKeyOrder(mockPred,ctx.isQuads() ? 4 : 3);
  pred=(Predicate)pred.setProperty(IPredicate.Annotations.KEY_ORDER,keyOrder);
  anns.add(new NV(PipelineJoin.Annotations.PREDICATE,pred));
  return applyQueryHints(new DistinctTermScanOp(leftOrEmpty(left),NV.asMap(anns.toArray(new NV[anns.size()]))),queryHints,ctx);
}

@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) private static PipelineOp distinctTermScanJoin ( final PipelineOp left , final List < NV > anns , Predicate pred , final DatasetNode dataset , final Long cutoffLimitIsIgnored , final VarNode distinctTermScanVar , final Properties queryHints , final AST2BOpContext ctx ) { final IVariable distinctVar = distinctTermScanVar . getValueExpression ( ) ; anns . add ( new NV ( DistinctTermScanOp . Annotations . DISTINCT_VAR , distinctVar ) ) ; final Constant < IV > mockConst = new Constant < IV > ( TermId . mockIV ( VTE . URI ) ) ; final IPredicate mockPred = pred . asBound ( distinctVar , mockConst ) ; final SPOKeyOrder keyOrder = SPOKeyOrder . getKeyOrder ( mockPred , ctx . isQuads ( ) ? 4 : 3 ) ; pred = ( Predicate ) pred . setProperty ( IPredicate . Annotations . KEY_ORDER , keyOrder ) ; anns . add ( new NV ( PipelineJoin . Annotations . PREDICATE , pred ) ) ; return applyQueryHints ( new DistinctTermScanOp ( leftOrEmpty ( left ) , NV . asMap ( anns . toArray ( new NV [ anns . size ( ) ] ) ) ) , queryHints , ctx ) ; }
fixme we need to handle cutoff joins here or the distinct - term - scan will not work with the rto ( alternatively , make sure the rto is only using pipeline joins when sampling the join graph ) .
