You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,9 @@
1
1
# Changes
2
2
3
+
## v1.1.2
4
+
* Oct/16/2021
5
+
* Added a new function compare_tuple_attributes to compare the attribute values of two tuples that are based on the same schema and then give back a list containing the attribute names that have differing values in the two tuples being compared.
6
+
3
7
## v1.1.1
4
8
* Sep/04/2021
5
9
* Added two new operational verbs: equalsCI and notEqualsCI.
Copy file name to clipboardExpand all lines: README.md
+74-2Lines changed: 74 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,14 +106,86 @@ if(error == 0) {
106
106
// It is a void function that returns nothing.
107
107
```
108
108
109
+
**compare_tuple_attributes** is another C++ native function provided via this toolkit. This function compares the attribute values of two tuples that are based on the same schema. It will give back a list containing attribute names that have differing values in the two tuples being compared. It supports primitive types (int32, float64, rstring etc.) as well as collection types (set, list and map). It also allows flat tuples as well as deeply nested tuples to be compared.
110
+
111
+
```
112
+
// This namespace usage declaration is needed at the top of an application.
113
+
use com.ibm.streamsx.eval_predicate::*;
114
+
115
+
// Schema can include other deeply nested types.
116
+
type NestedType1_t = int32 x, float64 y, rstring z, list<int32> l;
117
+
type NestedType2_t = NestedType1_t m, map<int32, boolean> n, timestamp o;
118
+
type Test_t = boolean a, int32 b, uint64 c, float32 d, float64 e,
119
+
rstring f, set<int32> g, list<rstring> h, map<int32, rstring> i,
120
+
map<rstring, float64> j, NestedType2_t k;
121
+
122
+
// Create two tuples that are based on the same schema.
123
+
mutable Test_t myTuple1 = {};
124
+
mutable Test_t myTuple2 = {};
125
+
mutable list<rstring> differingAttributes = [];
126
+
127
+
// Populate the tuple with some data.
128
+
myTuple1.a = true;
129
+
myTuple1.b = 456;
130
+
myTuple1.c = 789ul;
131
+
myTuple1.d = (float32)123.45;
132
+
myTuple1.e = 987.65;
133
+
myTuple1.f = "Life is mainly there to have fun.";
134
+
myTuple1.g = {5, 9, 2, 6};
135
+
myTuple1.h = ['One', 'Two', 'Three'];
136
+
myTuple1.i = {1:'One', 2:'Two', 3:'Three'};
137
+
myTuple1.j = {"One":1.0, "Two":2.0, "Three":3.0};
138
+
myTuple1.k.m.x = 678;
139
+
myTuple1.k.m.y = 936.27;
140
+
myTuple1.k.m.z = "String inside a nested tuple.";
141
+
myTuple1.k.m.l = [67, 78, 89];
142
+
myTuple1.k.n = {1:true, 2:false, 3:true};
143
+
myTuple1.k.o = getTimestamp();
144
+
145
+
// Make the second tuple same as the first tuple.
146
+
myTuple2 = myTuple1;
147
+
// Make some changes to certain attribute values in the second tuple.
148
+
myTuple2.a = false;
149
+
myTuple2.d = (float32)145.12;
150
+
myTuple2.f = "Life is mainly there to have joy and peace.";
151
+
myTuple2.i = {10:'Ten', 9:'Nine', 8:'Eight'};
152
+
myTuple2.k.m.y = 27.93;
153
+
myTuple2.k.m.z = "Different string inside a nested tuple.";
printStringLn("Compare tuple attributes function returned an error. Error=" + (rstring)error);
168
+
}
169
+
}
170
+
// Following is the usage description for the get_tuple_attribute_value function.
171
+
//
172
+
// Arg1: Your tuple1
173
+
// Arg2: Your tuple2
174
+
// Arg3: A mutable variable of list<string> type in which the
175
+
// attribute names that differ in their values will be returned.
176
+
// Arg4: A mutable int32 variable to receive non-zero error code if any.
177
+
// Arg5: A boolean value to enable debug tracing inside this function.
178
+
// It is a void function that returns nothing.
179
+
```
180
+
109
181
## Design considerations
110
182
This toolkit came into existence for a specific need with which a large enterprise customer approached the author of this toolkit. There is already a built-in function named *evalPredicate* that is available in the official IBM Streams product. However, that function has certain limitations. To fill that gap, this toolkit with its own **eval_predicate** function is being made available freely via the publicly accessible IBMStreams GitHub. The **eval_predicate** function from this toolkit differs from the *evalPredicate* built-in function in the IBM Streams product in the following ways.
111
183
112
184
1. This new eval_predicate function allows the user defined rule expression to access map based tuple attributes.
113
185
114
186
2. This new eval_predicate function allows the user defined rule expression to access nested tuple attributes.
115
187
116
-
3. This new eval_predicate function allows the user defined rule expression to have operation verbs such as contains, startsWith, endsWith, notContains, notStartsWith, notEndsWith, in, containsCI, startsWithCI, endsWithCI, notContainsCI, notStartsWithCI, notEndsWithCI, inCI, sizeEQ, sizeNE, sizeLT, sizeLE, sizeGT, sizeGE.
188
+
3. This new eval_predicate function allows the user defined rule expression to have operation verbs such as contains, startsWith, endsWith, notContains, notStartsWith, notEndsWith, in, containsCI, startsWithCI, endsWithCI, notContainsCI, notStartsWithCI, notEndsWithCI, inCI, equalsCI, notEqualsCI, sizeEQ, sizeNE, sizeLT, sizeLE, sizeGT, sizeGE.
117
189
118
190
4. This new eval_predicate function supports the following operations inside the rule.
119
191
@@ -123,7 +195,7 @@ This toolkit came into existence for a specific need with which a large enterpri
123
195
124
196
c. It supports these arithmetic operations: +, -, *, /, %
125
197
126
-
d. It supports these special operations for rstring, set, list and map: contains, startsWith, endsWith, notContains, notStartsWith, notEndsWith, in, containsCI, startsWithCI, endsWithCI, notContainsCI, notStartsWithCI, notEndsWithCI, inCI, sizeEQ, sizeNE, sizeLT, sizeLE, sizeGT, sizeGE
198
+
d. It supports these special operations for rstring, set, list and map: contains, startsWith, endsWith, notContains, notStartsWith, notEndsWith, in, containsCI, startsWithCI, endsWithCI, notContainsCI, notStartsWithCI, notEndsWithCI, inCI, equalsCI, notEqualsCI, sizeEQ, sizeNE, sizeLT, sizeLE, sizeGT, sizeGE
127
199
128
200
e. No bitwise operations are supported at this time.
Copy file name to clipboardExpand all lines: com.ibm.streamsx.eval_predicate/native.function/function.xml
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,19 @@ It fetches the value of a user given attribute name if it is present in the user
28
28
</description>
29
29
<prototype><tuple T1, any T2> public void get_tuple_attribute_value(rstring attributeName, T1 myTuple, mutable T2 value, mutable int32 error, boolean trace)</prototype>
30
30
</function>
31
+
32
+
<function>
33
+
<description>
34
+
It compares the attribute values of two tuples that are made of the same schema and returns a list containing the attribute names that have differing values.
35
+
@param myTuple1 First of the two user given tuples to be compared. Type: Tuple
36
+
@param myTuple2 Second of the two user given tuples to be compared. Type: Tuple
37
+
@param differingAttributes A mutable list variable that will contain the attribute names that have differing values. Type: list<rstring>
38
+
@param error A mutable variable that will contain a non-zero error code if an error occurs. Type: int32
39
+
@param trace A boolean value to enable tracing inside this function. Type: boolean
0 commit comments