public RegexPartitionState GetState(EventBean theEvent, bool isCollect) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QRegExPartition(_meta.PartitionExpressionNodes); } // collect unused states if ((isCollect) && (_states.Count >= _currentCollectionSize)) { IList <Object> removeList = new List <Object>(); foreach (var entry in _states) { if ((entry.Value.IsEmptyCurrentState) && (entry.Value.RandomAccess == null || entry.Value.RandomAccess.IsEmpty)) { removeList.Add(entry.Key); } } foreach (var removeKey in removeList) { _states.Remove(removeKey); } if (removeList.Count < (_currentCollectionSize / 5)) { _currentCollectionSize *= 2; } } var key = GetKeys(theEvent, _meta); var state = _states.Get(key); if (state != null) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().ARegExPartition(true, state); } return(state); } state = new RegexPartitionStateImpl(_getter, new List <RegexNFAStateEntry>(), key); _states.Put(key, state); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().ARegExPartition(false, state); } return(state); }
/// <summary> /// Ctor. /// </summary> /// <param name="getter">The getter.</param> /// <param name="keepScheduleState">if set to <c>true</c> [keep schedule state].</param> /// <param name="terminationStateCompare">The termination state compare.</param> public RegexPartitionStateRepoNoGroup(RegexPartitionStateRandomAccessGetter getter, bool keepScheduleState, RegexPartitionTerminationStateComparator terminationStateCompare) { _singletonState = new RegexPartitionStateImpl(getter, new List <RegexNFAStateEntry>()); _optionalIntervalSchedules = keepScheduleState ? new RegexPartitionStateRepoScheduleStateImpl(terminationStateCompare) : null; }
/// <summary> /// Copy state for iteration. /// </summary> /// <param name="forOutOfOrderReprocessing">For out of order reprocessing.</param> /// <returns></returns> public RegexPartitionStateRepo CopyForIterate(bool forOutOfOrderReprocessing) { var state = new RegexPartitionStateImpl(_singletonState.RandomAccess, null); return(new RegexPartitionStateRepoNoGroup(state)); }
/// <summary> /// Ctor. /// </summary> /// <param name="singletonState">state</param> public RegexPartitionStateRepoNoGroup(RegexPartitionStateImpl singletonState) { _singletonState = singletonState; _optionalIntervalSchedules = null; }