public LeftTuple createLeftTuple(LeftTuple leftTuple, RightTuple rightTuple, LeftTuple currentLeftChild, LeftTuple currentRightChild, Sink sink, boolean leftTupleMemoryEnabled) { return new LeftTupleImpl(leftTuple, rightTuple, currentLeftChild, currentRightChild, sink, leftTupleMemoryEnabled ); } public Memory createMemory(RuleBaseConfiguration config, InternalWorkingMemory wm) {
public LeftTuple createLeftTuple(LeftTuple leftTuple, RightTuple rightTuple, LeftTuple currentLeftChild, LeftTuple currentRightChild, Sink sink, boolean leftTupleMemoryEnabled) { return new LeftTupleImpl(leftTuple, rightTuple, currentLeftChild, currentRightChild, sink, leftTupleMemoryEnabled ); }
public LeftTuple createLeftTuple(final InternalFactHandle factHandle, final LeftTuple leftTuple, final Sink sink) { return new LeftTupleImpl(factHandle,leftTuple, sink ); }
public LeftTuple createLeftTuple(InternalFactHandle factHandle, Sink sink, boolean leftTupleMemoryEnabled) { return new LeftTupleImpl(factHandle, sink, leftTupleMemoryEnabled ); }
public LeftTuple createLeftTuple(LeftTuple leftTuple, Sink sink, PropagationContext pctx, boolean leftTupleMemoryEnabled) { return new LeftTupleImpl(leftTuple,sink, pctx, leftTupleMemoryEnabled ); }
public LeftTuple createLeftTuple(LeftTuple leftTuple, Sink sink, PropagationContext pctx, boolean leftTupleMemoryEnabled) { return new LeftTupleImpl(leftTuple,sink, pctx, leftTupleMemoryEnabled ); }
public LeftTuple createLeftTuple(InternalFactHandle factHandle, Sink sink, boolean leftTupleMemoryEnabled) { return new LeftTupleImpl(factHandle, sink, leftTupleMemoryEnabled ); }
public LeftTuple createLeftTuple(final InternalFactHandle factHandle, final LeftTuple leftTuple, final Sink sink) { return new LeftTupleImpl(factHandle,leftTuple, sink ); }
public LeftTuple createLeftTuple(LeftTuple leftTuple, Sink sink, PropagationContext pctx, boolean leftTupleMemoryEnabled) { return new LeftTupleImpl(leftTuple,sink, pctx, leftTupleMemoryEnabled ); }
public LeftTuple createLeftTuple(InternalFactHandle factHandle, Sink sink, boolean leftTupleMemoryEnabled) { return new LeftTupleImpl(factHandle, sink, leftTupleMemoryEnabled ); }
public LeftTuple createLeftTuple(LeftTuple leftTuple, RightTuple rightTuple, LeftTuple currentLeftChild, LeftTuple currentRightChild, Sink sink, boolean leftTupleMemoryEnabled) { return new LeftTupleImpl(leftTuple, rightTuple, currentLeftChild, currentRightChild, sink, leftTupleMemoryEnabled ); }
@Test public void testMidTraversal() { LeftTupleImpl tm2 = new LeftTupleImpl(); LeftTupleImpl tm1 = new LeftTupleImpl(tm2, null, (PropagationContext) null,true); LeftTuple tm1_1 = new LeftTupleImpl(tm1, null, (PropagationContext) null,true); // this leaf will not be included LeftTupleImpl t0 = new LeftTupleImpl(tm1, null, (PropagationContext) null,true); // insert two nodes before our root traversal position LeftTupleImpl t1 = new LeftTupleImpl(t0, null, (PropagationContext) null,true); LeftTupleImpl t2 = new LeftTupleImpl(t0, null, (PropagationContext) null,true); LeftTupleImpl t3 = new LeftTupleImpl(t0, null, (PropagationContext) null,true); LeftTupleImpl t1_1 = new LeftTupleImpl(t1, null, (PropagationContext) null,true); LeftTupleImpl t1_2 = new LeftTupleImpl(t1, null, (PropagationContext) null,true); LeftTupleImpl t1_1_1 = new LeftTupleImpl(t1_1, null, (PropagationContext) null,true); LeftTupleImpl t1_1_1_1 = new LeftTupleImpl(t1_1_1, null, (PropagationContext) null,true); LeftTupleImpl t1_1_1_2 = new LeftTupleImpl(t1_1_1, null, (PropagationContext) null,true); LeftTupleImpl t1_1_1_3 = new LeftTupleImpl(t1_1_1, null, (PropagationContext) null,true); LeftTupleImpl t1_2_1 = new LeftTupleImpl(t1_2, null, (PropagationContext) null,true); LeftTupleImpl t1_2_2 = new LeftTupleImpl(t1_2, null, (PropagationContext) null,true); LeftTupleImpl t1_2_2_1 = new LeftTupleImpl(t1_2_2, null, (PropagationContext) null,true); LeftTupleImpl t1_2_3 = new LeftTupleImpl(t1_2, null, (PropagationContext) null,true); LeftTupleImpl t2_1 = new LeftTupleImpl(t2, null, (PropagationContext) null,true); LeftTupleImpl t2_2 = new LeftTupleImpl(t2, null, (PropagationContext) null,true); LeftTupleImpl t2_3 = new LeftTupleImpl(t2, null, (PropagationContext) null,true);
@Test public void testRootTraversal() { LeftTupleImpl t0 = new LeftTupleImpl(); LeftTupleImpl t1 = new LeftTupleImpl(t0, null, (PropagationContext) null, true); LeftTupleImpl t2 = new LeftTupleImpl(t0, null, (PropagationContext) null,true); LeftTupleImpl t3 = new LeftTupleImpl(t0, null, (PropagationContext) null,true); LeftTupleImpl t1_1 = new LeftTupleImpl(t1, null, (PropagationContext) null,true); LeftTupleImpl t1_2 = new LeftTupleImpl(t1, null, (PropagationContext) null,true); LeftTupleImpl t1_1_1 = new LeftTupleImpl(t1_1, null, (PropagationContext) null,true); LeftTupleImpl t1_1_1_1 = new LeftTupleImpl(t1_1_1, null, (PropagationContext) null,true); LeftTupleImpl t1_1_1_2 = new LeftTupleImpl(t1_1_1, null, (PropagationContext) null,true); LeftTupleImpl t1_1_1_3 = new LeftTupleImpl(t1_1_1, null, (PropagationContext) null,true); LeftTupleImpl t1_2_1 = new LeftTupleImpl(t1_2, null, (PropagationContext) null,true); LeftTupleImpl t1_2_2 = new LeftTupleImpl(t1_2, null, (PropagationContext) null,true); LeftTupleImpl t1_2_2_1 = new LeftTupleImpl(t1_2_2, null,(PropagationContext) null, true); LeftTupleImpl t1_2_3 = new LeftTupleImpl(t1_2, null, (PropagationContext) null,true); LeftTupleImpl t2_1 = new LeftTupleImpl(t2, null, (PropagationContext) null,true); LeftTupleImpl t2_2 = new LeftTupleImpl(t2, null,(PropagationContext) null, true); LeftTupleImpl t2_3 = new LeftTupleImpl(t2, null, (PropagationContext) null,true); LeftTupleImpl t2_3_1 = new LeftTupleImpl(t2_3, null, (PropagationContext) null,true); LeftTupleImpl t2_3_1_1 = new LeftTupleImpl(t2_3_1, null, (PropagationContext) null,true); LeftTupleImpl t2_3_2 = new LeftTupleImpl(t2_3, null, (PropagationContext) null,true);
@Test public void testEmptyIterator() { final TupleList map = new TupleList(); final Cheese stilton1 = new Cheese( "stilton", 35 ); final InternalFactHandle h1 = new DefaultFactHandle( 1, stilton1 ); assertNull( map.getFirst( new LeftTupleImpl( h1, null, true ) ) ); } }
public T delete(Object... objects) { this.testStagedDelete = true; if ( objects == null ) { objects = new Object[0]; } for ( int i = 0; i < objects.length; i++ ) { if ( !(objects[i] instanceof Pair) ) { Object o1 = objects[i]; InternalFactHandle fh1 = (InternalFactHandle) wm.getFactHandle( o1 ); LeftTuple leftTuple = new LeftTupleImpl( fh1, sink, true ); leftTuples.addDelete( leftTuple ); } else { Pair p = (Pair )objects[i]; InternalFactHandle fh1 = (InternalFactHandle) wm.getFactHandle( p.getO1() ); LeftTuple leftTuple1 = new LeftTupleImpl( fh1, sink, true ); InternalFactHandle fh2 = (InternalFactHandle) wm.getFactHandle( p.getO2() ); LeftTuple leftTuple2 = sink.createLeftTuple( leftTuple1, new RightTupleImpl( fh2 ), sink ); leftTuples.addDelete( leftTuple2 ); } } return (T) this ; }
public T update(Object... objects) { this.testStagedUpdate = true; if ( objects == null ) { objects = new Object[0]; } for ( int i = 0; i < objects.length; i++ ) { if ( !(objects[i] instanceof Pair) ) { Object o1 = objects[i]; InternalFactHandle fh1 = (InternalFactHandle) wm.getFactHandle( o1 ); LeftTuple leftTuple = new LeftTupleImpl( fh1, sink, true ); leftTuples.addUpdate( leftTuple ); } else { Pair p = (Pair )objects[i]; InternalFactHandle fh1 = (InternalFactHandle) wm.getFactHandle( p.getO1() ); LeftTuple leftTuple1 = new LeftTupleImpl( fh1, sink, true ); InternalFactHandle fh2 = (InternalFactHandle) wm.getFactHandle( p.getO2() ); LeftTuple leftTuple2 = sink.createLeftTuple( leftTuple1, new RightTupleImpl( fh2 ), sink ); leftTuples.addUpdate( leftTuple2 ); } } return (T) this ; }
public SalienceEvaluator(InternalKnowledgeBase kBase, RuleBuildContext context, Rule rule, Salience salience, Person person) { wm = ((StatefulKnowledgeSessionImpl)kBase.newKieSession()); this.context = context; final InternalFactHandle f0 = (InternalFactHandle) wm.insert( person ); tuple = new LeftTupleImpl( f0, null, true ); this.salience = salience; this.halt = false; this.error = false; this.result = (person.getAge() + 20) / 2; RuleTerminalNode rtn = new RuleTerminalNode(); rtn.setSalienceDeclarations( context.getDeclarationResolver().getDeclarations( context.getRule() ).values().toArray( new Declaration[1] ) ); item = new AgendaItemImpl(0, tuple, 0, null, rtn, null); }
public T insert(Object... objects) { this.testStagedInsert = true; if ( objects == null ) { objects = new Object[0]; } for ( int i = 0; i < objects.length; i++ ) { if ( !(objects[i] instanceof Pair) ) { Object o1 = objects[i]; InternalFactHandle fh1 = (InternalFactHandle) wm.getFactHandle( o1 ); LeftTuple leftTuple = new LeftTupleImpl( fh1, sink, true ); leftTuples.addInsert( leftTuple ); } else { Pair p = (Pair )objects[i]; InternalFactHandle fh1 = (InternalFactHandle) wm.getFactHandle( p.getO1() ); LeftTuple leftTuple1 = new LeftTupleImpl( fh1, sink, true ); InternalFactHandle fh2 = (InternalFactHandle) wm.getFactHandle( p.getO2() ); LeftTuple leftTuple2 = sink.createLeftTuple( leftTuple1, new RightTupleImpl( fh2 ), sink ); leftTuples.addInsert( leftTuple2 ); } } return (T) this ; }
@Test public void testSimpleExpression() { StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newKieSession(); final Person p = new Person( "mark", "", 31 ); final InternalFactHandle f0 = (InternalFactHandle) ksession.insert( p ); final LeftTupleImpl tuple = new LeftTupleImpl( f0, null, true ); RuleTerminalNode rtn = new RuleTerminalNode(); rtn.setSalienceDeclarations( context.getDeclarationResolver().getDeclarations( context.getRule() ).values().toArray( new Declaration[1] ) ); AgendaItem item = new AgendaItemImpl(0, tuple, 0, null, rtn, null); assertEquals( 25, context.getRule().getSalience().getValue( new DefaultKnowledgeHelper( item, ksession ), context.getRule(), ksession ) ); }
@Test public void testEmptyIterator() { final InternalReadAccessor extractor = store.getReader( Cheese.class, "type" ); final Pattern pattern = new Pattern( 0, new ClassObjectType( Cheese.class ) ); final Declaration declaration = new Declaration( "typeOfCheese", extractor, pattern ); final FieldIndex fieldIndex = new FieldIndex( extractor, declaration, MvelConstraint.INDEX_EVALUATOR ); final TupleIndexHashTable map = new TupleIndexHashTable( new FieldIndex[]{fieldIndex}, false ); final Cheese stilton = new Cheese( "stilton", 55 ); final InternalFactHandle stiltonHandle = new DefaultFactHandle( 2, stilton ); assertNull( map.getFirst( new LeftTupleImpl( stiltonHandle, null, true ) ) ); }