Exemplo n.º 1
0
        public void TestNestedMapProperties()
        {
            var configuration = new Configuration();
            var point         = new Dictionary <string, object>();

            point.Put("X", typeof(int));
            point.Put("Y", typeof(int));

            var figure = new Dictionary <string, object>();

            figure.Put("Name", typeof(string));
            figure.Put("Point", point);

            configuration.AddEventType("Figure", figure);
            var ep = EPServiceProviderManager.GetProvider("testNestedMapProperties", configuration);
            var ul = new SupportUpdateListener();

            ep.EPAdministrator.CreateEPL("select * from Figure").Events += ul.Update;

            var source  = new AdapterInputSource("regression/nestedProperties.csv");
            var spec    = new CSVInputAdapterSpec(source, "Figure");
            var adapter = new CSVInputAdapter(ep, spec);

            adapter.Start();

            Assert.IsTrue(ul.IsInvoked());
            var e = ul.AssertOneGetNewAndReset();

            Assert.AreEqual(1, e.Get("Point.X"));
        }
Exemplo n.º 2
0
        public void TestNestedProperties()
        {
            var container = ContainerExtensions.CreateDefaultContainer();

            var configuration = new Configuration(container);

            configuration.AddEventType <Figure>();

            var ep = EPServiceProviderManager.GetProvider(container, "testNestedProperties", configuration);
            var ul = new SupportUpdateListener();

            ep.EPAdministrator.CreateEPL("select * from Figure").Events += ul.Update;

            var source  = new AdapterInputSource("regression/nestedProperties.csv");
            var spec    = new CSVInputAdapterSpec(source, "Figure");
            var adapter = new CSVInputAdapter(_container, ep, spec);

            adapter.Start();

            Assert.IsTrue(ul.IsInvoked());
            var e = ul.AssertOneGetNewAndReset();
            var f = (Figure)e.Underlying;

            Assert.AreEqual(1, f.Point.X);
        }
Exemplo n.º 3
0
        public void TestNestedMapProperties()
        {
            var configuration = new Configuration(_container);
            var point         = new Dictionary <string, object>();

            point.Put("X", typeof(int));
            point.Put("Y", typeof(int));

            var figure = new Dictionary <string, object>();

            figure.Put("Name", typeof(string));
            figure.Put("Point", point);

            configuration.Common.AddEventType("Figure", figure);
            var runtime = EPRuntimeProvider.GetRuntime("testNestedMapProperties", configuration);
            var ul      = new SupportUpdateListener();
            var stmt    = CompileUtil.CompileDeploy(runtime, "select * from Figure").Statements[0];

            stmt.Events += ul.Update;

            var source  = new AdapterInputSource(_container, "regression/nestedProperties.csv");
            var spec    = new CSVInputAdapterSpec(source, "Figure");
            var adapter = new CSVInputAdapter(runtime, spec);

            adapter.Start();

            Assert.IsTrue(ul.IsInvoked());
            var e = ul.AssertOneGetNewAndReset();

            Assert.AreEqual(1, e.Get("Point.X"));
        }
