Exemplo n.º 1
0
        public EventTable[] MakeEventTables(EventTableFactoryTableIdent tableIdent, ExprEvaluatorContext exprEvaluatorContext)
        {
            EventTableOrganization organization = Organization;

            return(new EventTable[] { new PropertyCompositeEventTableImpl(
                                          OptKeyCoercedTypes, OptRangeCoercedTypes, organization, (OptionalKeyedProps != null && OptionalKeyedProps.Count > 0), Chain) });
        }
Exemplo n.º 2
0
 /// <summary>Ctor. </summary>
 public PropertySortedEventTable(EventPropertyGetter propertyGetter, EventTableOrganization organization)
 {
     _organization   = organization;
     PropertyGetter  = propertyGetter;
     PropertyIndex   = new OrderedDictionary <Object, ISet <EventBean> >();
     NullKeyedValues = new LinkedHashSet <EventBean>();
 }
Exemplo n.º 3
0
        public override EventTable[] MakeEventTables()
        {
            var organization = new EventTableOrganization(null, false, true, StreamNum, new String[] { PropertyName }, EventTableOrganization.EventTableOrganizationType.BTREE);

            return(new EventTable[]
            {
                new PropertySortedEventTableCoerced(PropertyGetter, organization, _coercionType)
            });
        }
        public virtual EventTable[] MakeEventTables()
        {
            var organization = new EventTableOrganization(null, false, false, StreamNum, new String[] { PropertyName }, EventTableOrganization.EventTableOrganizationType.BTREE);

            return(new EventTable[]
            {
                new PropertySortedEventTable(PropertyGetter, organization)
            });
        }
Exemplo n.º 5
0
        public override EventTable[] MakeEventTables()
        {
            var organization = new EventTableOrganization(OptionalIndexName, Unique, true, StreamNum, PropertyNames, EventTableOrganization.EventTableOrganizationType.HASH);

            return(new EventTable[]
            {
                new PropertyIndexedEventTableCoerceAdd(PropertyGetters, organization, Coercers, CoercionType)
            });
        }
        public override EventTable[] MakeEventTables()
        {
            var organization = new EventTableOrganization(OptionalIndexName, Unique, true, StreamNum, new String[] { PropertyName }, EventTableOrganization.EventTableOrganizationType.HASH);
            var eventTable   = new PropertyIndexedEventTableSingleCoerceAll(PropertyGetter, organization, Coercer, CoercionType);

            return(new EventTable[]
            {
                eventTable
            });
        }
Exemplo n.º 7
0
 public PropertyIndexedEventTableCoerceAdd(
     EventPropertyGetter[] propertyGetters,
     EventTableOrganization organization,
     Coercer[] coercers,
     Type[] coercionTypes)
     : base(propertyGetters, organization)
 {
     Coercers      = coercers;
     CoercionTypes = coercionTypes;
 }
        public EventTable[] MakeEventTables()
        {
            var organization = new EventTableOrganization(null, false, _optKeyCoercedTypes != null || _optRangeCoercedTypes != null, _streamNum, CombinedPropertyLists(_optionalKeyedProps, _rangeProps), EventTableOrganization.EventTableOrganizationType.COMPOSITE);

            return(new EventTable[]
            {
                new PropertyCompositeEventTable(
                    (_optionalKeyedProps != null && _optionalKeyedProps.Count > 0), _chain, _optKeyCoercedTypes,
                    _optRangeCoercedTypes, organization)
            });
        }
Exemplo n.º 9
0
 public PropertyIndexedEventTableSingle(EventPropertyGetter propertyGetter, EventTableOrganization organization, bool allocate)
 {
     PropertyGetter = propertyGetter;
     _organization  = organization;
     if (allocate)
     {
         PropertyIndex = new Dictionary <object, ISet <EventBean> >().WithNullSupport();
     }
     else
     {
         PropertyIndex = null;
     }
 }
Exemplo n.º 10
0
        public virtual EventTable[] MakeEventTables()
        {
            var organization = new EventTableOrganization(
                OptionalIndexName, Unique, false, StreamNum, new String[] { PropertyName }, EventTableOrganization.EventTableOrganizationType.HASH);
            var eventTable = Unique
                ? new PropertyIndexedEventTableSingleUnique(PropertyGetter, organization)
                : new PropertyIndexedEventTableSingle(PropertyGetter, organization, true);

            return(new EventTable[]
            {
                eventTable
            });
        }
