use of org.drools.core.reteoo.RightTupleImpl in project drools by kiegroup.
the class BaseLeftTuplesBuilder method update.
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;
}
use of org.drools.core.reteoo.RightTupleImpl in project drools by kiegroup.
the class RightMemory method getRightTuples.
public List<RightTuple> getRightTuples(Object... objects) {
BetaNode node = scenario.getBetaNode();
BetaMemory bm = scenario.getBm();
TupleMemory rtm = bm.getRightTupleMemory();
InternalWorkingMemory wm = scenario.getWorkingMemory();
if (objects == null) {
objects = new Object[0];
}
List<RightTuple> rightTuples = new ArrayList<RightTuple>();
for (Object object : objects) {
InternalFactHandle fh = (InternalFactHandle) wm.insert(object);
// node.createLeftTuple( fh, node, true );
RightTuple expectedRightTuple = new RightTupleImpl(fh, node);
expectedRightTuple.setPropagationContext(new PhreakPropagationContext());
rightTuples.add(expectedRightTuple);
}
scenario.setTestRightMemory(true);
return rightTuples;
}
use of org.drools.core.reteoo.RightTupleImpl in project drools by kiegroup.
the class RightBuilder method insert.
public RightBuilder insert(Object... objects) {
for (Object object : objects) {
InternalFactHandle fh = (InternalFactHandle) wm.insert(object);
RightTuple rightTuple = new RightTupleImpl(fh, sink);
rightTuple.setPropagationContext(new PhreakPropagationContext());
rightTuples.addInsert(rightTuple);
}
return this;
}
use of org.drools.core.reteoo.RightTupleImpl in project drools by kiegroup.
the class IndexedHashtableIteratorTest method testCanReachAllEntriesInLastTableRowRightTupleIndexHashTable.
@Test
public void testCanReachAllEntriesInLastTableRowRightTupleIndexHashTable() {
// Construct a table with one row, containing one list, containing three entries.
int numEntries = 3;
TupleList[] table = new TupleList[3];
TupleList rtList = new TupleList();
table[0] = rtList;
for (int i = 0; i < numEntries; i++) {
RightTuple rightTuple = new RightTupleImpl();
rightTuple.setMemory(rtList);
rtList.add(rightTuple);
}
rtList = new TupleList();
table[2] = rtList;
for (int i = 0; i < numEntries; i++) {
RightTuple rightTuple = new RightTupleImpl();
rightTuple.setMemory(rtList);
rtList.add(rightTuple);
}
rtList = new TupleList();
table[2].setNext(rtList);
for (int i = 0; i < numEntries; i++) {
RightTuple rightTuple = new RightTupleImpl();
rightTuple.setMemory(rtList);
rtList.add(rightTuple);
}
// test fast
TupleIndexHashTable.FullFastIterator iter = new TupleIndexHashTable.FullFastIterator(table);
List<RightTuple> list = new ArrayList<RightTuple>();
for (RightTuple rightTuple = (RightTuple) iter.next(null); rightTuple != null; rightTuple = (RightTuple) iter.next(rightTuple)) {
// ensure no duplicate
assertFalse(contains(list, rightTuple));
list.add(rightTuple);
}
// test normal
TupleIndexHashTable rthTable = new TupleIndexHashTable();
rthTable.init(table, 3, numEntries * 3);
TupleIndexHashTable.FieldIndexHashTableFullIterator iter2 = new TupleIndexHashTable.FieldIndexHashTableFullIterator(rthTable);
list = new ArrayList<RightTuple>();
for (RightTuple rightTuple = (RightTuple) iter2.next(); rightTuple != null; rightTuple = (RightTuple) iter2.next()) {
// ensure no duplicate
assertFalse(contains(list, rightTuple));
list.add(rightTuple);
}
assertEquals(numEntries * 3, list.size());
}
use of org.drools.core.reteoo.RightTupleImpl in project drools by kiegroup.
the class RightBuilder method insert.
public RightBuilder insert(Object... objects) {
for (Object object : objects) {
InternalFactHandle fh = (InternalFactHandle) wm.insert(object);
RightTuple rightTuple = new RightTupleImpl(fh, sink);
rightTuple.setPropagationContext(new PhreakPropagationContext());
rightTuples.addInsert(rightTuple);
}
return this;
}
Aggregations