if ( stream.readBoolean() ) {
InternalFactHandle initialFactHandle = wm.getInitialFactHandle();
int sinkId = stream.readInt();
ObjectTypeNode initialFactNode = (ObjectTypeNode) context.sinks.get( sinkId );
ObjectHashSet initialFactMemory = (ObjectHashSet) context.wm.getNodeMemory( initialFactNode );
initialFactMemory.add( initialFactHandle );
readRightTuples( initialFactHandle,
context );
}
int size = stream.readInt();
// load the handles
InternalFactHandle[] handles = new InternalFactHandle[size];
for ( int i = 0; i < size; i++ ) {
InternalFactHandle handle = readFactHandle( context );
context.handles.put( handle.getId(),
handle );
handles[i] = handle;
context.wm.getObjectStore().addHandle( handle,
handle.getObject() );
readRightTuples( handle,
context );
}
EntryPointNode node = ruleBase.getRete().getEntryPointNode( EntryPoint.DEFAULT );
Map<ObjectType, ObjectTypeNode> objectTypeNodes = node.getObjectTypeNodes();
// add handles to object type nodes
for ( InternalFactHandle handle : handles ) {
Object object = handle.getObject();
ClassObjectType objectType = new ClassObjectType( object.getClass() );
ObjectTypeNode objectTypeNode = objectTypeNodes.get( objectType );
if (objectTypeNode != null) {
ObjectHashSet set = (ObjectHashSet) context.wm.getNodeMemory( objectTypeNode );
set.add( handle,
false );
}
}
InternalFactHandle handle = wm.getInitialFactHandle();