untyped adapter - create c# class at runtime

Отвечено untyped adapter - create c# class at runtime

  • Monday, November 14, 2011 2:33 PM
     
     

    Is it possible to create an untyped adapter, which creates a C# class, based on a data structure the app gets, at runtime? This would be opposed to creating a class at design time. The application has no prior knowledge about the structure of the data.

    Please provide a link, if such an example / hints on this topic exist(s).

     

    Thanks

     


All Replies

  • Tuesday, November 15, 2011 2:50 PM
     
     

    I'm not really sure that I understand your full use case here. "The application has no prior knowledge" ... ummm ... that would make it pretty hard to write the queries, wouldn't it?

    However, untyped adapters do provide a great deal of flexibility when it comes to enqueuing events. When your adapter is started, you get the CepEventType that has all of the fields that the starting query is expecting ... that is, the query "controls" the schema. This class will tell you the names of the fields, their types and their ordinal. You then use this information to enqueue the data for the event using event.SetField(). From an implementation perspective, it's easiest if your data source fields map directly to the CepEventType fields ... for example, if you are reading from a database, the field names map to the CepEventType field names. If not, you'll have to have some sort of mapping layer between the source fields and the destination fields.

    Make sense?


    DevBiker (aka J Sawyer)
    My Blog

    If I answered your question, please mark as answer.
    If my post was helpful, please mark as helpful.
  • Tuesday, November 15, 2011 3:54 PM
     
     

    Hello,

    I think I saw smth similar to what you're talking about in a post from StreamInsight Twitter. So it doesn't make much sense now, but I'll get back here once it does.

    I have this (not final) scenario in mind. The application doesn't have prior runtime knowledge about the schema of an input stream. During runtime, it gets the stream schema (I implemented this part): (A int, B string). The app presents this schema to a user. Based on the schema, the user can write text queries (using the excellent QueryTemplateScripter you talked about here ). In order to do this I think I need to implement a C# class streamSchema {public int A; public string B} at runtime. I hope I'm not missing anything here.

    C.

  • Tuesday, November 15, 2011 3:56 PM
     
     Answered

    OK ... that makes sense then. The query writer does have knowledge about the schema.

    You should be able to do this with an untyped input adapter. The biggest challenge is making sure that the fields that they query expects are enqueued from the data source ... so the query writer will have to have some knowledge of the source fields or provide a mapping.


    DevBiker (aka J Sawyer)
    My Blog

    If I answered your question, please mark as answer.
    If my post was helpful, please mark as helpful.
    • Marked As Answer by KJian_ Tuesday, November 22, 2011 6:20 AM
    •