C++ Example

Here is an example C++ continuous query. SAS Micro Analytic Service related method calls are highlighted. Error checking code has been removed to emphasize the main elements of the program, but should always be included in production.
// Initialize the SAS Event Stream Processing
// Engine and create a project.
dfESPengine *myEngine = dfESPengine::initialize(argc,
   argv, "engine", pubsub_DISABLE);
dfESPproject  *project_01 = myEngine->newProject("project_01");

// Publish a DS2 module to SAS Micro Analytic Service,
// in this case a credit risk scoring model.
project_01->publishFileToMAS("credit_risk", DS2,
   "./credit_risk.ds2", "Credit Risk Model");

// Create a continuous query containing source and procedural windows.
dfESPcontquery  *cq_01 = project_01->newContquery("contquery_01");
sw_01 = cq_01->newWindow_source("sourceWindow_01",
dfESPindextypes::pi_HASH,dfESPstring("ID*:int32,custid:int32,
   loanid:int32,amount:money"));
dfESPwindow_procedural *pw_01;
pw_01 = cq_01->newWindow_procedural("proceduralWindow_01",
dfESPindextypes::pi_RBTREE, dfESPstring("ID*:int32,risk_score:double,
   derog_remarks:string"));
dfESPpcontext *ctxt = new dfESPpcontext();

// Register the score() method of the credit_risk module to process
// the source window’s events.
ctxt->registerMethod_MAS(sw_01, "credit_risk", "score");

// Add an edge (directed arrow) between the two windows and start the project.
pw_01->registerMethodContext(ctxt);
cq_01->addEdge(sw_01, pw_01);
project_01->setNumThreads(2);
myEngine->startProjects();
Last updated: March 2, 2017