public EventFactHandle clone() { EventFactHandle clone = new EventFactHandle( getId(), getObject(), getRecency(), startTimestamp, duration, getEntryPoint(), isTraitOrTraitable()); clone.activationsCount = activationsCount; clone.expired = expired; clone.setEntryPoint( getEntryPoint() ); clone.setEqualityKey( getEqualityKey() ); clone.setFirstLeftTuple(getLastLeftTuple()); clone.setLastLeftTuple(getLastLeftTuple()); clone.setFirstRightTuple(getFirstRightTuple()); clone.setLastRightTuple(getLastRightTuple()); clone.setObjectHashCode(getObjectHashCode()); clone.firstWindowTuple = firstWindowTuple; clone.lastWindowTuple = lastWindowTuple; return clone; }
public FactHandle execute(Context context) { FactHandle handle = ((QueryResultsRow) context.get( "Row - "+rowId+" - "+this.localId)).getFactHandle(identifier); if(handle instanceof DefaultFactHandle){ FactHandle disconnectedHandle = ((DefaultFactHandle)handle).clone(); ((DefaultFactHandle)disconnectedHandle).disconnect(); return disconnectedHandle; } if(handle instanceof EventFactHandle){ FactHandle disconnectedHandle = ((EventFactHandle)handle).clone(); ((EventFactHandle)disconnectedHandle).disconnect(); return disconnectedHandle; } return null; }
public void execute( final ObjectSinkPropagator sink, final InternalWorkingMemory workingMemory ) { if ( handle.isEvent() ) { (( EventFactHandle ) handle).decPendingActions(); } } }
public boolean evaluate(InternalWorkingMemory workingMemory, final InternalReadAccessor extractor1, final InternalFactHandle handle1, final InternalReadAccessor extractor2, final InternalFactHandle handle2) { if ( extractor1.isNullValue( workingMemory, handle1.getObject() ) || extractor2.isNullValue( workingMemory, handle2.getObject() ) ) { return false; } long distStart = ((EventFactHandle) handle1).getStartTimestamp() - ((EventFactHandle) handle2).getStartTimestamp(); long distEnd = Math.abs( ((EventFactHandle) handle2).getEndTimestamp() - ((EventFactHandle) handle1).getEndTimestamp() ); return this.getOperator().isNegated() ^ (distStart > 0 && distEnd <= this.endDev); }
stream.writeLong( efh.getStartTimestamp() ); stream.writeLong( efh.getDuration() ); stream.writeBoolean( efh.isExpired() ); stream.writeLong( efh.getActivationsCount() );
public void execute(InternalWorkingMemory workingMemory) { if ( this.factHandle.isValid() ) { EventFactHandle eventHandle = (EventFactHandle) factHandle; if ( eventHandle.hasPendingActions() ) { workingMemory.queueWorkingMemoryAction( this ); return; } // if the fact is still in the working memory (since it may have been previously retracted already final PropagationContext context = new PropagationContextImpl( workingMemory.getNextPropagationIdCounter(), PropagationContext.EXPIRATION, null, null, this.factHandle ); eventHandle.setExpired( true ); this.node.retractObject( factHandle, context, workingMemory ); context.evaluateActionQueue( workingMemory ); // if no activations for this expired event if ( eventHandle.getActivationsCount() == 0 ) { // remove it from the object store and clean up resources eventHandle.getEntryPoint().retract( factHandle ); } context.evaluateActionQueue( workingMemory ); } }
EventFactHandle handle = (EventFactHandle) tuple.getLastHandle(); handle.decreaseActivationsCount(); if ( handle.isExpired() ) { if ( handle.getActivationsCount() <= 0 ) { handle.getEntryPoint().retract( handle );
handle = new EventFactHandle( id, object, recency, startTimeStamp, duration, entryPoint, typeConf != null && typeConf.isTrait() ); ( (EventFactHandle) handle ).setExpired( expired ); ( (EventFactHandle) handle ).setActivationsCount( activationsCount ); break;
public boolean evaluateCachedLeft(InternalWorkingMemory workingMemory, final VariableContextEntry context, final InternalFactHandle right) { if ( context.leftNull || context.extractor.isNullValue( workingMemory, right.getObject() ) ) { return false; } long leftStartTS = ((LeftStartRightEndContextEntry) context).timestamp; long dist = Math.abs( leftStartTS - ((EventFactHandle) right).getEndTimestamp() ); return this.getOperator().isNegated() ^ (dist <= this.finalRange); }
handle = new EventFactHandle( _handle.getId(), object, _handle.getRecency(), entryPoint, typeConf != null && typeConf.isTrait() ); ((EventFactHandle) handle).setExpired( _handle.getIsExpired() );
public void decreaseActivationCountForEvents() { for ( LeftTuple entry = this; entry != null; entry = entry.getParent() ) { if( entry.getLastHandle().isEvent() ) { ((EventFactHandle)entry.getLastHandle()).decreaseActivationsCount(); } } } }
object ); return new EventFactHandle( id, object, recency,
public boolean evaluate(InternalWorkingMemory workingMemory, final InternalReadAccessor extractor1, final InternalFactHandle handle1, final InternalReadAccessor extractor2, final InternalFactHandle handle2) { if ( extractor1.isNullValue( workingMemory, handle1.getObject() ) || extractor2.isNullValue( workingMemory, handle2.getObject() ) ) { return false; } long distStart = ((EventFactHandle) handle2).getStartTimestamp() - ((EventFactHandle) handle1).getStartTimestamp(); long distEnd = Math.abs( ((EventFactHandle) handle2).getEndTimestamp() - ((EventFactHandle) handle1).getEndTimestamp() ); return this.getOperator().isNegated() ^ (distStart > 0 && distEnd <= this.endDev); }
private static ProtobufMessages.FactHandle writeFactHandle(MarshallerWriteContext context, ObjectMarshallingStrategyStore objectMarshallingStrategyStore, InternalFactHandle handle) throws IOException { ProtobufMessages.FactHandle.Builder _handle = ProtobufMessages.FactHandle.newBuilder(); _handle.setType(getHandleType(handle)); _handle.setId(handle.getId()); _handle.setRecency(handle.getRecency()); _handle.setEntryPoint( handle.getEntryPoint().getEntryPointId() ); if (_handle.getType() == ProtobufMessages.FactHandle.HandleType.EVENT) { // is event EventFactHandle efh = (EventFactHandle) handle; _handle.setTimestamp(efh.getStartTimestamp()); _handle.setDuration(efh.getDuration()); _handle.setIsExpired(efh.isExpired()); _handle.setActivationsCount(efh.getActivationsCount()); } Object object = handle.getObject(); if (object != null) { ObjectMarshallingStrategy strategy = objectMarshallingStrategyStore.getStrategyObject(object); Integer index = context.getStrategyIndex(strategy); _handle.setStrategyIndex(index.intValue()); _handle.setObject(ByteString.copyFrom(strategy.marshal(context.strategyContext.get(strategy), context, object))); } return _handle.build(); }
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory, final VariableContextEntry context, final InternalFactHandle left) { if ( context.rightNull || context.declaration.getExtractor().isNullValue( workingMemory, left.getObject() )) { return false; } long rightStartTS = ((LeftEndRightStartContextEntry)context).timestamp; long dist = Math.abs( rightStartTS - ((EventFactHandle) left).getEndTimestamp() ); return this.getOperator().isNegated() ^ ( dist <= this.finalRange ); }
public boolean evaluate(InternalWorkingMemory workingMemory, final InternalReadAccessor extractor1, final InternalFactHandle handle1, final InternalReadAccessor extractor2, final InternalFactHandle handle2) { if ( extractor1.isNullValue( workingMemory, handle1.getObject() ) || extractor2.isNullValue( workingMemory, handle2.getObject() ) ) { return false; } long distStart = Math.abs(((EventFactHandle) handle1 ).getStartTimestamp() - ((EventFactHandle) handle2 ).getStartTimestamp()); long distEnd = ((EventFactHandle) handle1 ).getEndTimestamp() - ((EventFactHandle) handle2 ).getEndTimestamp(); return this.getOperator().isNegated() ^ ( distStart <= this.startDev && distEnd > 0 ); }
public void updateFromFactHandle(final InternalWorkingMemory workingMemory, final InternalFactHandle handle) { this.object = handle.getObject(); this.workingMemory = workingMemory; if ( this.extractor.isSelfReference() ) { this.timestamp = ((EventFactHandle)handle).getEndTimestamp(); } else { this.rightNull = this.extractor.isNullValue( workingMemory, handle.getObject()); if ( !rightNull ) { // avoid a NullPointerException this.timestamp = this.extractor.getLongValue( workingMemory, handle.getObject() ); } else { this.timestamp = 0; } } } }
public boolean evaluate(InternalWorkingMemory workingMemory, final InternalReadAccessor extractor1, final InternalFactHandle handle1, final InternalReadAccessor extractor2, final InternalFactHandle handle2) { if ( extractor1.isNullValue( workingMemory, handle1.getObject() ) || extractor2.isNullValue( workingMemory, handle2.getObject() ) ) { return false; } long distStart = Math.abs( ((EventFactHandle) handle1).getStartTimestamp() - ((EventFactHandle) handle2).getStartTimestamp() ); long distEnd = ((EventFactHandle) handle2).getEndTimestamp() - ((EventFactHandle) handle1).getEndTimestamp(); return this.getOperator().isNegated() ^ (distStart <= this.startDev && distEnd > 0 ); }
public boolean evaluateCachedLeft(InternalWorkingMemory workingMemory, final VariableContextEntry context, final InternalFactHandle right) { if ( context.leftNull || context.extractor.isNullValue( workingMemory, right.getObject() ) ) { return false; } long leftTS = ((LeftStartRightEndContextEntry)context).timestamp; long rightTS; if ( context.getFieldExtractor().isSelfReference() ) { rightTS = ((EventFactHandle) right).getEndTimestamp(); } else { rightTS = context.getFieldExtractor().getLongValue( workingMemory, right.getObject() ); } long dist = leftTS - rightTS; return this.getOperator().isNegated() ^ (dist >= this.initRange && dist <= this.finalRange); }
public boolean evaluate(InternalWorkingMemory workingMemory, final InternalReadAccessor extractor1, final InternalFactHandle handle1, final InternalReadAccessor extractor2, final InternalFactHandle handle2) { if ( extractor1.isNullValue( workingMemory, handle1.getObject() ) || extractor2.isNullValue( workingMemory, handle2.getObject() ) ) { return false; } long distStart = ((EventFactHandle) handle1).getStartTimestamp() - ((EventFactHandle) handle2).getStartTimestamp(); long distEnd = ((EventFactHandle) handle2).getEndTimestamp() - ((EventFactHandle) handle1).getEndTimestamp(); return this.getOperator().isNegated() ^ (distStart >= this.startMinDev && distStart <= this.startMaxDev && distEnd >= this.endMinDev && distEnd <= this.endMaxDev); }