7
7
/*
8
8
============================================================
9
9
First created on: Mar/05/2021
10
- Last modified on: May/05 /2021
10
+ Last modified on: May/23 /2021
11
11
12
12
This toolkit's public GitHub URL:
13
13
https://github.com/IBMStreams/streamsx.eval_predicate
@@ -100,6 +100,13 @@ So, I took a fresh approach to write this new eval_predicate function
100
100
with my own ideas along with sufficient commentary to explain the logic.
101
101
That obviously led to implementation and feature differences between
102
102
the built-in evalPredicate and my new eval_predicate in this file.
103
+ As this toolkit evolved from start to finish, it ended up with
104
+ very good features needed to make it as a great rule processing
105
+ engine within the IBM Streams product. If positioned properly,
106
+ this can be a huge difference maker for IBM Streams in the
107
+ competitive marketplace. It will also help customers and partners
108
+ to create useful and powerful custom rule processors for many
109
+ use cases in different business domains.
103
110
============================================================
104
111
*/
105
112
#ifndef FUNCTIONS_H_
@@ -120,7 +127,8 @@ the built-in evalPredicate and my new eval_predicate in this file.
120
127
#include < tr1/unordered_map>
121
128
122
129
// ====================================================================
123
- // All the constants are defined here.
130
+ // All the constants are defined here. It covers all the
131
+ // error codes returned by the eval_predicate function.
124
132
#define ALL_CLEAR 0
125
133
#define EMPTY_EXPRESSION 1
126
134
#define MISSING_OPEN_TUPLE_TAG 2
@@ -283,6 +291,8 @@ namespace eval_predicate_functions {
283
291
// have a full evaluation plan made ready for use whenever
284
292
// needed. That will allow us to evaluate a given expression string
285
293
// using a readily available evaluation plan by executing its steps.
294
+ // In essence, it is a blueprint that defines the expression evaluation plan.
295
+ //
286
296
// Following is the class that represents the evaluation plan for a
287
297
// given expression. In this class, we store the data structures
288
298
// required to evaluate each subexpression present within a given
@@ -346,11 +356,29 @@ namespace eval_predicate_functions {
346
356
347
357
private:
348
358
// Private member variables.
359
+ // The entire user given expression is stored in this variable.
349
360
rstring expression;
361
+
362
+ // The schema literal for the tuple associated with a fully
363
+ // validated expression is stored in this variable.
350
364
rstring tupleSchema;
365
+
366
+ // This map contains the details about the different
367
+ // subexpressions present in a fully validated expression.
368
+ // It is important to understand the structure of this map which
369
+ // is explained in great detail throughout this file.
370
+ // One such explanation is available around line 635 of this file.
351
371
SPL::map<rstring, SPL::list<rstring> > subexpressionsMap;
372
+
373
+ // This list provides the subexpression map keys in sorted order.
352
374
SPL::list<rstring> subexpressionsMapKeys;
375
+
376
+ // This map contains the logical operators used within a subexpression.
377
+ // Key for this map is the subexpression id and the value is the logical operator.
353
378
SPL::map<rstring, rstring> intraNestedSubexpressionLogicalOperatorsMap;
379
+
380
+ // This list contains the logical operators used in between
381
+ // different subexpressions present in a user given expression string.
354
382
SPL::list<rstring> interSubexpressionLogicalOperatorsList;
355
383
};
356
384
@@ -423,7 +451,7 @@ namespace eval_predicate_functions {
423
451
void performCollectionSizeCheckEvalOperations (int32 const & lhsSize,
424
452
int32 const & rhsInt32, rstring const & operationVerb,
425
453
boolean & subexpressionEvalResult, int32 & error);
426
- // Perform relational or arithmetic eval operatios .
454
+ // Perform relational or arithmetic eval operations .
427
455
template <class T1 >
428
456
void performRelationalOrArithmeticEvalOperations (T1 const & lhsValue,
429
457
T1 const & rhsValue, rstring const & operationVerb,
@@ -488,7 +516,6 @@ namespace eval_predicate_functions {
488
516
SPL::map<rstring, rstring> const & tupleAttributesMap,
489
517
SPL::list<rstring> const & attributeNameLayoutList,
490
518
T1 const & myTuple, T2 & value, int32 & error, boolean trace);
491
-
492
519
// ====================================================================
493
520
494
521
// Evaluate a given expression.
@@ -602,7 +629,7 @@ namespace eval_predicate_functions {
602
629
}
603
630
604
631
// If trace is enabled let us do the introspection of the
605
- // user provided tuple and display its sttribute names and values.
632
+ // user provided tuple and display its attribute names and values.
606
633
traceTupleAtttributeNamesAndValues (myTuple, tupleAttributesMap, trace);
607
634
608
635
// Note: The space below between > > is a must. Otherwise, compiler will give an error.
@@ -740,7 +767,7 @@ namespace eval_predicate_functions {
740
767
} // End of the else block.
741
768
742
769
// We have a valid iterator from the eval plan cache for the given expression.
743
- // We can go ahead execute the evaluation plan now.
770
+ // We can go ahead and execute the evaluation plan now.
744
771
SPLAPPTRC (L_TRACE, " Begin timing measurement 4" , " ExpressionEvaluation" );
745
772
// We are making a non-recursive call.
746
773
result = evaluateExpression (it->second , myTuple, error, trace);
@@ -1022,7 +1049,7 @@ namespace eval_predicate_functions {
1022
1049
1023
1050
// The attribute name of this nested tuple is just after the
1024
1051
// close angle bracket where we are at now. Let us parse that tuple name.
1025
- // Let us locate either the comma or an angle bracket after thetuple name.
1052
+ // Let us locate either the comma or an angle bracket after the tuple name.
1026
1053
int32 idx3 = -1 ;
1027
1054
1028
1055
for (int x=idx2+1 ; x<stringLength; x++) {
@@ -10181,3 +10208,33 @@ namespace eval_predicate_functions {
10181
10208
// ====================================================================
10182
10209
10183
10210
#endif
10211
+
10212
+ /*
10213
+ ==================================================================
10214
+ Coda
10215
+ ----
10216
+ Whatever lies ahead for IBM Streams beyond June/2021, I'm proud to
10217
+ have played a key role in this product team from 2007 to 2021.
10218
+ IBM Streams gave me so many marvelous opportunities to create
10219
+ amazing extensions, build cutting edge streaming analytics solutions,
10220
+ coach/train top notch customers and co-create meaningful
10221
+ production-ready software assets for such customers. It formed the
10222
+ best period in my 36 years of Software career thus far. I'm lucky to
10223
+ get a chance to build this toolkit as my final official project for
10224
+ IBM Streams. That too for meeting a critical business need of a
10225
+ prestigious customer in the semiconductor manufacturing industry.
10226
+ This particular toolkit is technically challenging and
10227
+ super interesting. I'm glad that it serves as a bookend for my
10228
+ technical contributions to the incomparable IBM Streams. I'm hopeful
10229
+ that I will get another chance to associate with this wonderful
10230
+ product as it finds a new home soon either inside or outside of IBM.
10231
+ Until then, I will continue to reminisce this unforgettable journey
10232
+ made possible by passionate researchers, engineers and managers who
10233
+ are all simply world class in their talent and camaraderie.
10234
+
10235
+ Long live IBM Streams.
10236
+
10237
+ Yours truly,
10238
+ SN
10239
+ ==================================================================
10240
+ */
0 commit comments