Exemplo n.º 11
0
        public virtual EventTable[] MakeEventTables(EventTableFactoryTableIdent tableIdent)
        {
            var organization = new EventTableOrganization(OptionalIndexName, Unique, false, StreamNum, new String[] { PropertyName }, EventTableOrganizationType.HASH);

            if (Unique)
            {
                return(new EventTable[] { new PropertyIndexedEventTableSingleUnique(PropertyGetter, organization) });
            }
            else
            {
                return(new EventTable[] { new PropertyIndexedEventTableSingleUnadorned(PropertyGetter, organization) });
            }
        }
Exemplo n.º 12
0
        public virtual EventTable[] MakeEventTables(EventTableFactoryTableIdent tableIdent, ExprEvaluatorContext exprEvaluatorContext)
        {
            EventTableOrganization organization = Organization;

            if (unique)
            {
                return(new EventTable[] { new PropertyIndexedEventTableUnique(propertyGetters, organization) });
            }
            else
            {
                return(new EventTable[] { new PropertyIndexedEventTableUnadorned(propertyGetters, organization) });
            }
        }
Exemplo n.º 13
0
        public PropertyCompositeEventTable(bool isHashKeyed, CompositeIndexEnterRemove chain, IList <Type> optKeyCoercedTypes, IList <Type> optRangeCoercedTypes, EventTableOrganization organization)
        {
            _chain = chain;
            _optKeyCoercedTypes   = optKeyCoercedTypes;
            _optRangeCoercedTypes = optRangeCoercedTypes;
            _organization         = organization;

            if (isHashKeyed)
            {
                _index = new Dictionary <Object, Object>();
            }
            else
            {
                _index = new OrderedDictionary <Object, Object>();
            }
        }
Exemplo n.º 14
0
        public EventTable[] MakeEventTables(EventTableFactoryTableIdent tableIdent)
        {
            var tables = new EventTable[PropertyGetters.Length];

            if (Unique)
            {
                for (var i = 0; i < tables.Length; i++)
                {
                    var organization = new EventTableOrganization(OptionalIndexName, Unique, false, StreamNum, new String[] { PropertyNames[i] }, EventTableOrganizationType.HASH);
                    tables[i] = new PropertyIndexedEventTableSingleUnique(PropertyGetters[i], organization);
                }
            }
            else
            {
                for (var i = 0; i < tables.Length; i++)
                {
                    var organization = new EventTableOrganization(OptionalIndexName, Unique, false, StreamNum, new String[] { PropertyNames[i] }, EventTableOrganizationType.HASH);
                    tables[i] = new PropertyIndexedEventTableSingleUnadorned(PropertyGetters[i], organization);
                }
            }
            return(tables);
        }
Exemplo n.º 15
0
 public PropertyIndexedEventTable(EventPropertyGetter[] propertyGetters, EventTableOrganization organization)
 {
     PropertyGetters = propertyGetters;
     _organization   = organization;
     PropertyIndex   = new Dictionary <MultiKeyUntyped, ISet <EventBean> >();
 }
        public virtual EventTable[] MakeEventTables(EventTableFactoryTableIdent tableIdent, ExprEvaluatorContext exprEvaluatorContext)
        {
            EventTableOrganization organization = Organization;

            return(new EventTable[] { new PropertySortedEventTableImpl(PropertyGetter, organization) });
        }
Exemplo n.º 17
0
        public override EventTable[] MakeEventTables(EventTableFactoryTableIdent tableIdent)
        {
            EventTableOrganization organization = GetOrganization();

            return(new EventTable[] { new PropertyIndexedEventTableSingleCoerceAdd(PropertyGetter, organization, Coercer, CoercionType) });
        }
 protected PropertyIndexedEventTableSingle(EventPropertyGetter propertyGetter, EventTableOrganization organization)
 {
     this.propertyGetter = propertyGetter;
     this.organization   = organization;
 }
 public PropertyIndexedEventTableUnadorned(EventPropertyGetter[] propertyGetters, EventTableOrganization organization)
     : base(propertyGetters, organization)
 {
     propertyIndex = new Dictionary <MultiKeyUntyped, ISet <EventBean> >();
 }
        public override EventTable[] MakeEventTables(EventTableFactoryTableIdent tableIdent, ExprEvaluatorContext exprEvaluatorContext)
        {
            EventTableOrganization organization = Organization;

            return(new EventTable[] { new PropertyIndexedEventTableCoerceAdd(propertyGetters, organization, Coercers, CoercionType) });
        }
