public void TestAddArray() { var factory = new PropertyIndexedEventTableFactory(1, _eventType, _propertyNames, false, null); _index = (PropertyIndexedEventTable) factory.MakeEventTables()[0]; // Add just 2 var events = new EventBean[2]; events[0] = _testEvents[1]; events[1] = _testEvents[4]; _index.Add(events); ICollection<EventBean> result = _index.Lookup(new Object[] {1, "b"}); Assert.AreEqual(2, result.Count); }
public void SetUp() { _propertyNames = new[] {"IntPrimitive", "TheString"}; _eventType = SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)); var factory = new PropertyIndexedEventTableFactory(1, _eventType, _propertyNames, false, null); _index = (PropertyIndexedEventTable) factory.MakeEventTables()[0]; // Populate with testEvents var intValues = new[] {0, 1, 1, 2, 1, 0}; var stringValues = new[] {"a", "b", "c", "a", "b", "c"}; _testEvents = new EventBean[intValues.Length]; _testEventsUnd = new Object[intValues.Length]; for (int i = 0; i < intValues.Length; i++) { _testEvents[i] = MakeBean(intValues[i], stringValues[i]); _testEventsUnd[i] = _testEvents[i].Underlying; } _index.Add(_testEvents); }
/// <summary> /// Build an index/table instance using the event properties for the event type. /// </summary> /// <param name="indexedStreamNum">number of stream indexed</param> /// <param name="item">The item.</param> /// <param name="eventType">type of event to expect</param> /// <param name="coerceOnAddOnly">if set to <c>true</c> [coerce on add only].</param> /// <param name="unique">if set to <c>true</c> [unique].</param> /// <param name="optionalIndexName">Name of the optional index.</param> /// <returns>table build</returns> public static EventTable BuildIndex( int indexedStreamNum, QueryPlanIndexItem item, EventType eventType, bool coerceOnAddOnly, bool unique, String optionalIndexName) { IList <string> indexProps = item.IndexProps; IList <Type> indexCoercionTypes = Normalize(item.OptIndexCoercionTypes); IList <string> rangeProps = item.RangeProps; IList <Type> rangeCoercionTypes = Normalize(item.OptRangeCoercionTypes); EventTable table; if (rangeProps == null || rangeProps.Count == 0) { if (indexProps == null || indexProps.Count == 0) { table = new UnindexedEventTable(indexedStreamNum); } else { // single index key if (indexProps.Count == 1) { if (indexCoercionTypes == null || indexCoercionTypes.Count == 0) { var factory = new PropertyIndexedEventTableSingleFactory( indexedStreamNum, eventType, indexProps[0], unique, optionalIndexName); table = factory.MakeEventTables()[0]; } else { if (coerceOnAddOnly) { var factory = new PropertyIndexedEventTableSingleCoerceAddFactory( indexedStreamNum, eventType, indexProps[0], indexCoercionTypes[0]); table = factory.MakeEventTables()[0]; } else { var factory = new PropertyIndexedEventTableSingleCoerceAllFactory( indexedStreamNum, eventType, indexProps[0], indexCoercionTypes[0]); table = factory.MakeEventTables()[0]; } } } // Multiple index keys else { if (indexCoercionTypes == null || indexCoercionTypes.Count == 0) { var factory = new PropertyIndexedEventTableFactory( indexedStreamNum, eventType, indexProps, unique, optionalIndexName); table = factory.MakeEventTables()[0]; } else { if (coerceOnAddOnly) { var factory = new PropertyIndexedEventTableCoerceAddFactory( indexedStreamNum, eventType, indexProps, indexCoercionTypes); table = factory.MakeEventTables()[0]; } else { var factory = new PropertyIndexedEventTableCoerceAllFactory( indexedStreamNum, eventType, indexProps, indexCoercionTypes); table = factory.MakeEventTables()[0]; } } } } } else { if ((rangeProps.Count == 1) && (indexProps == null || indexProps.Count == 0)) { if (rangeCoercionTypes == null) { var factory = new PropertySortedEventTableFactory(indexedStreamNum, eventType, rangeProps[0]); return(factory.MakeEventTables()[0]); } else { var factory = new PropertySortedEventTableCoercedFactory( indexedStreamNum, eventType, rangeProps[0], rangeCoercionTypes[0]); return(factory.MakeEventTables()[0]); } } else { var factory = new PropertyCompositeEventTableFactory( indexedStreamNum, eventType, indexProps, indexCoercionTypes, rangeProps, rangeCoercionTypes); return(factory.MakeEventTables()[0]); } } return(table); }