77/*
88============================================================
99First created on: Mar/05/2021
10- Last modified on: June/07 /2021
10+ Last modified on: Sep/03 /2021
1111
1212This toolkit's public GitHub URL:
1313https://github.com/IBMStreams/streamsx.eval_predicate
@@ -29,7 +29,8 @@ given expression (rule) to have operational verbs such as
2929contains, startsWith, endsWith, notContains, notStartsWith,
3030notEndsWith, in. For case insensitive (CI) string operations, these
3131operational verbs can be used: containsCI, startsWithCI,
32- endsWithCI, notContainsCI, notStartsWithCI, notEndsWithCI, inCI
32+ endsWithCI, inCI, equalsCI, notContainsCI, notStartsWithCI,
33+ notEndsWithCI, notEqualsCI.
3334For checking the size of the set, list and map, these
3435operational verbs can be used: sizeEQ, sizeNE, sizeLT,
3536sizeLE, sizeGT, sizeGE
@@ -40,9 +41,10 @@ sizeLE, sizeGT, sizeGE
4041--> It supports these arithmetic operations: +, -, *, /, %
4142--> It supports these special operations for rstring, set, list and map:
4243 contains, startsWith, endsWith, notContains, notStartsWith,
43- notEndsWith, in, containsCI, startsWithCI, endsWithCI, notContainsCI,
44- notStartsWithCI, notEndsWithCI, inCI, sizeEQ, sizeNE, sizeLT,
45- sizeLE, sizeGT, sizeGE
44+ notEndsWith, in, containsCI, startsWithCI, endsWithCI,
45+ inCI, equalsCI, notContainsCI, notStartsWithCI,
46+ notEndsWithCI, notEqualsCI,
47+ sizeEQ, sizeNE, sizeLT, sizeLE, sizeGT, sizeGE
4648--> No bitwise operations are supported at this time.
4749
48505) Following are the data types currently allowed in an expression (rule).
@@ -276,11 +278,12 @@ use cases in different business domains.
276278#define INCOMPATIBLE_NOT_ENDS_WITH_CI_OPERATION_FOR_LHS_ATTRIB_TYPE 145
277279#define INCOMPATIBLE_IN_OPERATION_FOR_LHS_ATTRIB_TYPE 146
278280#define INCOMPATIBLE_IN_CI_OPERATION_FOR_LHS_ATTRIB_TYPE 147
279- #define UNABLE_TO_PARSE_RHS_VALUE 148
280- #define RHS_VALUE_WITH_MISSING_OPEN_BRACKET_NO_MATCH_FOR_IN_OR_IN_CI_OPVERB 149
281- #define RHS_VALUE_WITH_MISSING_CLOSE_BRACKET_NO_MATCH_FOR_IN_OR_IN_CI_OPVERB 150
282- #define INVALID_RHS_LIST_LITERAL_STRING_FOUND_FOR_IN_OR_IN_CI_OPVERB 151
283-
281+ #define INCOMPATIBLE_EQUALS_CI_OPERATION_FOR_LHS_ATTRIB_TYPE 148
282+ #define INCOMPATIBLE_NOT_EQUALS_CI_OPERATION_FOR_LHS_ATTRIB_TYPE 149
283+ #define UNABLE_TO_PARSE_RHS_VALUE 150
284+ #define RHS_VALUE_WITH_MISSING_OPEN_BRACKET_NO_MATCH_FOR_IN_OR_IN_CI_OPVERB 151
285+ #define RHS_VALUE_WITH_MISSING_CLOSE_BRACKET_NO_MATCH_FOR_IN_OR_IN_CI_OPVERB 152
286+ #define INVALID_RHS_LIST_LITERAL_STRING_FOUND_FOR_IN_OR_IN_CI_OPVERB 153
284287// ====================================================================
285288// Define a C++ namespace that will contain our native function code.
286289namespace eval_predicate_functions {
@@ -2042,14 +2045,14 @@ namespace eval_predicate_functions {
20422045 // We support these arithmetic operations: +, -, *, /, %
20432046 // Special operations:
20442047 // contains, startsWith, endsWith, notContains, notStartsWith, notEndsWith, in,
2045- // containsCI, startsWithCI, endsWithCI, notContainsCI ,
2046- // notStartsWithCI, notEndsWithCI, inCI, sizeEQ, sizeNE, sizeLT ,
2047- // sizeLE, sizeGT, sizeGE
2048+ // containsCI, startsWithCI, endsWithCI, inCI, equalsCI ,
2049+ // notContainsCI, notStartsWithCI, notEndsWithCI, notEqualsCI ,
2050+ // sizeEQ, sizeNE, sizeLT, sizeLE, sizeGT, sizeGE
20482051 // No bitwise operations are supported at this time.
20492052 rstring relationalAndArithmeticOperations =
20502053 rstring (" ==,!=,<=,<,>=,>,+,-,*,/,%," ) +
2051- rstring (" containsCI,startsWithCI,endsWithCI," ) +
2052- rstring (" notContainsCI,notStartsWithCI,notEndsWithCI,inCI ," ) +
2054+ rstring (" containsCI,startsWithCI,endsWithCI,inCI,equalsCI, " ) +
2055+ rstring (" notContainsCI,notStartsWithCI,notEndsWithCI,notEqualsCI ," ) +
20532056 rstring (" contains,startsWith,endsWith," ) +
20542057 rstring (" notContains,notStartsWith,notEndsWith,in," ) +
20552058 rstring (" sizeEQ,sizeNE,sizeLT,sizeLE,sizeGT,sizeGE" );
@@ -3357,9 +3360,9 @@ namespace eval_predicate_functions {
33573360 // ==, !=, <, <=, >, >=
33583361 // +, -, *, /, %
33593362 // contains, startsWith, endsWith, notContains, notStartsWith,
3360- // notEndsWith, in, containsCI, startsWithCI, endsWithCI, notContainsCI ,
3361- // notStartsWithCI, notEndsWithCI, inCI, sizeEQ, sizeNE, sizeLT ,
3362- // sizeLE, sizeGT, sizeGE
3363+ // notEndsWith, in, containsCI, startsWithCI, endsWithCI, inCI, equalsCI ,
3364+ // notContainsCI, notStartsWithCI, notEndsWithCI, notEqualsCI ,
3365+ // sizeEQ, sizeNE, sizeLT, sizeLE, sizeGT, sizeGE
33633366 // e-g:
33643367 // a == "hi" && b contains "xyz" && g[4] > 6.7 && id % 8 == 3
33653368 // (a == "hi") && (b contains "xyz" || g[4] > 6.7 || id % 8 == 3)
@@ -3887,8 +3890,10 @@ namespace eval_predicate_functions {
38873890 currentOperationVerb == " notEndsWith" ||
38883891 currentOperationVerb == " startsWithCI" ||
38893892 currentOperationVerb == " endsWithCI" ||
3893+ currentOperationVerb == " equalsCI" ||
38903894 currentOperationVerb == " notStartsWithCI" ||
3891- currentOperationVerb == " notEndsWithCI" ) {
3895+ currentOperationVerb == " notEndsWithCI" ||
3896+ currentOperationVerb == " notEqualsCI" ) {
38923897 if (lhsAttribType != " rstring" &&
38933898 lhsAttribType != " list<rstring>" &&
38943899 lhsAttribType != " map<rstring,rstring>" &&
@@ -3909,10 +3914,14 @@ namespace eval_predicate_functions {
39093914 error = INCOMPATIBLE_STARTS_WITH_CI_OPERATION_FOR_LHS_ATTRIB_TYPE;
39103915 } else if (currentOperationVerb == " endsWithCI" ) {
39113916 error = INCOMPATIBLE_ENDS_WITH_CI_OPERATION_FOR_LHS_ATTRIB_TYPE;
3917+ } else if (currentOperationVerb == " equalsCI" ) {
3918+ error = INCOMPATIBLE_EQUALS_CI_OPERATION_FOR_LHS_ATTRIB_TYPE;
39123919 } else if (currentOperationVerb == " notStartsWithCI" ) {
39133920 error = INCOMPATIBLE_NOT_STARTS_WITH_CI_OPERATION_FOR_LHS_ATTRIB_TYPE;
3914- } else {
3921+ } else if (currentOperationVerb == " notEndsWithCI " ) {
39153922 error = INCOMPATIBLE_NOT_ENDS_WITH_CI_OPERATION_FOR_LHS_ATTRIB_TYPE;
3923+ } else {
3924+ error = INCOMPATIBLE_NOT_EQUALS_CI_OPERATION_FOR_LHS_ATTRIB_TYPE;
39163925 }
39173926
39183927 return (false );
@@ -7582,8 +7591,8 @@ namespace eval_predicate_functions {
75827591 // Allowed operations for rstring are these:
75837592 // ==, !=, contains, notContains, startsWith,
75847593 // notStartsWith, endsWith, notEndsWith, in,
7585- // containsCI, startsWithCI, endsWithCI, notContainsCI ,
7586- // notStartsWithCI, notEndsWithCI, inCI , sizeXX
7594+ // containsCI, startsWithCI, endsWithCI, inCI, equalsCI ,
7595+ // notContainsCI, notStartsWithCI, notEndsWithCI, notEqualsCI , sizeXX
75877596 if (operationVerb == " ==" ) {
75887597 subexpressionEvalResult = (lhsValue == rhsValue) ? true : false ;
75897598 } else if (operationVerb == " !=" ) {
@@ -7791,6 +7800,14 @@ namespace eval_predicate_functions {
77917800 subexpressionEvalResult = true ;
77927801 }
77937802 }
7803+ } else if (operationVerb == " equalsCI" ) {
7804+ rstring lhsValueLower = Functions::String::lower (lhsValue);
7805+ rstring rhsValueLower = Functions::String::lower (rhsValue);
7806+ subexpressionEvalResult = (lhsValueLower == rhsValueLower) ? true : false ;
7807+ } else if (operationVerb == " notEqualsCI" ) {
7808+ rstring lhsValueLower = Functions::String::lower (lhsValue);
7809+ rstring rhsValueLower = Functions::String::lower (rhsValue);
7810+ subexpressionEvalResult = (lhsValueLower != rhsValueLower) ? true : false ;
77947811 } else if (operationVerb == " sizeEQ" ) {
77957812 subexpressionEvalResult = false ;
77967813 int32 lhsSize = Functions::String::length (lhsValue);
@@ -10508,16 +10525,17 @@ Coda
1050810525Whatever path lies ahead for IBM Streams beyond 2Q2021, I'm proud to have
1050910526played a key role in this product team from 2007 to 2021. IBM Streams
1051010527gave me marvelous opportunities to create beautiful extensions, build
10511- cutting edge streaming analytics solutions, coach/train top notch customers
10528+ cutting edge streaming analytics solutions, coach/train top- notch customers
1051210529and co-create meaningful production-grade software assets with them. Thus far,
1051310530it formed the best period in my 36 years of Software career. I created
1051410531this challenging Rule Processing toolkit for meeting a critical business need
1051510532of a prestigious customer in the semiconductor industry. Most likely, it is the
1051610533last hurrah in my technical contributions to the incomparable IBM Streams.
1051710534I will be thrilled to get another chance to associate with this wonderful
10518- product if it finds a new home either inside or outside of IBM. Until then,
10519- I will continue to reminisce this unforgettable journey made possible by the
10520- passionate researchers, engineers and managers who are all simply world class.
10535+ product if it finds a new home for further development either inside or
10536+ outside of IBM. Until then, I will continue to reminisce this unforgettable
10537+ journey made possible by the passionate researchers, engineers and managers
10538+ who are all simply world class.
1052110539
1052210540It will take many more years for some other company or an open-source group to
1052310541roll out a full-featured product that can be a true match for IBM Streams.
0 commit comments