Skip to content

Commit 806c1d6

Browse files
author
Senthil Nathan
committed
Changes done for v1.1.7.
1 parent 730caa6 commit 806c1d6

File tree

5 files changed

+43
-20
lines changed

5 files changed

+43
-20
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.7
4+
* Sep/27/2023
5+
* Made a fix to correctly evaluate a new multi-level nested expression pattern as shown in the test case A51.21 in FunctionalTests.spl.
6+
37
## v1.1.6
48
* Sep/20/2023
59
* Made a major redesign to evaluate multi-level nested subexpressions.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ This toolkit came into existence for a specific need with which a large enterpri
279279
(a.transport.plane.airliner equalsCI 'bOeInG' && a.transport.cars.autoMaker equalsCI 'Enzo Ferrari') && ((testId equalsCI 'Happy Path' && a.rack.hw.vendor equalsCI 'Intel') || ((a.transport.plane.airliner equalsCI 'bOeInG2' || testId equalsCI 'Happy Path') && (a.transport.cars.autoMaker equalsCI 'Enzo Ferrari') && (a.transport.plane.airliner equalsCI 'bOeInG')) || (testId equalsCI 'Happy Path' && testId equalsCI 'Happy Path') || (testId equalsCI 'Happy Path7' && testId equalsCI 'Happy Path')) && (testId equalsCI 'Happy Path')
280280

281281
(a.transport.plane.airliner equalsCI 'bOeInG' && (a.transport.cars.autoMaker equalsCI 'Enzo Ferrari' || (testId equalsCI 'Happy Path' || a.rack.hw.vendor equalsCI 'Intel2'))) && ((testId equalsCI 'Happy Path' && a.rack.hw.vendor equalsCI 'Intel') || ((a.transport.plane.airliner equalsCI 'bOeInG2' || testId equalsCI 'Happy Path') && (a.transport.cars.autoMaker equalsCI 'Enzo Ferrari') && (a.transport.plane.airliner equalsCI 'bOeInG')) || (testId equalsCI 'Happy Path' && testId equalsCI 'Happy Path') || (testId equalsCI 'Happy Path7' && testId equalsCI 'Happy Path')) && (testId equalsCI 'Happy Path')
282+
283+
(a.transport.plane.airliner equalsCI 'bOeInG') && (a.transport.cars.autoMaker equalsCI 'Enzo Ferrari') && ((testId equalsCI 'Happy Path') && ((a.rack.hw.vendor equalsCI 'Intel') || ((a.transport.cars.autoMaker equalsCI 'Enzo Ferrari') && (a.transport.plane.airliner equalsCI 'bOeInG'))))
282284

283285
## Source code
284286
The complete C++ logic for the **eval_predicate** function is available in the [eval_predicate.h](impl/include/eval_predicate.h) file of this repository.

com.ibm.streamsx.eval_predicate/FunctionalTests.spl

Lines changed: 17 additions & 1 deletion
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: Sep/20/2023
11+
Last modified on: Sep/27/2023
1212

1313
This application is meant for doing several hundred
1414
functional tests to provide as much coverage as possible to
@@ -6945,6 +6945,22 @@ composite FunctionalTests {
69456945
} else {
69466946
printStringLn("Testcase A51.20: Evaluation execution failed. Error=" + (rstring)error);
69476947
}
6948+
6949+
// A51.21 (Nested expression pattern 21)
6950+
// The following is a rule that has the first two subexpressions
6951+
// as self-enclosed. It then has the next subexpression with
6952+
// three levels of multi-level nested SEs.
6953+
_rule = "(a.transport.plane.airliner equalsCI 'bOeInG') && (a.transport.cars.autoMaker equalsCI 'Enzo Ferrari') && ((testId equalsCI 'Happy Path') && ((a.rack.hw.vendor equalsCI 'Intel') || ((a.transport.cars.autoMaker equalsCI 'Enzo Ferrari') && (a.transport.plane.airliner equalsCI 'bOeInG'))))";
6954+
6955+
result = eval_predicate(_rule, _myTestData, error, $EVAL_PREDICATE_TRACING);
6956+
6957+
if(result == true) {
6958+
printStringLn("Testcase A51.21: Evaluation criteria is met.");
6959+
} else if(result == false && error == 0) {
6960+
printStringLn("Testcase A51.21: Evaluation criteria is not met.");
6961+
} else {
6962+
printStringLn("Testcase A51.21: Evaluation execution failed. Error=" + (rstring)error);
6963+
}
69486964
// -------------------------
69496965

69506966
// A52.1 (list<TUPLE>)

impl/include/eval_predicate.h

Lines changed: 19 additions & 18 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: Sep/20/2023
10+
Last modified on: Sep/27/2023
1111
Author(s): Senthil Nathan ([email protected])
1212

