DefineObserver for query with anonymous type in Streaminsight 2.1 using the Rx Framework

Hello all,
Assuming one has the following observable:
var source =
myApp.DefineObservable(() => Observable.Interval(TimeSpan.FromSeconds(1)))
.ToPointStreamable(x => PointEvent.CreateInsert(DateTimeOffset.Now, x),
AdvanceTimeSettings.IncreasingStartTime);
One can write the following query:
var query = from integer in source.TumblingWindow(TimeSpan.FromSeconds(5))
select integer.Avg(e => e);
And bind it to the following observer:
var sink = myApp.DefineObserver(() => Observer.Create<double>(Console.WriteLine));
using (query.Bind(sink).Run("Query 1"))
Console.WriteLine("Running, press Enter to stop");
Console.ReadLine();
And everything works fine.
Now let's say I want to modify the query so it can return (for example) both the average and the number of elements in the tumbling window. In that case I would modify to query like this:
var query = from integer in source.TumblingWindow(TimeSpan.FromSeconds(5))
select new
Average = integer.Avg(e => e),
Count = integer.Count()
However, the sink is expecting a "double" not an anonymous type.
My question is, is it possible to define a sink that can accept an anonymous type, ie. is it possible to right something like this:
var sink = myApp.DefineObserver(() => Observer.Create<????????????????>
(x =>
Console.WriteLine("Average: {0} Count: {1}", x.Average,
x.Count));
or do I need to define a "AverageAndCount" class beforehand so I do something like:
var query = from integer in source.TumblingWindow(TimeSpan.FromSeconds(5))
select new AverageAndCount
Average = integer.Avg(e => e),
Count = integer.Count()
};var sink = myApp.DefineObserver(() => Observer.Create<AverageAndCount>
                                          (x =>
                                           Console.WriteLine("Average: {0} Count: {1}", x.Average,
                                                             x.Count));

No ... you don't. There are ways around it ... there's no problem that an additional layer of abstraction can't fix, right? What you need is a way to get the type of the payload in a way that the compiler can infer it.
From an upcoming blog post in my current series, here's an extension method that would do that with my "dual-mode sinks":
public static IRemoteStreamableBinding BindConsumer<TPayload>(
this IQStreamable<TPayload> stream,
Application cepApplication,
Type consumerFactoryType,
object configInfo,
EventShape eventShape)
var factory = Activator.CreateInstance(consumerFactoryType) as ISinkFactory;
if (factory == null)
throw new ArgumentException("Factory cannot be created or does not implement ISinkFactory");
switch (eventShape)
case EventShape.Interval:
var intervalObserver = cepApplication.DefineObserver(() => factory.CreateIntervalObserverSink<TPayload>(configInfo));
return stream.Bind(intervalObserver);
case EventShape.Edge:
var edgeObserver = cepApplication.DefineObserver(() => factory.CreateEdgeObserverSink<TPayload>(configInfo));
return stream.Bind(edgeObserver);
case EventShape.Point:
var pointObserver = cepApplication.DefineObserver(() => factory.CreatePointObserverSink<TPayload>(configInfo));
return stream.Bind(pointObserver);
default:
throw new ArgumentOutOfRangeException("eventShape");
Within the sink itself, you'll need to use reflection to "unpack" the event. It's not quite as straighforward - or as simple - as the untyped output adapter but it does work quite well. Keep an eye on my blog ... I should get an update posted this week that
will get you a good ways down the path. :-)
DevBiker (aka J Sawyer)
Microsoft MVP - Sql Server (StreamInsight)
If I answered your question, please mark as answer.
If my post was helpful, please mark as helpful.