Exemplo n.º 21
0
 public PropertyIndexedEventTableCoerceAll(EventPropertyGetter[] propertyGetters, EventTableOrganization organization, Coercer[] coercers, Type[] coercionType)
     : base(propertyGetters, organization, coercers, coercionType)
 {
 }
Exemplo n.º 22
0
 protected PropertyIndexedEventTable(EventPropertyGetter[] propertyGetters, EventTableOrganization organization)
 {
     this.propertyGetters = propertyGetters;
     this.organization    = organization;
 }
 protected PropertyCompositeEventTable(IList <Type> optKeyCoercedTypes, IList <Type> optRangeCoercedTypes, EventTableOrganization organization)
 {
     _optKeyCoercedTypes   = optKeyCoercedTypes;
     _optRangeCoercedTypes = optRangeCoercedTypes;
     Organization          = organization;
 }
Exemplo n.º 24
0
 public PropertyIndexedEventTableUnique(EventPropertyGetter[] propertyGetters, EventTableOrganization organization)
     : base(propertyGetters, organization)
 {
     _propertyIndex = new Dictionary <MultiKeyUntyped, EventBean>();
     _canClear      = true;
 }
Exemplo n.º 25
0
 public PropertyCompositeEventTableImpl(IList <Type> optKeyCoercedTypes, IList <Type> optRangeCoercedTypes, EventTableOrganization organization, bool isHashKeyed, CompositeIndexEnterRemove chain)
     : base(optKeyCoercedTypes, optRangeCoercedTypes, organization)
 {
     _chain = chain;
     _index = isHashKeyed
             ? (IDictionary <object, object>) new Dictionary <object, object>()
         : (IDictionary <object, object>) new OrderedDictionary <object, object>();
 }
Exemplo n.º 26
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="tables">tables to hold</param>
 /// <param name="organization">The _organization.</param>
 public MultiIndexEventTable(EventTable[] tables, EventTableOrganization organization)
 {
     _tables       = tables;
     _organization = organization;
 }
Exemplo n.º 27
0
 public SingleReferenceEventTable(EventTableOrganization organization, Atomic <ObjectArrayBackedEventBean> eventReference)
 {
     this._organization   = organization;
     this._eventReference = eventReference;
 }
