private IRunningQuery initQueryWithConditionalRoutingOp(IConstraint condition,int startId,int joinId1,int joinId2) throws Exception {
  final int predId1=10;
  final int predId2=11;
  final int condId=12;
  final int sliceId=13;
  final PipelineOp startOp=new StartOp(new BOp[]{},NV.asMap(new NV[]{new NV(Predicate.Annotations.BOP_ID,startId),new NV(SliceOp.Annotations.EVALUATION_CONTEXT,BOpEvaluationContext.CONTROLLER)}));
  final Predicate<?> pred1Op=new Predicate<E>(new IVariableOrConstant[]{Var.var("x"),Var.var("y")},NV.asMap(new NV[]{new NV(Predicate.Annotations.RELATION_NAME,new String[]{namespace}),new NV(Predicate.Annotations.BOP_ID,predId1),new NV(Annotations.TIMESTAMP,ITx.READ_COMMITTED)}));
  final Predicate<?> pred2Op=new Predicate<E>(new IVariableOrConstant[]{Var.var("y"),Var.var("z")},NV.asMap(new NV[]{new NV(Predicate.Annotations.RELATION_NAME,new String[]{namespace}),new NV(Predicate.Annotations.BOP_ID,predId2),new NV(Annotations.TIMESTAMP,ITx.READ_COMMITTED)}));
  final ConditionalRoutingOp cond=new ConditionalRoutingOp(new BOp[]{startOp},NV.asMap(new NV[]{new NV(BOp.Annotations.BOP_ID,condId),new NV(PipelineOp.Annotations.SINK_REF,joinId1),new NV(PipelineOp.Annotations.ALT_SINK_REF,sliceId),new NV(ConditionalRoutingOp.Annotations.CONDITION,condition)}));
  final PipelineOp join1Op=new PipelineJoin<E>(new BOp[]{cond},new NV(Predicate.Annotations.BOP_ID,joinId1),new NV(PipelineJoin.Annotations.PREDICATE,pred1Op));
  final PipelineOp join2Op=new PipelineJoin<E>(new BOp[]{join1Op},new NV(Predicate.Annotations.BOP_ID,joinId2),new NV(PipelineJoin.Annotations.PREDICATE,pred2Op));
  final PipelineOp sliceOp=new SliceOp(new BOp[]{join2Op},NV.asMap(new NV[]{new NV(BOp.Annotations.BOP_ID,sliceId),new NV(BOp.Annotations.EVALUATION_CONTEXT,BOpEvaluationContext.CONTROLLER),new NV(PipelineOp.Annotations.SHARED_STATE,true),new NV(PipelineOp.Annotations.REORDER_SOLUTIONS,false),new NV(QueryEngine.Annotations.CHUNK_HANDLER,StandaloneChunkHandler.TEST_INSTANCE)}));
  final PipelineOp query=sliceOp;
  final UUID queryId=UUID.randomUUID();
  final IBindingSet initialBindings=new ListBindingSet();
{
    initialBindings.set(Var.var("x"),new Constant<String>("Mary"));
  }
  final IRunningQuery runningQuery=queryEngine.eval(queryId,query,initialBindings);
  return runningQuery;
}

private IRunningQuery initQueryWithConditionalRoutingOp ( IConstraint condition , int startId , int joinId1 , int joinId2 ) throws Exception { final int predId1 = 10 ; final int predId2 = 11 ; final int condId = 12 ; final int sliceId = 13 ; final PipelineOp startOp = new StartOp ( new BOp [ ] { } , NV . asMap ( new NV [ ] { new NV ( Predicate . Annotations . BOP_ID , startId ) , new NV ( SliceOp . Annotations . EVALUATION_CONTEXT , BOpEvaluationContext . CONTROLLER ) } ) ) ; final Predicate < ? > pred1Op = new Predicate < E > ( new IVariableOrConstant [ ] { Var . var ( "x" ) , Var . var ( "y" ) } , NV . asMap ( new NV [ ] { new NV ( Predicate . Annotations . RELATION_NAME , new String [ ] { namespace } ) , new NV ( Predicate . Annotations . BOP_ID , predId1 ) , new NV ( Annotations . TIMESTAMP , ITx . READ_COMMITTED ) } ) ) ; final Predicate < ? > pred2Op = new Predicate < E > ( new IVariableOrConstant [ ] { Var . var ( "y" ) , Var . var ( "z" ) } , NV . asMap ( new NV [ ] { new NV ( Predicate . Annotations . RELATION_NAME , new String [ ] { namespace } ) , new NV ( Predicate . Annotations . BOP_ID , predId2 ) , new NV ( Annotations . TIMESTAMP , ITx . READ_COMMITTED ) } ) ) ; final ConditionalRoutingOp cond = new ConditionalRoutingOp ( new BOp [ ] { startOp } , NV . asMap ( new NV [ ] { new NV ( BOp . Annotations . BOP_ID , condId ) , new NV ( PipelineOp . Annotations . SINK_REF , joinId1 ) , new NV ( PipelineOp . Annotations . ALT_SINK_REF , sliceId ) , new NV ( ConditionalRoutingOp . Annotations . CONDITION , condition ) } ) ) ; final PipelineOp join1Op = new PipelineJoin < E > ( new BOp [ ] { cond } , new NV ( Predicate . Annotations . BOP_ID , joinId1 ) , new NV ( PipelineJoin . Annotations . PREDICATE , pred1Op ) ) ; final PipelineOp join2Op = new PipelineJoin < E > ( new BOp [ ] { join1Op } , new NV ( Predicate . Annotations . BOP_ID , joinId2 ) , new NV ( PipelineJoin . Annotations . PREDICATE , pred2Op ) ) ; final PipelineOp sliceOp = new SliceOp ( new BOp [ ] { join2Op } , NV . asMap ( new NV [ ] { new NV ( BOp . Annotations . BOP_ID , sliceId ) , new NV ( BOp . Annotations . EVALUATION_CONTEXT , BOpEvaluationContext . CONTROLLER ) , new NV ( PipelineOp . Annotations . SHARED_STATE , true ) , new NV ( PipelineOp . Annotations . REORDER_SOLUTIONS , false ) , new NV ( QueryEngine . Annotations . CHUNK_HANDLER , StandaloneChunkHandler . TEST_INSTANCE ) } ) ) ; final PipelineOp query = sliceOp ; final UUID queryId = UUID . randomUUID ( ) ; final IBindingSet initialBindings = new ListBindingSet ( ) ; { initialBindings . set ( Var . var ( "x" ) , new Constant < String > ( "Mary" ) ) ; } final IRunningQuery runningQuery = queryEngine . eval ( queryId , query , initialBindings ) ; return runningQuery ; }
helper method to initialize a bop tree that includes a conditionalroutinop
