public void TestRecursiveBuild() { var streamNum = 2; var queryGraph = new QueryGraph(6, null, false); var outerInnerGraph = new OuterInnerDirectionalGraph(6); var completedStreams = new HashSet <int>(); var substreamsPerStream = new LinkedHashMap <int, int[]>(); var requiredPerStream = new bool[6]; outerInnerGraph.Add(3, 2).Add(2, 1).Add(4, 3).Add(1, 0).Add(3, 5); queryGraph.AddStrictEquals(2, "", null, 3, "", null); queryGraph.AddStrictEquals(3, "", null, 4, "", null); queryGraph.AddStrictEquals(3, "", null, 5, "", null); queryGraph.AddStrictEquals(2, "", null, 1, "", null); queryGraph.AddStrictEquals(1, "", null, 0, "", null); ICollection <InterchangeablePair <int, int> > innerJoins = new HashSet <InterchangeablePair <int, int> >(); var innerJoinGraph = new InnerJoinGraph(6, innerJoins); var streamStack = new Stack <int>(); NStreamOuterQueryPlanBuilder.RecursiveBuild(streamNum, streamStack, queryGraph, outerInnerGraph, innerJoinGraph, completedStreams, substreamsPerStream, requiredPerStream, new DependencyGraph(6, false)); Assert.AreEqual(6, substreamsPerStream.Count); EPAssertionUtil.AssertEqualsExactOrder(substreamsPerStream[2], new int[] { 3, 1 }); EPAssertionUtil.AssertEqualsExactOrder(substreamsPerStream.Get(3), new int[] { 4, 5 }); EPAssertionUtil.AssertEqualsExactOrder(substreamsPerStream[1], new int[] { 0 }); EPAssertionUtil.AssertEqualsExactOrder(substreamsPerStream.Get(4), new int[] {}); EPAssertionUtil.AssertEqualsExactOrder(substreamsPerStream.Get(5), new int[] {}); EPAssertionUtil.AssertEqualsExactOrder(substreamsPerStream[0], new int[] {}); NStreamOuterQueryPlanBuilder.VerifyJoinedPerStream(2, substreamsPerStream); EPAssertionUtil.AssertEqualsExactOrder(requiredPerStream, new bool[] { false, false, false, true, true, false } ); }
private static MatchEventSpec AnalyzeMatchEvent(EvalFactoryNode relativeNode) { var taggedEventTypes = new LinkedHashMap <string, Pair <EventType, string> >(); var arrayEventTypes = new LinkedHashMap <string, Pair <EventType, string> >(); // Determine all the filter nodes used in the pattern var evalNodeAnalysisResult = EvalNodeUtil.RecursiveAnalyzeChildNodes(relativeNode); // collect all filters underneath foreach (var filterNode in evalNodeAnalysisResult.FilterNodes) { var optionalTag = filterNode.EventAsName; if (optionalTag != null) { taggedEventTypes.Put( optionalTag, new Pair <EventType, string>( filterNode.FilterSpec.FilterForEventType, filterNode.FilterSpec.FilterForEventTypeName)); } } // collect those filters under a repeat since they are arrays var arrayTags = new HashSet <string>(); foreach (var matchUntilNode in evalNodeAnalysisResult.RepeatNodes) { var matchUntilAnalysisResult = EvalNodeUtil.RecursiveAnalyzeChildNodes(matchUntilNode.ChildNodes[0]); foreach (var filterNode in matchUntilAnalysisResult.FilterNodes) { var optionalTag = filterNode.EventAsName; if (optionalTag != null) { arrayTags.Add(optionalTag); } } } // for each array tag change collection foreach (var arrayTag in arrayTags) { if (taggedEventTypes.Get(arrayTag) != null) { arrayEventTypes.Put(arrayTag, taggedEventTypes.Get(arrayTag)); taggedEventTypes.Remove(arrayTag); } } return(new MatchEventSpec(taggedEventTypes, arrayEventTypes)); }
public IPrefetchHandle Union(IPrefetchHandle otherPrefetchHandle) { if (otherPrefetchHandle == null) { return(this); } LinkedHashMap <Type, CHashSet <AppendableCachePath> > newMap = LinkedHashMap <Type, CHashSet <AppendableCachePath> > .Create(entityTypeToPrefetchSteps.Count); foreach (Entry <Type, PrefetchPath[]> entry in entityTypeToPrefetchSteps) { CHashSet <AppendableCachePath> prefetchPaths = newMap.Get(entry.Key); if (prefetchPaths == null) { prefetchPaths = new CHashSet <AppendableCachePath>(); newMap.Put(entry.Key, prefetchPaths); } foreach (PrefetchPath cachePath in entry.Value) { prefetchPaths.Add(cachePathHelper.CopyCachePathToAppendable(cachePath)); } } foreach (Entry <Type, PrefetchPath[]> entry in ((PrefetchHandle)otherPrefetchHandle).entityTypeToPrefetchSteps) { CHashSet <AppendableCachePath> prefetchPaths = newMap.Get(entry.Key); if (prefetchPaths == null) { prefetchPaths = new CHashSet <AppendableCachePath>(); newMap.Put(entry.Key, prefetchPaths); } foreach (PrefetchPath cachePath in entry.Value) { AppendableCachePath clonedCachePath = cachePathHelper.CopyCachePathToAppendable(cachePath); if (prefetchPaths.Add(clonedCachePath)) { continue; } AppendableCachePath existingCachePath = prefetchPaths.Get(clonedCachePath); cachePathHelper.UnionCachePath(existingCachePath, clonedCachePath); } } LinkedHashMap <Type, PrefetchPath[]> targetMap = LinkedHashMap <Type, PrefetchPath[]> .Create(newMap.Count); foreach (Entry <Type, CHashSet <AppendableCachePath> > entry in newMap) { PrefetchPath[] cachePaths = cachePathHelper.CopyAppendableToCachePath(entry.Value); targetMap.Put(entry.Key, cachePaths); } return(new PrefetchHandle(targetMap, cachePathHelper)); }
public object EvaluateEnumMethod( EventBean[] eventsLambda, ICollection<object> enumcoll, bool isNewData, ExprEvaluatorContext context) { if (enumcoll.IsEmpty()) { return null; } IDictionary<object, int> items = new LinkedHashMap<object, int>(); var beans = (ICollection<EventBean>) enumcoll; foreach (var next in beans) { eventsLambda[forge.StreamNumLambda] = next; var item = innerExpression.Evaluate(eventsLambda, isNewData, context); int? existing = items.Get(item); if (existing == null) { existing = 1; } else { existing++; } items.Put(item, existing.Value); } return GetEnumMostLeastFrequentResult(items, forge.isMostFrequent); }
public Object EvaluateEnumMethod(EventBean[] eventsLambda, ICollection <object> target, bool isNewData, ExprEvaluatorContext context) { var result = new LinkedHashMap <object, ICollection <object> >(); var resultEvent = new ObjectArrayEventBean(new Object[1], _resultEventType); var values = target; foreach (Object next in values) { resultEvent.Properties[0] = next; eventsLambda[StreamNumLambda] = resultEvent; var key = InnerExpression.Evaluate(new EvaluateParams(eventsLambda, isNewData, context)); resultEvent.Properties[0] = next; var entry = _secondExpression.Evaluate(new EvaluateParams(eventsLambda, isNewData, context)); var value = result.Get(key); if (value == null) { value = new List <object>(); result.Put(key, value); } value.Add(entry); } return(result); }
public object EvaluateEnumMethod( EventBean[] eventsLambda, ICollection<object> enumcoll, bool isNewData, ExprEvaluatorContext context) { if (enumcoll.IsEmpty()) { return null; } IDictionary<object, int> items = new LinkedHashMap<object, int>(); foreach (var next in enumcoll) { int? existing = items.Get(next); if (existing == null) { existing = 1; } else { existing++; } items.Put(next, existing.Value); } return EnumMostLeastFrequentEventForgeEval.GetEnumMostLeastFrequentResult(items, _isMostFrequent); }
public override void Unregister(V extension, Type key) { Object writeLock = GetWriteLock(); lock (writeLock) { base.Unregister(extension, key); ClassEntry <V> classEntry = CopyStructure(); LinkedHashMap <StrongKey <V>, List <DefEntry <V> > > definitionReverseMap = classEntry.definitionReverseMap; List <DefEntry <V> > weakEntriesOfStrongType = definitionReverseMap.Remove(new StrongKey <V>(extension, key)); if (weakEntriesOfStrongType == null) { return; } LinkedHashMap <Type, Object> typeToDefEntryMap = classEntry.typeToDefEntryMap; for (int a = weakEntriesOfStrongType.Count; a-- > 0;) { DefEntry <V> defEntry = weakEntriesOfStrongType[a]; Type registeredType = defEntry.type; Object value = typeToDefEntryMap.Get(registeredType); InterfaceFastList <DefEntry <V> > list = (InterfaceFastList <DefEntry <V> >)value; list.Remove(defEntry); if (list.Count == 0) { typeToDefEntryMap.Remove(registeredType); } TypeToDefEntryMapChanged(classEntry, registeredType); } this.classEntry = classEntry; } }
/// <summary> /// Returns the property sheet for the given object instance /// </summary> /// <param name="instanceName"></param> /// <returns></returns> public PropertySheet GetPropertySheet(String instanceName) { if (!_symbolTable.ContainsKey(instanceName)) { // if it is not in the symbol table, so construct // it based upon our raw property data RawPropertyData rpd = null; if (_rawPropertyMap.ContainsKey(instanceName)) { rpd = _rawPropertyMap[instanceName]; } if (rpd != null) { var className = rpd.ClassName; try { // now load the property-sheet by using the class annotation var propertySheet = new PropertySheet(Type.GetType(className, true), instanceName, this, rpd); _symbolTable.Put(instanceName, propertySheet); } catch (Exception) { Trace.Fail(string.Format("Class '{0}' not found in Assembly '{1}'", className, Assembly.GetCallingAssembly())); throw; } } } return(_symbolTable.Get(instanceName)); }
public object EvaluateEnumMethod( EventBean[] eventsLambda, ICollection<object> enumcoll, bool isNewData, ExprEvaluatorContext context) { if (enumcoll.IsEmpty()) { return Collections.GetEmptyMap<object, object>(); } IDictionary<object, ICollection<object>> result = new LinkedHashMap<object, ICollection<object>>(); var beans = (ICollection<EventBean>) enumcoll; foreach (var next in beans) { eventsLambda[_forge.StreamNumLambda] = next; var key = _innerExpression.Evaluate(eventsLambda, isNewData, context); var entry = _secondExpression.Evaluate(eventsLambda, isNewData, context); var value = result.Get(key); if (value == null) { value = new List<object>(); result.Put(key, value); } value.Add(entry); } return result; }
public object EvaluateEnumMethod( EventBean[] eventsLambda, ICollection<object> enumcoll, bool isNewData, ExprEvaluatorContext context) { if (enumcoll.IsEmpty()) { return Collections.GetEmptyMap<object, object>(); } IDictionary<object, ICollection<object>> result = new LinkedHashMap<object, ICollection<object>>(); var values = (ICollection<object>) enumcoll; var resultEvent = new ObjectArrayEventBean(new object[1], _forge.resultEventType); eventsLambda[_forge.StreamNumLambda] = resultEvent; var props = resultEvent.Properties; foreach (var next in values) { props[0] = next; var key = _innerExpression.Evaluate(eventsLambda, isNewData, context); var value = result.Get(key); if (value == null) { value = new List<object>(); result.Put(key, value); } value.Add(next); } return result; }
public object EvaluateEnumMethod( EventBean[] eventsLambda, ICollection<object> enumcoll, bool isNewData, ExprEvaluatorContext context) { if (enumcoll.IsEmpty()) { return null; } IDictionary<object, int> items = new LinkedHashMap<object, int>(); var values = (ICollection<object>) enumcoll; var resultEvent = new ObjectArrayEventBean(new object[1], _forge.resultEventType); eventsLambda[_forge.StreamNumLambda] = resultEvent; var props = resultEvent.Properties; foreach (var next in values) { props[0] = next; var item = _innerExpression.Evaluate(eventsLambda, isNewData, context); int? existing = items.Get(item); if (existing == null) { existing = 1; } else { existing++; } items.Put(item, existing.Value); } return EnumMostLeastFrequentEventForgeEval.GetEnumMostLeastFrequentResult(items, _forge.isMostFrequent); }
private ICollection <IList <Query.Row> > CombineJoins(IList <Query.Row> joins) { // combine joins with the same to/from tables IDictionary <IList <string>, IList <Query.Row> > comboJoinMap = new LinkedHashMap <IList <string>, IList <Query.Row> >(); foreach (Query.Row join in joins) { IList <string> key = Arrays.AsList(join.name1, join.name2); IList <Query.Row> comboJoins = comboJoinMap.Get(key); if (comboJoins == null) { comboJoins = new AList <Query.Row>(); comboJoinMap.Put(key, comboJoins); } else { if ((short)comboJoins[0].flag != (short)join.flag) { throw new InvalidOperationException("Mismatched join flags for combo joins"); } } comboJoins.AddItem(join); } return(comboJoinMap.Values); }
/// <summary> /// Retrieves an entry from the cache. /// The retrieved entry becomes the MRU (most recently used) entry. /// </summary> /// <param name="methodParams">the key whose associated value is to be returned.</param> /// <returns>the value associated to this key, or null if no value with this key exists in the cache.</returns> public EventTable[] GetCached(object methodParams) { lock (this) { var key = methodParams; return(cache.Get(key)); } }
public void GivenASentence_WheAddedToHashTable_ShouldReturnWordFrequency() { string sentence = "to be or not to be"; string[] words = sentence.ToLower().Split(" "); foreach (string word in words) { int value = LinkedHashMap.Get(word); if (value == default) { value = 1; } else value += 1; LinkedHashMap.Add(word, value); } int frequency = LinkedHashMap.Get("to"); Console.WriteLine(LinkedHashMap); Assert.AreEqual(2, frequency); }
public void AddNamedBean(String beanName, Object bean) { CheckNotDisposed(); CheckNotRunning(); ParamChecker.AssertParamNotNull(beanName, "beanName"); ParamChecker.AssertParamNotNull(bean, "bean"); if (nameToServiceDict == null) { nameToServiceDict = new LinkedHashMap <String, Object>(); } if (nameToServiceDict.ContainsKey(beanName)) { throw CreateDuplicateBeanNameException(beanName, bean, nameToServiceDict.Get(beanName)); } if (beanName.Contains("&") || beanName.Contains("*") || beanName.Contains(" ") || beanName.Contains("\t")) { throw new ArgumentException("Bean name '" + beanName + "' must not contain any of the following characters: '&', '*' or any whitespace"); } nameToServiceDict.Put(beanName, bean); }
public void ApplyEnter(EventBean[] eventsPerStream, ExprEvaluatorContext exprEvaluatorContext) { var theEvent = eventsPerStream[StreamId]; if (theEvent == null) { return; } _array = null; var value = RefSet.Get(theEvent); if (value == null) { RefSet.Put(theEvent, 1); return; } value++; RefSet.Put(theEvent, value); }
private void TrySend(int numThreads, int numRepeats) { var threadPool = Executors.NewFixedThreadPool(numThreads); var future = new Future <bool> [numThreads]; for (int i = 0; i < numThreads; i++) { var callable = new StmtInsertIntoCallable(Convert.ToString(i), _engine, numRepeats); future[i] = threadPool.Submit(callable); } threadPool.Shutdown(); threadPool.AwaitTermination(TimeSpan.FromSeconds(10)); for (int i = 0; i < numThreads; i++) { Assert.IsTrue(future[i].GetValueOrDefault()); } // Assert results int totalExpected = numThreads * numRepeats * 2; EventBean[] result = _listener.GetNewDataListFlattened(); Assert.AreEqual(totalExpected, result.Length); var results = new LinkedHashMap <long, ICollection <String> >(); foreach (EventBean theEvent in result) { var count = theEvent.Get("mycount").AsLong(); var key = (String)theEvent.Get("key"); ICollection <String> entries = results.Get(count); if (entries == null) { entries = new HashSet <String>(); results.Put(count, entries); } entries.Add(key); } Assert.AreEqual(numRepeats, results.Count); foreach (ICollection <String> value in results.Values) { Assert.AreEqual(2 * numThreads, value.Count); for (int i = 0; i < numThreads; i++) { Assert.IsTrue(value.Contains("E1_" + i)); Assert.IsTrue(value.Contains("E2_" + i)); } } _listener.Reset(); }
private void TrySend(EPServiceProvider epService, SupportMTUpdateListener listener, int numThreads, int numRepeats) { var threadPool = Executors.NewFixedThreadPool(numThreads); var future = new Future <bool> [numThreads]; for (int i = 0; i < numThreads; i++) { var callable = new StmtInsertIntoCallable(Convert.ToString(i), epService, numRepeats); future[i] = threadPool.Submit(callable); } threadPool.Shutdown(); threadPool.AwaitTermination(10, TimeUnit.SECONDS); for (int i = 0; i < numThreads; i++) { Assert.IsTrue(future[i].GetValueOrDefault()); } // Assert results int totalExpected = numThreads * numRepeats * 2; EventBean[] result = listener.GetNewDataListFlattened(); Assert.AreEqual(totalExpected, result.Length); var results = new LinkedHashMap <long, ISet <string> >(); foreach (EventBean theEvent in result) { long count = (long)theEvent.Get("mycount"); string key = (string)theEvent.Get("key"); ISet <string> entries = results.Get(count); if (entries == null) { entries = new HashSet <string>(); results.Put(count, entries); } entries.Add(key); } Assert.AreEqual(numRepeats, results.Count); foreach (ISet <string> value in results.Values) { Assert.AreEqual(2 * numThreads, value.Count); for (int i = 0; i < numThreads; i++) { Assert.IsTrue(value.Contains("E1_" + i)); Assert.IsTrue(value.Contains("E2_" + i)); } } listener.Reset(); }
private void CheckResults(PatternTestStyle testStyle, String eventId) { // For each test descriptor, make sure the listener has received exactly the events expected int index = 0; Log.Debug("CheckResults: Checking results for event " + eventId); foreach (EventExpressionCase descriptor in _caseList.Results) { String expressionText = _expressions[index].Text; LinkedHashMap <String, LinkedList <EventDescriptor> > allExpectedResults = descriptor.ExpectedResults; EventBean[] receivedResults = _listeners[index].LastNewData; index++; // If nothing at all was expected for this event, make sure nothing was received if (!(allExpectedResults.ContainsKey(eventId))) { if ((receivedResults != null) && (receivedResults.Length > 0)) { Log.Debug("CheckResults: Incorrect result for style " + testStyle + " expression : " + expressionText); Log.Debug("CheckResults: Expected no results for event " + eventId + ", but received " + receivedResults.Length + " events"); Log.Debug("CheckResults: Received, have " + receivedResults.Length + " entries"); PrintList(receivedResults); Assert.Fail(); } continue; } LinkedList <EventDescriptor> expectedResults = allExpectedResults.Get(eventId); // Compare the result lists, not caring about the order of the elements try { if (!(CompareLists(receivedResults, expectedResults))) { Log.Debug("CheckResults: Incorrect result for style " + testStyle + " expression : " + expressionText); Log.Debug("CheckResults: Expected size=" + expectedResults.Count + " received size=" + (receivedResults == null ? 0 : receivedResults.Length)); Log.Debug("CheckResults: Expected, have " + expectedResults.Count + " entries"); PrintList(expectedResults); Log.Debug("CheckResults: Received, have " + (receivedResults == null ? 0 : receivedResults.Length) + " entries"); PrintList(receivedResults); Assert.Fail(); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); Assert.Fail("For statement '" + expressionText + "' failed to assert: " + ex.Message); } } }
/// <summary> /// Returns the value for /// <code>key</code> /// if it exists in the cache or can be /// created by /// <code>#create</code> /// . If a value was returned, it is moved to the /// head of the queue. This returns null if a value is not cached and cannot /// be created. /// </summary> public V Get(K key) { if (key == null) { throw new ArgumentNullException("key == null"); } V mapValue; lock (locker) { mapValue = map.Get(key); if (mapValue != null) { hitCount++; return(mapValue); } missCount++; } V createdValue = Create(key); if (createdValue == null) { return(default(V)); } lock (locker) { createCount++; mapValue = map.Put(key, createdValue); if (mapValue != null) { // There was a conflict so undo that last put map[key] = mapValue; } else { size += SafeSizeOf(key, createdValue); } } if (mapValue != null) { EntryRemoved(false, key, createdValue, mapValue); return(mapValue); } else { TrimToSize(maxSize); return(createdValue); } }
private EventDescriptor AddDesc(String expectedOnEventId) { LinkedList <EventDescriptor> resultList = expectedResults.Get(expectedOnEventId); if (resultList == null) { resultList = new LinkedList <EventDescriptor>(); expectedResults.Put(expectedOnEventId, resultList); } EventDescriptor eventDesc = new EventDescriptor(); resultList.AddLast(eventDesc); return(eventDesc); }
public static IList <OccuranceBucket> RecursiveAnalyze( IList <Pair <long, EventBean[]> > occurances, long[] granularities, int level, long start, long end) { // form buckets var granularity = granularities[level]; IDictionary <int, OccuranceIntermediate> intermediates = new LinkedHashMap <int, OccuranceIntermediate>(); var countBucket = 0; for (var offset = start; offset < end; offset += granularity) { var intermediate = new OccuranceIntermediate(offset, offset + granularity - 1); intermediates.Put(countBucket, intermediate); countBucket++; } // sort into bucket foreach (var entry in occurances) { long time = entry.First; var delta = time - start; var bucket = (int)(delta / granularity); var intermediate = intermediates.Get(bucket); intermediate.Items.Add(entry); } // report each bucket IList <OccuranceBucket> buckets = new List <OccuranceBucket>(); foreach (KeyValuePair <int, OccuranceIntermediate> pair in intermediates) { var inter = pair.Value; var bucket = GetBucket(inter); buckets.Add(bucket); // for buckets within buckets if (level < granularities.Length - 1 && !inter.Items.IsEmpty()) { bucket.InnerBuckets = RecursiveAnalyze(inter.Items, granularities, level + 1, inter.Low, inter.High); } } return(buckets); }
private static void AddNotYetNavigated( int streamNo, int numStreams, LinkedHashMap <int, int[]> substreamsPerStream, NStreamQueryPlanBuilder.BestChainResult bestChain) { // sum up all substreams (the query plan for each stream: nested iteration or cardinal) ISet <int> streams = new HashSet <int>(); streams.Add(streamNo); RecursiveAdd(streamNo, streamNo, substreamsPerStream, streams, false); // we are done, all have navigated if (streams.Count == numStreams) { return; } var previous = streamNo; foreach (var stream in bestChain.Chain) { if (streams.Contains(stream)) { previous = stream; continue; } // add node as a nested join to the previous stream var substreams = substreamsPerStream.Get(previous); if (substreams == null) { substreams = new int[0]; } var added = CollectionUtil.AddValue(substreams, stream); substreamsPerStream.Put(previous, added); if (!substreamsPerStream.ContainsKey(stream)) { substreamsPerStream.Put(stream, new int[0]); } previous = stream; } }
/// <summary>Analyze multiple event types and determine common property sets that form property groups. </summary> /// <param name="allProperties">property names to look at</param> /// <param name="deltaEventTypes">all types contributing</param> /// <param name="names">names of properies</param> /// <returns>groups</returns> public static PropertyGroupDesc[] AnalyzeGroups(String[] allProperties, EventType[] deltaEventTypes, String[] names) { if (deltaEventTypes.Length != names.Length) { throw new ArgumentException("Delta event type number and name number of elements don't match"); } allProperties = CopyAndSort(allProperties); var result = new LinkedHashMap <MultiKey <String>, PropertyGroupDesc>(); var currentGroupNum = 0; for (int i = 0; i < deltaEventTypes.Length; i++) { MultiKey <String> props = GetPropertiesContributed(deltaEventTypes[i], allProperties); if (props.Array.Length == 0) { Log.Warn("Event type named '" + names[i] + "' does not contribute (or override) any properties of the revision event type"); continue; } PropertyGroupDesc propertyGroup = result.Get(props); IDictionary <EventType, String> typesForGroup; if (propertyGroup == null) { typesForGroup = new Dictionary <EventType, String>(); propertyGroup = new PropertyGroupDesc(currentGroupNum++, typesForGroup, props.Array); result.Put(props, propertyGroup); } else { typesForGroup = propertyGroup.Types; } typesForGroup.Put(deltaEventTypes[i], names[i]); } PropertyGroupDesc[] array = Collections.ToArray(result.Values); if (Log.IsDebugEnabled) { Log.Debug(".analyzeGroups " + array.Render()); } return(array); }
private IDictionary <int, IList <String> > SortPerIntKey(EventBean[] result) { IDictionary <int, IList <String> > results = new LinkedHashMap <int, IList <String> >(); foreach (EventBean theEvent in result) { var count = (int)theEvent.Get("IntPrimitive"); var key = (String)theEvent.Get("key"); var entries = results.Get(count); if (entries == null) { entries = new List <String>(); results.Put(count, entries); } entries.Add(key); } return(results); }
protected bool AppendRegistration(Type strongType, Type type, V extension, int distance, ClassEntry <V> classEntry) { LinkedHashMap <Type, Object> typeToDefEntryMap = classEntry.typeToDefEntryMap; Object fastList = typeToDefEntryMap.Get(type); if (fastList != null && !Object.ReferenceEquals(fastList, alreadyHandled)) { IListElem <DefEntry <V> > pointer = ((InterfaceFastList <DefEntry <V> >)fastList).First; while (pointer != null) { DefEntry <V> existingDefEntry = pointer.ElemValue; if (Object.ReferenceEquals(existingDefEntry.extension, extension) && existingDefEntry.distance == distance) { // DefEntry already exists with same distance return(false); } pointer = pointer.Next; } } if (fastList == null || Object.ReferenceEquals(fastList, alreadyHandled)) { fastList = new InterfaceFastList <DefEntry <V> >(); typeToDefEntryMap.Put(type, fastList); } DefEntry <V> defEntry = new DefEntry <V>(extension, type, distance); LinkedHashMap <StrongKey <V>, List <DefEntry <V> > > definitionReverseMap = classEntry.definitionReverseMap; StrongKey <V> strongKey = new StrongKey <V>(extension, strongType); List <DefEntry <V> > typeEntries = definitionReverseMap.Get(strongKey); if (typeEntries == null) { typeEntries = new List <DefEntry <V> >(); definitionReverseMap.Put(strongKey, typeEntries); } typeEntries.Add(defEntry); InterfaceFastList <DefEntry <V> > .InsertOrdered((InterfaceFastList <DefEntry <V> >) fastList, defEntry); TypeToDefEntryMapChanged(classEntry, type); return(true); }
public Object EvaluateEnumMethod(EventBean[] eventsLambda, ICollection <object> target, bool isNewData, ExprEvaluatorContext context) { var result = new LinkedHashMap <Object, ICollection <object> >(); foreach (EventBean next in target) { eventsLambda[StreamNumLambda] = next; var key = InnerExpression.Evaluate(new EvaluateParams(eventsLambda, isNewData, context)); var value = result.Get(key); if (value == null) { value = new List <object>(); result.Put(key, value); } value.Add(next.Underlying); } return(result); }
public object EvaluateEnumMethod(EventBean[] eventsLambda, ICollection <object> target, bool isNewData, ExprEvaluatorContext context) { IDictionary <Object, int?> items = new LinkedHashMap <Object, int?>(); foreach (Object next in target) { int?existing = items.Get(next); if (existing == null) { existing = 1; } else { existing++; } items.Put(next, existing); } return(EnumEvalMostLeastFrequentEvent.GetResult(items, _isMostFrequent)); }
public object EvaluateEnumMethod(EventBean[] eventsLambda, ICollection <object> target, bool isNewData, ExprEvaluatorContext context) { var items = new LinkedHashMap <Object, int?>(); foreach (EventBean next in target) { eventsLambda[StreamNumLambda] = next; Object item = InnerExpression.Evaluate(new EvaluateParams(eventsLambda, isNewData, context)); int? existing = items.Get(item); if (!existing.HasValue) { existing = 1; } else { existing++; } items[item] = existing; } return(GetResult(items, _isMostFrequent)); }
public IDictionary <NamedWindowConsumerView, NamedWindowDeltaData> GetDeltaPerConsumer(object perStmtObj, EPStatementAgentInstanceHandle handle) { var list = (IList <NamedWindowConsumerLatch>)perStmtObj; var deltaPerConsumer = new LinkedHashMap <NamedWindowConsumerView, NamedWindowDeltaData>(); foreach (var unit in list) // for each unit { foreach (var consumerView in unit.DispatchTo.Get(handle)) // each consumer { var deltaForConsumer = deltaPerConsumer.Get(consumerView); if (deltaForConsumer == null) { deltaPerConsumer.Put(consumerView, unit.DeltaData); } else { var aggregated = new NamedWindowDeltaData(deltaForConsumer, unit.DeltaData); deltaPerConsumer.Put(consumerView, aggregated); } } } return(deltaPerConsumer); }
/// <exception cref="System.IO.IOException"></exception> private void ReadAdvertisedRefsImpl() { LinkedHashMap<string, Ref> avail = new LinkedHashMap<string, Ref>(); for (; ; ) { string line; try { line = pckIn.ReadString(); } catch (EOFException eof) { if (avail.IsEmpty()) { throw NoRepository(); } throw; } if (line == PacketLineIn.END) { break; } if (line.StartsWith("ERR ")) { // This is a customized remote service error. // Users should be informed about it. throw new RemoteRepositoryException(uri, Sharpen.Runtime.Substring(line, 4)); } if (avail.IsEmpty()) { int nul = line.IndexOf('\0'); if (nul >= 0) { // The first line (if any) may contain "hidden" // capability values after a NUL byte. foreach (string c in Sharpen.Runtime.Substring(line, nul + 1).Split(" ")) { remoteCapablities.AddItem(c); } line = Sharpen.Runtime.Substring(line, 0, nul); } } string name = Sharpen.Runtime.Substring(line, 41, line.Length); if (avail.IsEmpty() && name.Equals("capabilities^{}")) { // special line from git-receive-pack to show // capabilities when there are no refs to advertise continue; } ObjectId id = ObjectId.FromString(Sharpen.Runtime.Substring(line, 0, 40)); if (name.Equals(".have")) { additionalHaves.AddItem(id); } else { if (name.EndsWith("^{}")) { name = Sharpen.Runtime.Substring(name, 0, name.Length - 3); Ref prior = avail.Get(name); if (prior == null) { throw new PackProtocolException(uri, MessageFormat.Format(JGitText.Get().advertisementCameBefore , name, name)); } if (prior.GetPeeledObjectId() != null) { throw DuplicateAdvertisement(name + "^{}"); } avail.Put(name, new ObjectIdRef.PeeledTag(RefStorage.NETWORK, name, prior.GetObjectId (), id)); } else { Ref prior = avail.Put(name, new ObjectIdRef.PeeledNonTag(RefStorage.NETWORK, name , id)); if (prior != null) { throw DuplicateAdvertisement(name); } } } } Available(avail); }