final FieldIndex fieldIndex = new FieldIndex( extractor,
declaration,
equals.getEvaluator( ValueType.STRING_TYPE,
Operator.EQUAL ) );
final ConcurrentHashTable map = new ConcurrentHashTable( new FieldIndex[]{fieldIndex} );
assertEquals( 0,
map.size() );
final Cheese stilton1 = new Cheese( "stilton",
35 );
final InternalFactHandle stiltonHandle1 = new DefaultFactHandle( 1,
stilton1 );
map.add( new RightTuple( stiltonHandle1,
null ) );
final Cheese cheddar1 = new Cheese( "cheddar",
35 );
final InternalFactHandle cheddarHandle1 = new DefaultFactHandle( 2,
cheddar1 );
map.add( new RightTuple( cheddarHandle1,
null ) );
final Cheese stilton2 = new Cheese( "stilton",
81 );
final InternalFactHandle stiltonHandle2 = new DefaultFactHandle( 3,
stilton2 );
map.add( new RightTuple( stiltonHandle2,
null ) );
assertEquals( 3,
map.size() );
// Check they are correctly chained to the same FieldIndexEntry
final Cheese stilton3 = new Cheese( "stilton",
89 );
final InternalFactHandle stiltonHandle3 = new DefaultFactHandle( 4,
stilton2 );
final RightTupleList list = map.get( new LeftTupleImpl( stiltonHandle3,
null,
true ), stiltonHandle3 );
assertSame( stiltonHandle1,
list.first.getFactHandle() );
assertSame( stiltonHandle2,