Similar Messages

  • How to view a BI query with anonymous user in the portal

    <b>Hi Gurus,</b>
    Does anybody knows how to view a BI query in the portal with anonymous user?
    Cause when i try to view a query the portal always ask for authentification. And i don't want to sign with a user cause my portal is for everybody and if the user logged in it shows the roles that previously were assigned.
    I have the Netweaver 2004 with SP9
    <b>Thank you Very Much</b>

    do you have sso configured between portal and BW server, if yes the authentication pop up should not come.
    if you dont want to do sso between portal and bw server and still want to logon to BW query with anonymous user,
    in you bw server go to transaction sicf and navigate to DEFAULT_HOST->SAP->BW->BEX and double click on bex node in the resulting window, log on details section provide a default userid/password
    Raja

  • HT1338 My MacBook Pro (running Leopard 10.5.8) won't allow keyboard to type an upper case 'C' using the shift key...works fine with caps lock, or, with my Typinator workaround using double-typed lower case c (not always best). Any ideas?

    My MacBook Pro keyboard won't type an upper case 'C' using the shift key... only with caps lock. Workaround has been to use Typinator by typing a double lower case c, not always the best solution. Mac is a refurbished model, which initially was fine. Apple tech helped me correct the quirk when it first appeared, but now it has returned and refuses fixes. Any ideas?

    I'm willing to bet that this has something to do with iCloud.  I've been facing a frozen computer nearly every time I go into it. 
    In Activity Monitor I have seen two programs associate with iCloud that take up about 2.5 GB of memory (I only have 4 in the computer) -- causing everything to freeze.  One of these is called "iCloud Helper" and the other one is something like "Address Book Sync helper" -- I see parts of these names in the stuff you have posted.
    I am at my wits' end with these and have written to Apple asking them to do away with these or fix them.  To get rid of the Address book sync thing I have gone into system preferences for iCloud and unchecked Contacts -- but then spontaneously it gets rechecked.  And oftentimes after I Force Quit the iCloud helper, it spontaneously turns on again.  My conclusion --- the iCloud is basically unusable.  It turns a Mac into the most useless, clogged, sluggish PC.  If this is happening to a lot of people's computers -- and I see no reason why yours or mine should be an exception -- these programs just might destroy Apple itself. 
    So -- I'm about to completely give up on iCloud, and I suspect that others will too unless this gets fixed.
    Cheers,
    Bob

  • I want a soundbar for my 6th generation nano but am having trouble finding a compatible device. I'd like more than a dock, ideally a soundbar with wireless subwoofer. I'll only use the soundbar for music, not TV home theater. Any suggestions?

    I want a soundbar for my 6th generation nano but am having trouble finding a compatible device. I'd like more than a dock, ideally a soundbar with wireless subwoofer. I'll only use the soundbar for music, not TV home theater. Any suggestions? Thanks.

    Google

  • TS3367 My partner has the Iphone 5 and I am using a MacBook with version 1.0.2. When using the face time app to call him he says that cam freezes and he is unable to hear me. Any ideas of the problem and and ideas for resolving the issue?

    My partner has the Iphone 5 and I am using a MacBook with version 1.0.2. When using the face time app to call him he says that cam freezes and he is unable to hear me. Any ideas of the problem and and ideas for resolving the issue?

    Had the same problem, the only fault and the reason why it happend is a bad wifi connection!
    Could ofc be something else, but thats my two cents!

  • Hi there, I am trying to sign up for CC with an exisitng Adobe ID that I used for the Lightroom and Phtoshop trials.

    I am trying to sign up for CC with an exisitnd Adobe ID that I used for the Lightroom and Phtoshop trials.  Can you tell me how to do that?

    http://www.adobe.com/products/creativecloud/faq.html
    http://helpx.adobe.com/creative-cloud/help/install-apps.html to install or uninstall
    http://forums.adobe.com/community/download_install_setup/creative_cloud_faq
    What it is http://helpx.adobe.com/creative-cloud/help/creative-cloud-desktop.html
    Cloud Getting Started https://helpx.adobe.com/creative-cloud.html
    Cloud Plans https://creative.adobe.com/plans
    -Special Photography Plan includes Photoshop & Lightroom & Bridge & Mobile Lightroom
    -Special Photography Plan includes 2Gig of Cloud storage (not the 20Gig of the full plan)
    -http://helpx.adobe.com/creative-cloud/faq/mobileapps.html
    -http://helpx.adobe.com/photoshop/kb/differences-photoshop-creative-cloud-photography.html
    -and subscription terms http://www.adobe.com/misc/subscription_terms.html
    -what is in the entire Cloud http://www.adobe.com/creativecloud/catalog/desktop.html
    -http://www.adobe.com/products/catalog/mobile._sl_id-contentfilter_sl_catalog_sl_mobiledevi ces.html

  • I want to buy a new apple tv but it used hdmi cables and my house is only wired for analog.  Is there any way I can use the apple tv on analog cables?

    I want to buy a new apple tv but it used hdmi cables and my house is only wired for analog.  Is there any way I can use the apple tv on analog cables?

    Welcome to the Apple Community.
    It's do-able, but I don't think it's a great idea.
    DVI
    Some users with DVI have managed to get their TV's to work with DVI-HDMI cables. DVI carries no audio, so alternative connections need to be explored to enable audio. DVI doesn't necessarily support HDCP as well as other standards used by HDMI (which may or may not be an issue)
    Analogue
    There are hardware converters that will convert HDMI to various other types of output, however there are some issues with doing so that you should be aware of.
    HDCP
    HDCP compliant converters will not allow you to watch HDCP protected content such as that from the iTunes Store. Non compliant converters exist but we cannot discuss them under the Terms of Use for these communities.
    Resolution and aspect ratio
    I'm not aware of any converters that will scale the output from the Apple TV, any TV or projector which is used will need to be widescreen and support resolutions of 720p (Apple TV 2), 720p/1080p (Apple TV 3)
    DAC
    DAC (Example Only - Not a recommendation or suggestion that this is suitable in your circumstances)

  • What are the best practices for using the enhancement framework?

    Hello enhancement framework experts,
    Recently, my company upgraded to SAP NW 7.1 EhP6.  This presents us with the capability to use the enhancement framework.
    A couple of senior programmers were asked to deliver a guideline for use of the framework.  They published the following statement:
    "SAP does not guarantee the validity of the enhancement points in future releases/versions. As a result, any implemented enhancement points may require significant work during upgrades. So, enhancement points should essentially be used as an alternative to core modifications, which is a rare scenario.".
    I am looking for confirmation or contradiction to the statement  "SAP does not guarantee the validity of enhancement points in future releases/versions..." .  Is this a true statement for both implicit and explicit enhancement points?
    Is the impact of activated explicit and implicit enhancements much greater to an SAP upgrade than BAdi's and user exits?
    Is there any SAP published guidelines/best practices for use of the enhancement framework?
    Thank you,
    Kimberly
    Edited by: Kimberly Carmack on Aug 11, 2011 5:31 PM

    Found an article that answers this question quite well:
    [How to Get the Most From the Enhancement and Switch Framework as a Customer or Partner - Tips from the Experts|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/c0f0373e-a915-2e10-6e88-d4de0c725ab3]
    Thank you Thomas Weiss!

  • 10.2 crashes when I try to convert old libraries for use in the new software. Is there a workaround for this? Or will i have to continue using the previous version to complete older projects?

    Final Cut Pro X 10.2 crashes when I try to convert old libraries for use in the new software. Is there a workaround for this? Or will I have to continue using the previous version to complete older projects? the only foreseeable solution is to begin any new projects on 10.2 or importing footage on 10.2 and starting form scratch--which is something i definitely don't want to do or have time to do. ANY advice, thoughts, or opinions would be greatly appreciated! Thank you!
    Running 10.10.3 // MacBook Pro (Retina, 15-inch, Early 2013) // 2.4 GHz Intel Core i7 // 8 GB 1600 MHz DDR3

    Exactly the same problem with me.
    Some other threads advice to remove fonts, clean the caches, remove add ins but nothing works consistenty, for some it looks like it works, for me it failed.
    What I did not try yet, was to move the Render files out of the malicious library to trash.

  • "No enought room on startup disk for Application Memory" when using the Accelerate Framework

    Dear colleagues,
    I am running what I know is a large problem for a scientific application (tochnog) a finite element solver that runs from the Terminal. The application tries to solve 1,320,000 simultaneous linear equations. The problem starts when I use the Accelerate Framework as the Virtual Memory size jumps from 142 G to about 576 G after the library  (LAPACK) is called to solve the system.It does not do it if I use a solver that does not calls LAPACK inside Accelerate.
    The machine is a mac pro desktop with 8 GB of ram, the 2.66 GHz Quad-core Intel and the standard 640 GB hard drive. The system tells me that I have 487 GB available on hard drive.
    The top instruction in Terminal reads VM 129G vsize when starting. When I run the finite element application once the LAPACK library in the Accelerate framework gets called, the Virtual Memory (VM) jumps to 563 G vsize.
    After a short while, I get the "No enought room on startup disk for Application Memory error"
    This is a screen capture of the application attempting to solve the problem using the LAPACK library inside the Accelerate framework: Here are the numbers as reported by the activity Monitor.
    Tochnog Real Memory 6.68 GB
    System Memory  Free: 33.8 MB, Wired 378.8 MB, Active 5.06 GB, Inactive 2.53 GB, Used 7.96 GB.
    VM size 567.52 GB, Page ins 270.8 MB, Page outs 108.2 MB, Swap used 505 MB
    This is a screen copy of the same application solving the same problemwithout using the Accelerate framework.
    Tochnog Real Memory 1.96 GB,
    System Memory  Free: 4.52 MB, Wired 382.1 MB, Active 2.69 GB, Inactive 416.2 GB, Used 3.47 GB.
    VM size 148.60 GB, Page ins 288.8 MB, Page outs 108.2 MB, Swap used 2.5 MB
    I can not understand the disparity in the behavior for the same case. As I said before, the only difference is the use of Accelerate in the first case. Also, as you can see, I thought that 8 GB of ram memory was a lot.
    Your help will be greatly appreciated
    Best regards,
    F Lorenzo

    The OP had posted this question in the iMac Intel forum.
    I replied along similar lines, but suggested he repost this in the SL forum where I know there are usually several people who have a far better grasp of these issues than I.
    I would be interested in getting their take on this.
    Although, I think you are coming to the correct conclusion that there are not enough resources available for this process, I'm not certain that what you are saying on the way to that conclusion is correct. My understanding of VM is that it is the total theoretical demand on memory a process might make. It is not necessarily the actual or real world demand being made.
    As such, this process is not actually demanding 568GB (rounded.) As evidence of that, you can see there is still memory available, albeit quite small, in the form of free memory of 33.8MB and inactive of 2.53GB (the GB for that figure, above, seems like it might be a typo, since for the process when not using Accelerate the reported figure for inactive was 416.2 GB -- surely impossible) and 7.96GB used. The process, itself, is using 6.68GB real memory.
    In addition, I question whether the OP has misstated the 487GB free drive space. I think that might be the total drive capacity, not the free space.
    My guess is that it is the combination of low available memory and low free drive space prompting this error.
    From Dr. Smoke on VM:
    it is possible that swap files could grow to the point where all free space on your disk is consumed by them. This can happen if you are very low on both RAM and free disk space.
    https://discussions.apple.com/message/2232469?messageID=2232469&#2232469
    This gets more to the actual intent of your question...
    EDIT: Looks like some kind of glitch right now getting to the Dr. Smoke post.
    Message was edited by: WZZZ
    <Hyperlink Edited by Host>

  • I have purchased a macbook air with 64 gb hard disk. the available space is only 10gb. With this available space, i can't use the system effectively. kindly advise.

    I have purchased a macbook air with 64 gb hard disk. the available space is only 10gb. With this available space, i can't use the system effectively. kindly advise.

    You should have bought one with a larger SSD. You can regain some space by disabling the sleepimage file:
    To disable safe sleep, run the two following commands in Terminal:
    $ sudo pmset -a hibernatemode 0
    $ sudo nvram "use-nvramrc?"=false
    When done, restart your computer. Now go delete the file "/private/var/vm/sleepimage" to free up some hard drive space. When you put your computer to sleep it, should happen in under five seconds; my MacBook now goes to sleep in two seconds.
    [robg adds: To state the obvious, with safe sleep disabled, a total power loss will wipe out whatever was open on your machine. To enable safe sleep mode again, repeat the above commands, but change hibernatemode 0 on the first line to hibernatemode 3, and =false to =true on the second line. You'll then need to reboot again. Personally, I prefer the safe sleep mode, even with the slower sleep time and hard drive consumption -- even if for no other reason than it's great when changing batteries on a flight.]
    You can also delete unneeded files:
    Freeing Up Space on The Hard Drive
      1. See Lion/Mountain Lion's Storage Display.
      2. You can remove data from your Home folder except for the /Home/Library/ folder.
      3. Visit The XLab FAQs and read the FAQ on freeing up space on your hard drive.
      4. Also see Freeing space on your Mac OS X startup disk.
      5. See Where did my Disk Space go?.
      6. See The Storage Display.
    You must Empty the Trash in order to recover the space they occupied on the hard drive.
    You should consider replacing the drive with a larger one. Check out OWC for drives, tutorials, and toolkits.
    Try using OmniDiskSweeper 1.8 or GrandPerspective to search your drive for large files and where they are located.

  • How do I turn off the alt scroll zoom?  When I'm in Adobe photoshop and illustrator using the pen tool, alt is utilized for another short cut.  I would like to use the alt command for the pen tool instead of zooming into the screen.

    How do I turn off the alt scroll zoom? 
    When I'm in Adobe photoshop and illustrator using the pen tool, alt is utilized for another short cut.  I would like to use the alt command for the pen tool instead of zooming into the screen.

    I tend to select things from left to right and every time I am moving in a downward right diagonal motion during lasso selection I am missing a clear view and I am tending to have a more sloppy selection.  All this does is slow me down since I need to go back and hit those areas again.  The big arrowhead just get's in the way.  The original lasso tool with the thin line and small active point at it's lower left was far better for me.
    I don't like turning the cursors to precise because I like to see the active tool icon where my cursor is and as the icon changes as I hold modifier keys down.  If I am forced to get comfortable with using pricise cursors I guess I will, but man, I've never had to do this in my 15 years of photoshop use...
    I would absolutely LOVE to find a way to get the old lasso icon -- without the arrowhead above it.
    Is there any chance this option could be inlcuded in cursor preferences?  I'd give much thanks, Adobe.

  • G'day, i am trying to type into an adobe document using the typewriter function. However everytime after i type the text vanishes. It is almost as if the text is white and vanishes into the background. However this is not the case as the works are not vis

    G'day,
    I need some help, i am trying to type into an adobe document using the typewriter function.
    However every time after i type the text vanishes. It is almost as if the text is white and vanishes into the background.
    This is not the case as the works are not visible regardless of the background color.
    The text box remains available and can be edited if clicked on, also if i double click on it the typed words become visible and editable, however once i close the box i cannot see them on the screen.
    I would appreciate any help i can get, i cant seem to do anything using properties or view.
    Thanks 
    Tiernan

    Hi Sara,
    See response to your questions below:
    1.     Are you running into this issue in a specific PDF, or in all of them?
    A.     All of them
    2.     What version of Acrobat are you using (and, are you on Mac OS or Windows?).
    A.     Using Acrobat 10.0\Acrobat on Windows
    3.     If you look at the text properties on the Tools panel (under Format), what color is the text swatch?
    A.     Test swatch for the text is black
    4.     What happens if you change the text color?
    A.     Nothing.
    I look forward to hearing back from you.

  • Suddenly with version 9 and 10 i cant use the shortcut command of ctrl+shift+t to open the most recently closed tab.

    Suddenly with version 9 and 10 i cant use the shortcut command of ctrl+shift+t to open the most recently closed tab. a feature used several times a day, previously. This is very Frustrating to me, i have tried looking up a tool keyconfig 20110522 and looked that it says that ctrl+shift+t is the right command, but i still cant use it WHY oh WHY?? if i could get some help figuring this out it would be so awesome, cause i love Firefox, been using it almost daily for the last 10 or so years and i don't intend to switch soon.

    Hi,
    Please check if this happens in [https://support.mozilla.com/en-US/kb/Safe%20Mode Safe Mode.] This is a temporary diagnostic session and you can exit anytime and start Firefox normally again. This session disables all the '''Extensions''', themes ('''Appearance''') and '''Plugins''' in '''Tools''' ('''Alt''' + '''T''') > '''Add-ons'''.
    [http://kb.mozillazine.org/Problematic_extensions Problematic Extensions]
    [https://support.mozilla.com/en-US/kb/Troubleshooting%20extensions%20and%20themes Troubleshooting Extensions and Themes]
    [http://support.mozilla.com/en-US/kb/Uninstalling+add-ons Uninstalling Add-ons]
    [http://kb.mozillazine.org/Uninstalling_toolbars Uninstalling Toolbars]

  • HT5035 I have a credit from an Apple gift card. I want to buy itunes. When I go to check out it asks for my credit card info. How do I use the credit I have?

    How do I use the itunes credit I have on my MAC? I received a gift card and loaded it on my MAC. I want to buy itunes. When I go to check out it asks for my credit card info. How do I use the credit?

    Purchase and Redeem an iTunes Gift Card.
    How to Redeem a Code  >  http://support.apple.com/kb/ht1574

Maybe you are looking for

  • I've had my IPAD 2 2 mosths and still can't get it to backup.

    Thought I'd do this upgrade in itunes. Then upgrade IPAD several hours later Itune updated now I can't get past the backup to do the software upgrade. I'm thinking I've bought a pieces of Junk for $800.00.  No Support!! No Customer service!. Thinking

  • TestStand Deployment problems on Windows 2K3 x64

    Greeings: I'm hoping someone out there can advise me. I recently tried building a TS application to deploy on a server running WIndows Server 2003 x64, and I have run into a few difficulties.  On my development system, (32-bit WInXP pro) I built a TS

  • Issue with Real-Time data acquisition

    Hello, I'm using RDA to extract a non-standard transparent table (Z*) from  ECC to BI. When I launch my deamon, my infopackage and my DTP become yellow only 2/3 seconds and green just after, and no data are coming from ECC. If I check the deamon log

  • Issues ti Graph

    Hi Every, I am trying to implement Interactive graph By using Graph_2d Fm, In that I want to know how can I to interactive graph and what is the use of B_key, B_typ and M_typ. pleas help me  to implement this . Warm Regards Imran

  • Wireless Backup w/ time capsule

    I was thinking about getting time capsule. I do have a question about wireless backup though. I travel a lot and I wondered if I were to leave my time capsule at my house and travel out of town will I still be able to backup things on the time capsul