Exemplo n.º 28
0
        /// <summary>Get the strategies to use for polling from a given stream. </summary>
        /// <param name="streamViewStreamNum">the stream providing the polling events</param>
        /// <returns>looking and indexing strategy</returns>
        public Pair <HistoricalIndexLookupStrategy, PollResultIndexingStrategy> GetStrategy(int streamViewStreamNum)
        {
            // If there is only a single polling stream, then build a single index
            if (_pollingStreams.Count == 1)
            {
                return(JoinSetComposerPrototypeFactory.DetermineIndexing(_queryGraph, _typesPerStream[_historicalStreamNum], _typesPerStream[streamViewStreamNum], _historicalStreamNum, streamViewStreamNum));
            }

            // If there are multiple polling streams, determine if a single index is appropriate.
            // An index can be reused if:
            //  (a) indexed property names are the same
            //  (b) indexed property types are the same
            //  (c) key property types are the same (because of coercion)
            // A index lookup strategy is always specific to the providing stream.
            if (_indexesUsedByStreams == null)
            {
                _indexesUsedByStreams = new LinkedHashMap <HistoricalStreamIndexDesc, IList <int> >();
                foreach (var pollingStream in _pollingStreams)
                {
                    var queryGraphValue = _queryGraph.GetGraphValue(pollingStream, _historicalStreamNum);
                    var hashKeyProps    = queryGraphValue.HashKeyProps;
                    var indexProperties = hashKeyProps.Indexed;

                    var keyTypes   = GetPropertyTypes(hashKeyProps.Keys);
                    var indexTypes = GetPropertyTypes(_typesPerStream[_historicalStreamNum], indexProperties);

                    var desc          = new HistoricalStreamIndexDesc(indexProperties, indexTypes, keyTypes);
                    var usedByStreams = _indexesUsedByStreams.Get(desc);
                    if (usedByStreams == null)
                    {
                        usedByStreams = new List <int>();
                        _indexesUsedByStreams.Put(desc, usedByStreams);
                    }
                    usedByStreams.Add(pollingStream);
                }

                // There are multiple indexes required:
                // Build a master indexing strategy that forms multiple indexes and numbers each.
                if (_indexesUsedByStreams.Count > 1)
                {
                    var numIndexes         = _indexesUsedByStreams.Count;
                    var indexingStrategies = new PollResultIndexingStrategy[numIndexes];

                    // create an indexing strategy for each index
                    var count = 0;
                    foreach (var desc in _indexesUsedByStreams)
                    {
                        var sampleStreamViewStreamNum = desc.Value[0];
                        indexingStrategies[count] = JoinSetComposerPrototypeFactory.DetermineIndexing(_queryGraph, _typesPerStream[_historicalStreamNum], _typesPerStream[sampleStreamViewStreamNum], _historicalStreamNum, sampleStreamViewStreamNum).Second;
                        count++;
                    }

                    // create a master indexing strategy that utilizes each indexing strategy to create a set of indexes
                    var streamNum = streamViewStreamNum;
                    _masterIndexingStrategy = new ProxyPollResultIndexingStrategy
                    {
                        ProcIndex = (pollResult, isActiveCache, statementContext) =>
                        {
                            var tables = new EventTable[numIndexes];
                            for (var i = 0; i < numIndexes; i++)
                            {
                                tables[i] = indexingStrategies[i].Index(pollResult, isActiveCache, statementContext)[0];
                            }

                            var organization = new EventTableOrganization(null, false, false, streamNum, null, EventTableOrganizationType.MULTIINDEX);
                            return(new EventTable[]
                            {
                                new MultiIndexEventTable(tables, organization)
                            });
                        },
                        ProcToQueryPlan = () =>
                        {
                            var writer    = new StringWriter();
                            var delimiter = "";
                            foreach (var strategy in indexingStrategies)
                            {
                                writer.Write(delimiter);
                                writer.Write(strategy.ToQueryPlan());
                                delimiter = ", ";
                            }
                            return(GetType().FullName + " " + writer);
                        }
                    };
                }
            }

            // there is one type of index
            if (_indexesUsedByStreams.Count == 1)
            {
                return(JoinSetComposerPrototypeFactory.DetermineIndexing(
                           _queryGraph, _typesPerStream[_historicalStreamNum], _typesPerStream[streamViewStreamNum], _historicalStreamNum, streamViewStreamNum));
            }

            // determine which index number the polling stream must use
            var indexUsed = 0;
            var found     = false;

            foreach (var desc in _indexesUsedByStreams.Values)
            {
                if (desc.Contains(streamViewStreamNum))
                {
                    found = true;
                    break;
                }
                indexUsed++;
            }
            if (!found)
            {
                throw new IllegalStateException("MapIndex not found for use by stream " + streamViewStreamNum);
            }

            // Use one of the indexes built by the master index and a lookup strategy
            var indexNumber = indexUsed;
            HistoricalIndexLookupStrategy innerLookupStrategy = JoinSetComposerPrototypeFactory.DetermineIndexing(_queryGraph, _typesPerStream[_historicalStreamNum], _typesPerStream[streamViewStreamNum], _historicalStreamNum, streamViewStreamNum).First;

            var lookupStrategy = new ProxyHistoricalIndexLookupStrategy
            {
                ProcLookup = (lookupEvent, index, context) =>
                {
                    var multiIndex = (MultiIndexEventTable)index[0];
                    var indexToUse = multiIndex.Tables[indexNumber];
                    return(innerLookupStrategy.Lookup(lookupEvent, new EventTable[] { indexToUse }, context));
                },
                ProcToQueryPlan = () => GetType().FullName + " inner: " + innerLookupStrategy.ToQueryPlan()
            };

            return(new Pair <HistoricalIndexLookupStrategy, PollResultIndexingStrategy> (lookupStrategy, _masterIndexingStrategy));
        }
Exemplo n.º 29
0
 public PropertyIndexedEventTableUnique(EventPropertyGetter[] propertyGetters, EventTableOrganization organization, IDictionary <MultiKeyUntyped, EventBean> propertyIndex)
     : base(propertyGetters, organization)
 {
     _propertyIndex = propertyIndex;
     _canClear      = false;
 }
Exemplo n.º 30
0
 public PropertyIndexedEventTableSingleCoerceAll(EventPropertyGetter propertyGetter, EventTableOrganization organization, Coercer coercer, Type coercionType)
     : base(propertyGetter, organization, coercer, coercionType)
 {
     _coercionType = coercionType;
 }