1313
This toolkit's public GitHub URL:
@@ -1993,7 +1993,7 @@ namespace eval_predicate_functions {
19931993
// the usage of attributes (LHS), operations performed (in the middle),
19941994
// the values to be compared (RHS) and the intra subexpression logical
19951995
// operators if any. By building that structure once here,
1996-
// it can be reused when the user application ode calls the eval_predicate
1996+
// it can be reused when the user application code calls the eval_predicate
19971997
// function available in this file repeatedly for evaluating a
19981998
// given expression. It will help in improving the expression evaluation performance.
19991999
// This subexpression layout list will have a sequence of items as shown below.
@@ -2402,7 +2402,7 @@ namespace eval_predicate_functions {
24022402

24032403
Please search for Sep/20/2023 in this file to get a broader
24042404
understanding of how I handle the multi-level nested subexpressions.
2405-
As always, I only tested half a dozen example expressions that include
2405+
As always, I only tested a dozen example expressions that include
24062406
multi-level nested SEs. There will definitely be other forms
24072407
of multi-level nested SEs that are not handled adequately.
24082408
If that happens in the field, I will have to do more
@@ -2439,7 +2439,7 @@ namespace eval_predicate_functions {
24392439
NestedSubexpressionId="2.2.1.2.4.1", Logical operator="||"
24402440

24412441
Test cases covering the multi-level nested subexpressions can be found in the
2442-
EvalPredicateExample.spl (3.7 to 3.12) and FunctionalTests.spl (A51.1 to A51.20).
2442+
EvalPredicateExample.spl (3.7 to 3.12) and FunctionalTests.spl (A51.1 to A51.21).
24432443
*********************************************************
24442444
*/
24452445

@@ -2540,24 +2540,25 @@ namespace eval_predicate_functions {
25402540

25412541
boolean breakFromOpenParenthesisProcessingWhileLoopIfNeeded = true;
25422542

2543-
// There are special cases such as the A51.20 test case in
2543+
// There are special test cases such as the A51.20 and A51.21 in
25442544
// FunctionalTests.spl will have a reason for us to meet the
25452545
// condition in this if block.
2546-
if((subexpressionId == "") && ((idx > 0) && (myBlob[idx-1] == '('))) {
2547-
// If we get inside this if block, then we have met these conditions.
2546+
// Senthil made a change in the following statement on Sep/27/2023.
2547+
if(idx > 0 && myBlob[idx-1] == '(') {
2548+
// If we reach inside this if block, then we have met these conditions.
25482549
// selol size is non-zero.
25492550
// We encountered a new OP.
2550-
// SE Id is an empty string.
2551-
// That means, we already completed validating
2552-
// the very first SE in the full expression.
2553-
// Since we also passed the test for finding the
2554-
// previous character as another OP, it is an indication
2551+
// SE Id is either an empty string or a non-empty string.
2552+
// These conditions indicate that we already completed validating
2553+
// the previous SE we encountered in the given expression.
2554+
// Since we also passed the test for finding that the
2555+
// previous character is another OP, it is an indication
25552556
// that there is a new nested SE starting right after the
2556-
// entire expression's very first SE that we just now
2557+
// previously completed SE that we just now
25572558
// validated. In this case, let us not break from the
2558-
// OP processing white loop so that it can continue to
2559-
// create the very first SE id of this entire expression as
2560-
// 1.1 right here in this iteration of the OP processing while loop.
2559+
// OP processing while loop so that it can continue to
2560+
// create the SE id of the previously completed subexpression
2561+
// right here in this iteration of the OP processing while loop.
25612562
// So, let us not give a chance for the next if-block to
25622563
// break from the OP processing based on that if block's
25632564
// conditional check result.
@@ -2663,7 +2664,7 @@ namespace eval_predicate_functions {
26632664
// We are going to declare the end of this nested subexpression.
26642665
subexpressionLayoutList[selolSize - 1] = "";
26652666

2666-
// Test cases such as A51.19 and A51.20 in FunctionalTests.spl will make it to
2667+
// Test cases such as A51.19 to A51.21 in FunctionalTests.spl will make it to
26672668
// go via this part of the OP processing logic.
26682669
if(trace == true) {
26692670
cout << "_HHHHH_03 Inside the OP processing block just before getting " <<
@@ -2696,7 +2697,7 @@ namespace eval_predicate_functions {
26962697
// If it is a multi-level nested expression, then we have to call the following
26972698
// method in such a way to get an SE ID that follows the format x.y.z instead of x.y.
26982699
//
2699-
// You can refer to A51.19 and A51.20 test cases in FunctionalTests.spl file to
2700+
// You can refer to A51.19 to A51.21 test cases in FunctionalTests.spl file to
27002701
// see how the following if-else condition will work for the very first part of the
27012702
// subexpression in those two test cases.
27022703
//

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.6</info:version>
7+
<info:version>1.1.7</info:version>
88
<info:requiredProductVersion>4.2.1.6</info:requiredProductVersion>
99
</info:identity>
1010
<info:dependencies/>

0 commit comments

Comments
 (0)