Skip to content

Commit 1651510

Browse files
author
Senthil Nathan
committed
Changes done for v1.1.1.
1 parent 0b9ca45 commit 1651510

File tree

5 files changed

+87
-40
lines changed

5 files changed

+87
-40
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes
22

3+
## v1.1.1
4+
* Sep/04/2021
5+
* Added two new operational verbs: equalsCI and notEqualsCI.
6+
37
## v1.1.0
48
* June/07/2021
59
* Modified it to support the in operational verb for int32, float64 and rstring based tuple attributes and the inCI operational verb only for rstring based tuple attributes.

com.ibm.streamsx.eval_predicate/EvalPredicateExample.spl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/*
99
==================================================================
1010
First created on: Mar/05/2021
11-
Last modified on: June/07/2021
11+
Last modified on: Sep/04/2021
1212

1313
This is an example application that shows how to use the
1414
eval_predicate function to evaluate an SPL expression a.k.a
@@ -38,7 +38,8 @@ given expression (rule) to have operational verbs such as
3838
contains, startsWith, endsWith, notContains, notStartsWith,
3939
notEndsWith, in. For case insensitive (CI) string operations, these
4040
operational verbs can be used: containsCI, startsWithCI,
41-
endsWithCI, notContainsCI, notStartsWithCI, notEndsWithCI, inCI
41+
endsWithCI, inCI, equalsCI, notContainsCI, notStartsWithCI,
42+
notEndsWithCI, notEqualsCI.
4243
For checking the size of the set, list and map, these
4344
operational verbs can be used: sizeEQ, sizeNE, sizeLT,
4445
sizeLE, sizeGT, sizeGE
@@ -49,9 +50,9 @@ sizeLE, sizeGT, sizeGE
4950
--> It supports these arithmetic operations: +, -, *, /, %
5051
--> It supports these special operations for rstring, set, list and map:
5152
contains, startsWith, endsWith, notContains, notStartsWith,
52-
notEndsWith, in, containsCI, startsWithCI, endsWithCI, notContainsCI,
53-
notStartsWithCI, notEndsWithCI, inCI, sizeEQ, sizeNE, sizeLT,
54-
sizeLE, sizeGT, sizeGE
53+
notEndsWith, in, containsCI, startsWithCI, endsWithCI, inCI, equalsCI,
54+
notContainsCI, notStartsWithCI, notEndsWithCI, notEqualsCI,
55+
sizeEQ, sizeNE, sizeLT, sizeLE, sizeGT, sizeGE
5556
--> No bitwise operations are supported at this time.
5657

5758
5) Following are the data types currently allowed in an expression (rule).

com.ibm.streamsx.eval_predicate/FunctionalTests.spl

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/*
99
==================================================================
1010
First created on: Mar/28/2021
11-
Last modified on: June/07/2021
11+
Last modified on: Sep/04/2021
1212

1313
This application is meant for doing several hundred
1414
functional tests to provide as much coverage as possible to
@@ -1336,9 +1336,9 @@ composite FunctionalTests {
13361336
printStringLn("Testcase A8.15: Evaluation execution failed. Error=" + (rstring)error);
13371337
}
13381338

1339-
// A8.16 (rstring notContainsCI operation verb)
1340-
_rule = "(symbol notContainsCI 'intc')";
1341-
result = eval_predicate(_rule, _myTicker, error, $EVAL_PREDICATE_TRACING);
1339+
// A8.16 (rstring equalsCI operation verb)
1340+
_rule = "(a.transport.plane.airliner equalsCI 'bOeInG')";
1341+
result = eval_predicate(_rule, _myTestData, error, $EVAL_PREDICATE_TRACING);
13421342

13431343
if(result == true) {
13441344
printStringLn("Testcase A8.16: Evaluation criteria is met.");
@@ -1348,8 +1348,8 @@ composite FunctionalTests {
13481348
printStringLn("Testcase A8.16: Evaluation execution failed. Error=" + (rstring)error);
13491349
}
13501350

1351-
// A8.17 (rstring notStartsWithCI operation verb)
1352-
_rule = "(symbol notStartsWithCI 'iB')";
1351+
// A8.17 (rstring notContainsCI operation verb)
1352+
_rule = "(symbol notContainsCI 'intc')";
13531353
result = eval_predicate(_rule, _myTicker, error, $EVAL_PREDICATE_TRACING);
13541354

13551355
if(result == true) {
@@ -1360,8 +1360,8 @@ composite FunctionalTests {
13601360
printStringLn("Testcase A8.17: Evaluation execution failed. Error=" + (rstring)error);
13611361
}
13621362

1363-
// A8.18 (rstring notEndsWithCI operation verb)
1364-
_rule = "(symbol notEndsWithCI 'Bm')";
1363+
// A8.18 (rstring notStartsWithCI operation verb)
1364+
_rule = "(symbol notStartsWithCI 'iB')";
13651365
result = eval_predicate(_rule, _myTicker, error, $EVAL_PREDICATE_TRACING);
13661366

13671367
if(result == true) {
@@ -1370,7 +1370,31 @@ composite FunctionalTests {
13701370
printStringLn("Testcase A8.18: Evaluation criteria is not met.");
13711371
} else {
13721372
printStringLn("Testcase A8.18: Evaluation execution failed. Error=" + (rstring)error);
1373+
}
1374+
1375+
// A8.19 (rstring notEndsWithCI operation verb)
1376+
_rule = "(symbol notEndsWithCI 'Bm')";
1377+
result = eval_predicate(_rule, _myTicker, error, $EVAL_PREDICATE_TRACING);
1378+
1379+
if(result == true) {
1380+
printStringLn("Testcase A8.19: Evaluation criteria is met.");
1381+
} else if(result == false && error == 0) {
1382+
printStringLn("Testcase A8.19: Evaluation criteria is not met.");
1383+
} else {
1384+
printStringLn("Testcase A8.19: Evaluation execution failed. Error=" + (rstring)error);
13731385
}
1386+
1387+
// A8.20 (rstring equalsCI operation verb)
1388+
_rule = "(a.transport.plane.airliner notEqualsCI 'bOeInK')";
1389+
result = eval_predicate(_rule, _myTestData, error, $EVAL_PREDICATE_TRACING);
1390+
1391+
if(result == true) {
1392+
printStringLn("Testcase A8.20: Evaluation criteria is met.");
1393+
} else if(result == false && error == 0) {
1394+
printStringLn("Testcase A8.20: Evaluation criteria is not met.");
1395+
} else {
1396+
printStringLn("Testcase A8.20: Evaluation execution failed. Error=" + (rstring)error);
1397+
}
13741398
// -------------------------
13751399

13761400
// A9.1 (rstring contains operation verb)

impl/include/eval_predicate.h

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/*
88
============================================================
99
First created on: Mar/05/2021
10-
Last modified on: June/07/2021
10+
Last modified on: Sep/03/2021
1111
1212
This toolkit's public GitHub URL:
1313
https://github.com/IBMStreams/streamsx.eval_predicate
@@ -29,7 +29,8 @@ given expression (rule) to have operational verbs such as
2929
contains, startsWith, endsWith, notContains, notStartsWith,
3030
notEndsWith, in. For case insensitive (CI) string operations, these
3131
operational verbs can be used: containsCI, startsWithCI,
32-
endsWithCI, notContainsCI, notStartsWithCI, notEndsWithCI, inCI
32+
endsWithCI, inCI, equalsCI, notContainsCI, notStartsWithCI,
33+
notEndsWithCI, notEqualsCI.
3334
For checking the size of the set, list and map, these
3435
operational verbs can be used: sizeEQ, sizeNE, sizeLT,
3536
sizeLE, 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
4850
5) 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.
286289
namespace 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
1050810525
Whatever path lies ahead for IBM Streams beyond 2Q2021, I'm proud to have
1050910526
played a key role in this product team from 2007 to 2021. IBM Streams
1051010527
gave 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
1051210529
and co-create meaningful production-grade software assets with them. Thus far,
1051310530
it formed the best period in my 36 years of Software career. I created
1051410531
this challenging Rule Processing toolkit for meeting a critical business need
1051510532
of a prestigious customer in the semiconductor industry. Most likely, it is the
1051610533
last hurrah in my technical contributions to the incomparable IBM Streams.
1051710534
I 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
1052210540
It will take many more years for some other company or an open-source group to
1052310541
roll out a full-featured product that can be a true match for IBM Streams.

info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<info:identity>
55
<info:name>eval_predicate</info:name>
66
<info:description>Toolkit for user defined rule (expression) processing</info:description>
7-
<info:version>1.1.0</info:version>
7+
<info:version>1.1.1</info:version>
88
<info:requiredProductVersion>4.2.1.6</info:requiredProductVersion>
99
</info:identity>
1010
<info:dependencies/>

0 commit comments

Comments
 (0)