@Test public void testStringData3() { final int count = 100000; final ObjectHashMap map = new ObjectHashMap(); assertNotNull( map ); for ( int idx = 0; idx < count; idx++ ) { final String key = "key" + idx; final String strval = "value" + idx; map.put( key, strval ); } final long start = System.currentTimeMillis(); for ( int idx = 0; idx < count; idx++ ) { final String key = "key" + idx; map.get( key ); } final long end = System.currentTimeMillis(); System.out.println( "Custom ObjectHashMap get(key) ET - " + ((end - start)) ); }
@Test public void testIntegerData() { final ObjectHashMap map = new ObjectHashMap(); assertNotNull( map ); final int count = 1000; for ( int idx = 0; idx < count; idx++ ) { final Integer key = new Integer( idx ); final Integer val = new Integer( idx ); map.put( key, val ); assertEquals( val, map.get( key ) ); } }
public InternalFactHandle getHandleForObject(Object object){ if ( object == null ) { return null; } else { return (InternalFactHandle) this.assertMap.get( object ); } }
public EqualityKey get(final EqualityKey key) { return (EqualityKey) this.assertMap.get( key ); }
public InternalFactHandle reconnect(FactHandle factHandle) { return (InternalFactHandle) this.assertMap.get( factHandle ); }
public InternalFactHandle getHandleForObjectIdentity(Object object) { return (InternalFactHandle) this.identityMap.get( object ); }
public EqualityKey get(final Object object) { return (EqualityKey) this.assertMap.get( object ); }
@Test public void testStringData() { final ObjectHashMap map = new ObjectHashMap(); assertNotNull( map ); final int count = 1000; for ( int idx = 0; idx < count; idx++ ) { final String key = "key" + idx; final String val = "value" + idx; map.put( key, val ); assertEquals( val, map.get( key ) ); } }
@Test public void testStringDataDupFalse() { final ObjectHashMap map = new ObjectHashMap(); assertNotNull( map ); final int count = 10000; for ( int idx = 0; idx < count; idx++ ) { final String key = "key" + idx; final String val = "value" + idx; map.put( key, val, false ); assertEquals( val, map.get( key ) ); } }
public Object getObjectForHandle(FactHandle handle) { try { this.lock.lock(); // Make sure the FactHandle is from this WorkingMemory final InternalFactHandle internalHandle = (InternalFactHandle) this.assertMap.get( handle ); if ( internalHandle == null ) { return null; } Object object = internalHandle.getObject(); return object; } finally { this.lock.unlock(); } }
public void removeLogicalDependency(final Activation activation, final LogicalDependency node, final PropagationContext context) { final InternalFactHandle handle = (InternalFactHandle) node.getJustified(); final BeliefSet beliefSet = (BeliefSet) this.justifiedMap.get( handle.getId() ); if ( beliefSet != null ) { beliefSystem.delete( node, beliefSet, context ); } }
public void modifyLeftTuple(LeftTuple leftTuple, PropagationContext context, InternalWorkingMemory workingMemory) { final RIAMemory memory = (RIAMemory) workingMemory.getNodeMemory( this ); // add it to a memory mapping InternalFactHandle handle = (InternalFactHandle) memory.memory.get( leftTuple ); // propagate it for ( RightTuple rightTuple = handle.getFirstRightTuple(); rightTuple != null; rightTuple = (RightTuple) rightTuple.getHandleNext() ) { rightTuple.getRightTupleSink().modifyRightTuple( rightTuple, context, workingMemory ); } }
public LogicalRetractCallback(MarshallerReaderContext context) throws IOException { this.tms = context.wm.getTruthMaintenanceSystem(); this.handle = context.handles.get( context.readInt() ); this.context = context.propagationContexts.get( context.readLong() ); this.activation = (Activation) context.terminalTupleMap.get( context.readInt() ).getObject(); this.beliefSet = (BeliefSet) this.tms.getJustifiedMap().get( handle.getId() ); for ( LinkedListEntry entry = (LinkedListEntry) beliefSet.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) { final LogicalDependency node = (LogicalDependency) entry.getObject(); if ( node.getJustifier() == this.activation ) { this.node = node; break; } } }
public LogicalRetractCallback(MarshallerReaderContext context, Action _action) { LogicalRetract _retract = _action.getLogicalRetract(); this.tms = context.wm.getTruthMaintenanceSystem(); this.handle = context.handles.get( _retract.getHandleId() ); this.activation = (Activation) context.filter .getTuplesCache().get( PersisterHelper.createActivationKey( _retract.getActivation().getPackageName(), _retract.getActivation().getRuleName(), _retract.getActivation().getTuple() ) ).getObject(); this.context = this.activation.getPropagationContext(); this.beliefSet = (BeliefSet) this.tms.getJustifiedMap().get( handle.getId() ); for ( LinkedListEntry entry = (LinkedListEntry) beliefSet.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) { final LogicalDependency node = (LogicalDependency) entry.getObject(); if ( node.getJustifier() == this.activation ) { this.node = node; break; } } }
public void addLogicalDependency(final InternalFactHandle handle, final Object value, final Activation activation, final PropagationContext context, final Rule rule, final ObjectTypeConf typeConf, final boolean read) throws FactException { final LogicalDependency node = beliefSystem.newLogicalDependency( activation, handle, value ); activation.getRule().setHasLogicalDependency( true ); activation.addLogicalDependency( node ); BeliefSet beliefSet = (BeliefSet) this.justifiedMap.get( handle.getId() ); if ( beliefSet == null ) { if ( context.getType() == PropagationContext.MODIFICATION ) { // if this was a update, chances are its trying to retract a logical assertion } beliefSet = beliefSystem.newBeliefSet(); this.justifiedMap.put( handle.getId(), beliefSet ); } if ( read ) { // used when deserialising beliefSystem.read( node, beliefSet, context, typeConf ); } else { beliefSystem.insert( node, beliefSet, context, typeConf ); } }
object, fieldIndex.getFieldExtractor() ); final AlphaNode sink = (AlphaNode) this.hashedSinkMap.get( hashKey ); if ( sink != null ) {
object, fieldIndex.getFieldExtractor() ); final AlphaNode sink = (AlphaNode) this.hashedSinkMap.get( hashKey ); if ( sink != null ) {
object, fieldIndex.getFieldExtractor() ); final AlphaNode sink = (AlphaNode) this.hashedSinkMap.get( hashKey ); if ( sink != null ) {