Exemplo n.º 4
0
        public void TestNestedProperties()
        {
            var container = ContainerExtensions.CreateDefaultContainer();

            var configuration = new Configuration(container);

            configuration.Common.AddEventType(typeof(Figure));

            var runtime = EPRuntimeProvider.GetRuntime("testNestedProperties", configuration);
            var ul      = new SupportUpdateListener();

            var stmt = CompileUtil.CompileDeploy(runtime, "select * from Figure").Statements[0];

            stmt.Events += ul.Update;

            var source  = new AdapterInputSource(_container, "regression/nestedProperties.csv");
            var spec    = new CSVInputAdapterSpec(source, "Figure");
            var adapter = new CSVInputAdapter(runtime, spec);

            adapter.Start();

            Assert.IsTrue(ul.IsInvoked());
            var e = ul.AssertOneGetNewAndReset();
            var f = (Figure)e.Underlying;

            Assert.AreEqual(1, f.Point.X);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="runtime">provides the engine runtime and services</param>
        /// <param name="spec">the parameters for this adapter</param>

        public CSVInputAdapter(EPRuntime runtime, CSVInputAdapterSpec spec)
            : base(runtime, spec.IsUsingEngineThread, spec.IsUsingExternalTimer, spec.IsUsingTimeSpanEvents)
        {
            Coercer        = new BasicTypeCoercer();
            _adapterSpec   = spec;
            _eventTypeName = _adapterSpec.EventTypeName;
            _eventsPerSec  = spec.EventsPerSec;

            if (runtime != null)
            {
                FinishInitialization(runtime, spec);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="epService">provides the engine runtime and services</param>
        /// <param name="spec">the parameters for this adapter</param>

        public CSVInputAdapter(IContainer container, EPServiceProvider epService, CSVInputAdapterSpec spec)
            : base(epService, spec.IsUsingEngineThread, spec.IsUsingExternalTimer, spec.IsUsingTimeSpanEvents)
        {
            Coercer        = new BasicTypeCoercer();
            _adapterSpec   = spec;
            _eventTypeName = _adapterSpec.EventTypeName;
            _eventsPerSec  = spec.EventsPerSec;
            _container     = container;

            if (epService != null)
            {
                FinishInitialization(epService, spec);
            }
        }
Exemplo n.º 7
0
        private static void AssertValidParameters(EPRuntime runtime, CSVInputAdapterSpec adapterSpec)
        {
            if (!(runtime is EPRuntimeSPI))
            {
                throw new ArgumentException("Invalid type of EPServiceProvider");
            }

            if (adapterSpec.EventTypeName == null)
            {
                throw new ArgumentException("eventTypeName cannot be null");
            }

            if (adapterSpec.AdapterInputSource == null)
            {
                throw new ArgumentException("adapterInputSource cannot be null");
            }

            AssertValidEventsPerSec(adapterSpec.EventsPerSec);

            if (adapterSpec.IsLooping && !adapterSpec.AdapterInputSource.IsResettable)
            {
                throw new EPException("Cannot loop on a non-resettable input source");
            }
        }
Exemplo n.º 8
0
        private void FinishInitialization(EPRuntime runtime, CSVInputAdapterSpec spec)
        {
            AssertValidParameters(runtime, spec);

            var spi = (EPRuntimeSPI)runtime;

            ScheduleSlot = new ScheduleBucket(-1).AllocateSlot();

            _reader         = new CSVReader(spec.AdapterInputSource);
            _reader.Looping = spec.IsLooping;

            var firstRow = FirstRow;

            var givenPropertyTypes = ConstructPropertyTypes(
                spec.EventTypeName,
                spec.PropertyTypes,
                spi.ServicesContext.EventTypeRepositoryBus);

            _propertyOrder =
                spec.PropertyOrder ??
                CSVPropertyOrderHelper.ResolvePropertyOrder(firstRow, givenPropertyTypes);

            _reader.IsUsingTitleRow = IsUsingTitleRow(firstRow, _propertyOrder);
            if (!IsUsingTitleRow(firstRow, _propertyOrder))
            {
                this._firstRow = firstRow;
            }

            _propertyTypes = ResolvePropertyTypes(givenPropertyTypes);
            if (givenPropertyTypes == null)
            {
                throw new EPException("CSV adapter requires a predefined event type name, the event type named '" + spec.EventTypeName + "' could not be found");
            }

            Coercer.SetPropertyTypes(_propertyTypes);
        }
Exemplo n.º 9
0
        private void FinishInitialization(EPServiceProvider epService, CSVInputAdapterSpec spec)
        {
            AssertValidParameters(epService, spec);

            var spi = (EPServiceProviderSPI)epService;

            ScheduleSlot = spi.SchedulingMgmtService.AllocateBucket().AllocateSlot();

            _reader         = new CSVReader(_container, spec.AdapterInputSource);
            _reader.Looping = spec.IsLooping;

            var firstRow = FirstRow;

            var givenPropertyTypes = ConstructPropertyTypes(
                spec.EventTypeName,
                spec.PropertyTypes,
                spi.EventAdapterService);

            _propertyOrder =
                spec.PropertyOrder ??
                CSVPropertyOrderHelper.ResolvePropertyOrder(firstRow, givenPropertyTypes);

            _reader.IsUsingTitleRow = IsUsingTitleRow(firstRow, _propertyOrder);
            if (!IsUsingTitleRow(firstRow, _propertyOrder))
            {
                this._firstRow = firstRow;
            }

            _propertyTypes = ResolvePropertyTypes(givenPropertyTypes);
            if (givenPropertyTypes == null)
            {
                spi.EventAdapterService.AddNestableMapType(_eventTypeName, new Dictionary <string, object>(_propertyTypes), null, true, true, true, false, false);
            }

            Coercer.SetPropertyTypes(_propertyTypes);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Ctor for adapters that will be passed to an AdapterCoordinator.
        /// </summary>
        /// <param name="adapterSpec">contains parameters that specify the behavior of the input adapter</param>

        public CSVInputAdapter(CSVInputAdapterSpec adapterSpec)
            : this(null, adapterSpec)
        {
        }
Exemplo n.º 11
0
        /// <summary>
        /// Ctor for adapters that will be passed to an AdapterCoordinator.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="adapterSpec">contains parameters that specify the behavior of the input adapter</param>

        public CSVInputAdapter(IContainer container, CSVInputAdapterSpec adapterSpec)
            : this(container, null, adapterSpec)
        {
        }