Skip to content

Commit 99fb30c

Browse files
committed
Fixed constructor issue in RegexMatch on PPC64. Added blob handling in
RegexMatch. Updated descriptions. Update to v1.4.3.
1 parent 93fbce5 commit 99fb30c

File tree

11 files changed

+126
-42
lines changed

11 files changed

+126
-42
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ com.ibm.streamsx.regex/impl/include/boost
44
com.ibm.streamsx.regex/samples
55
samples/*/doc
66
samples/*/output
7-
samples/*/toolkit.xml
87
index.*
98
# begin streamsx.regex excluded
109
.classpath

com.ibm.streamsx.regex/com.ibm.streamsx.regex.re2/RegexMatch/RegexMatch.xml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<context>
55
<description>
66
RegexMatch operator has three custom output functions:
7-
* RegexSimpleMatch performs a partial match and runs in interpretation mode (like SPL regexMatch function).
8-
* RegexPartialMatch performs a partial match and runs in compilation mode.
9-
* RegexFullMatch performs a full match and runs in compilation mode.
7+
* RegexSimpleMatch performs a partial match - runs in interpretation mode (like SPL regexMatch function).
8+
* RegexPartialMatch performs a partial match - runs in compilation mode.
9+
* RegexFullMatch performs a full match - runs in compilation mode.
1010
</description>
1111
<customOutputFunctions>
1212
<customOutputFunction>
@@ -15,26 +15,46 @@ RegexMatch operator has three custom output functions:
1515
<description>Assign value to the output attribute.</description>
1616
<prototype>&lt;any T> T AsIs(T v)</prototype>
1717
</function>
18-
<function pseudoFunction="true">
18+
<function pseudoFunction="false">
1919
<description>Tries to match the whole string with the pattern (defined as the operator parameter).</description>
2020
<prototype>boolean RegexFullMatch(rstring str)</prototype>
2121
</function>
22-
<function pseudoFunction="true">
22+
<function pseudoFunction="false">
23+
<description>Tries to match the whole blob with the pattern (defined as the operator parameter).</description>
24+
<prototype>boolean RegexFullMatch(blob blb)</prototype>
25+
</function>
26+
<function pseudoFunction="false">
2327
<description>Tries to match the whole string with the pattern.</description>
2428
<prototype>boolean RegexFullMatch(rstring str, rstring pattern)</prototype>
2529
</function>
26-
<function pseudoFunction="true">
30+
<function pseudoFunction="false">
31+
<description>Tries to match the whole blob with the pattern.</description>
32+
<prototype>boolean RegexFullMatch(blob blb, rstring pattern)</prototype>
33+
</function>
34+
<function pseudoFunction="false">
2735
<description>Tries to match the string with the pattern (defined as the operator parameter).</description>
2836
<prototype>boolean RegexPartialMatch(rstring str)</prototype>
2937
</function>
30-
<function pseudoFunction="true">
38+
<function pseudoFunction="false">
39+
<description>Tries to match the blob with the pattern (defined as the operator parameter).</description>
40+
<prototype>boolean RegexPartialMatch(blob blb)</prototype>
41+
</function>
42+
<function pseudoFunction="false">
3143
<description>Tries to match the string with the pattern.</description>
3244
<prototype>boolean RegexPartialMatch(rstring str, rstring pattern)</prototype>
3345
</function>
34-
<function pseudoFunction="true">
46+
<function pseudoFunction="false">
47+
<description>Tries to match the blob with the pattern.</description>
48+
<prototype>boolean RegexPartialMatch(blob blb, rstring pattern)</prototype>
49+
</function>
50+
<function pseudoFunction="false">
3551
<description>Tries to match the string with the pattern.</description>
3652
<prototype>boolean RegexSimpleMatch(rstring str, rstring pattern)</prototype>
3753
</function>
54+
<function pseudoFunction="false">
55+
<description>Tries to match the blob with the pattern.</description>
56+
<prototype>boolean RegexSimpleMatch(blob blb, rstring pattern)</prototype>
57+
</function>
3858
</customOutputFunction>
3959
</customOutputFunctions>
4060
<libraryDependencies>

com.ibm.streamsx.regex/com.ibm.streamsx.regex.re2/RegexMatch/RegexMatch_cpp.cgt

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ bool MY_OPERATOR::RegexFullMatch(const string & str) {
1414
return RE2::FullMatch(str, _regex) == 1;
1515
}
1616

17+
bool MY_OPERATOR::RegexFullMatch(const blob & blb) {
18+
return RE2::FullMatch(re2::StringPiece(reinterpret_cast<const char*>(blb.getData()), blb.getSize()), _regex) == 1;
19+
}
20+
1721
bool MY_OPERATOR::RegexFullMatch(const string & str, const string & pattern) {
1822

1923
AutoPortMutex am(_mutex, *this);
@@ -25,10 +29,25 @@ bool MY_OPERATOR::RegexFullMatch(const string & str, const string & pattern) {
2529
return RE2::FullMatch(str, _regexMap.at(pattern)) == 1;
2630
}
2731

32+
bool MY_OPERATOR::RegexFullMatch(const blob & blb, const string & pattern) {
33+
34+
AutoPortMutex am(_mutex, *this);
35+
if(_regexMap.count(pattern) == 0) {
36+
string pat = pattern;
37+
_regexMap.insert(pat, new RE2(pattern, _options));
38+
}
39+
40+
return RE2::FullMatch(re2::StringPiece(reinterpret_cast<const char*>(blb.getData()), blb.getSize()), _regexMap.at(pattern)) == 1;
41+
}
42+
2843
bool MY_OPERATOR::RegexPartialMatch(const string & str) {
2944
return RE2::PartialMatch(str, _regex) == 1;
3045
}
3146

47+
bool MY_OPERATOR::RegexPartialMatch(const blob & blb) {
48+
return RE2::PartialMatch(re2::StringPiece(reinterpret_cast<const char*>(blb.getData()), blb.getSize()), _regex) == 1;
49+
}
50+
3251
bool MY_OPERATOR::RegexPartialMatch(const string & str, const string & pattern) {
3352

3453
AutoPortMutex am(_mutex, *this);
@@ -40,11 +59,26 @@ bool MY_OPERATOR::RegexPartialMatch(const string & str, const string & pattern)
4059
return RE2::PartialMatch(str, _regexMap.at(pattern)) == 1;
4160
}
4261

62+
bool MY_OPERATOR::RegexPartialMatch(const blob & blb, const string & pattern) {
63+
64+
AutoPortMutex am(_mutex, *this);
65+
if(_regexMap.count(pattern) == 0) {
66+
string pat = pattern;
67+
_regexMap.insert(pat, new RE2(pattern, _options));
68+
}
69+
70+
return RE2::PartialMatch(re2::StringPiece(reinterpret_cast<const char*>(blb.getData()), blb.getSize()), _regexMap.at(pattern)) == 1;
71+
}
72+
4373
bool MY_OPERATOR::RegexSimpleMatch(const string & str, const string & pattern) {
4474
return RE2::PartialMatch(str, pattern) == 1;
4575
}
4676

47-
MY_OPERATOR::MY_OPERATOR() : _options(), _regex(<%=$pattern%>, _options) {
77+
bool MY_OPERATOR::RegexSimpleMatch(const blob & blb, const string & pattern) {
78+
return RE2::PartialMatch(re2::StringPiece(reinterpret_cast<const char*>(blb.getData()), blb.getSize()), pattern) == 1;
79+
}
80+
81+
MY_OPERATOR::MY_OPERATOR() : _options(), _regex(re2::StringPiece(<%=$pattern%>), _options) {
4882
_options.set_log_errors(<%=$logErrors%>);
4983
_options.set_max_mem(<%=$maxMemory%>);
5084
}
@@ -92,4 +126,4 @@ MY_OPERATOR::OPort0Type * MY_OPERATOR::getOutputTuple() {
92126
return otuplePtr;
93127
}
94128

95-
<%SPL::CodeGen::implementationEpilogue($model);%>
129+
<%SPL::CodeGen::implementationEpilogue($model);%>

com.ibm.streamsx.regex/com.ibm.streamsx.regex.re2/RegexMatch/RegexMatch_cpp.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
package RegexMatch_cpp;
3-
use strict; use Cwd 'realpath'; use File::Basename; use lib dirname(__FILE__); use SPL::Operator::Instance::OperatorInstance; use SPL::Operator::Instance::Context; use SPL::Operator::Instance::Expression; use SPL::Operator::Instance::ExpressionTree; use SPL::Operator::Instance::ExpressionTreeVisitor; use SPL::Operator::Instance::ExpressionTreeCppGenVisitor; use SPL::Operator::Instance::InputAttribute; use SPL::Operator::Instance::InputPort; use SPL::Operator::Instance::OutputAttribute; use SPL::Operator::Instance::OutputPort; use SPL::Operator::Instance::Parameter; use SPL::Operator::Instance::StateVariable; use SPL::Operator::Instance::Window;
3+
use strict; use Cwd 'realpath'; use File::Basename; use lib dirname(__FILE__); use SPL::Operator::Instance::OperatorInstance; use SPL::Operator::Instance::Annotation; use SPL::Operator::Instance::Context; use SPL::Operator::Instance::Expression; use SPL::Operator::Instance::ExpressionTree; use SPL::Operator::Instance::ExpressionTreeEvaluator; use SPL::Operator::Instance::ExpressionTreeVisitor; use SPL::Operator::Instance::ExpressionTreeCppGenVisitor; use SPL::Operator::Instance::InputAttribute; use SPL::Operator::Instance::InputPort; use SPL::Operator::Instance::OutputAttribute; use SPL::Operator::Instance::OutputPort; use SPL::Operator::Instance::Parameter; use SPL::Operator::Instance::StateVariable; use SPL::Operator::Instance::TupleValue; use SPL::Operator::Instance::Window;
44
sub main::generate($$) {
55
my ($xml, $signature) = @_;
66
print "// $$signature\n";
@@ -75,6 +75,7 @@ sub main::generate($$) {
7575
print ' ';
7676
foreach my $attribute (@{$outputPort->getAttributes()}) {
7777
my $name = $attribute->getName();
78+
SPL::CodeGen::println($attribute->getAssignmentOutputFunctionName());
7879
if ($attribute->hasAssignmentWithOutputFunction()) {
7980
my $operation = $attribute->getAssignmentOutputFunctionName();
8081
if ($operation eq 'AsIs') {

com.ibm.streamsx.regex/com.ibm.streamsx.regex.re2/RegexMatch/RegexMatch_h.cgt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ private:
2929
OPort0Type * getOutputTuple();
3030

3131
bool RegexFullMatch(const string & str);
32+
bool RegexFullMatch(const blob & blb);
3233
bool RegexFullMatch(const string & str, const string & pattern);
34+
bool RegexFullMatch(const blob & blb, const string & pattern);
3335
bool RegexPartialMatch(const string & str);
36+
bool RegexPartialMatch(const blob & blb);
3437
bool RegexPartialMatch(const string & str, const string & pattern);
35-
bool RegexSimpleMatch(const string & str, const string & pattern);
38+
bool RegexPartialMatch(const blob & blb, const string & pattern);
3639
};
3740

3841
<%SPL::CodeGen::headerEpilogue($model);%>

com.ibm.streamsx.regex/com.ibm.streamsx.regex.re2/RegexMatch/RegexMatch_h.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
package RegexMatch_h;
3-
use strict; use Cwd 'realpath'; use File::Basename; use lib dirname(__FILE__); use SPL::Operator::Instance::OperatorInstance; use SPL::Operator::Instance::Context; use SPL::Operator::Instance::Expression; use SPL::Operator::Instance::ExpressionTree; use SPL::Operator::Instance::ExpressionTreeVisitor; use SPL::Operator::Instance::ExpressionTreeCppGenVisitor; use SPL::Operator::Instance::InputAttribute; use SPL::Operator::Instance::InputPort; use SPL::Operator::Instance::OutputAttribute; use SPL::Operator::Instance::OutputPort; use SPL::Operator::Instance::Parameter; use SPL::Operator::Instance::StateVariable; use SPL::Operator::Instance::Window;
3+
use strict; use Cwd 'realpath'; use File::Basename; use lib dirname(__FILE__); use SPL::Operator::Instance::OperatorInstance; use SPL::Operator::Instance::Annotation; use SPL::Operator::Instance::Context; use SPL::Operator::Instance::Expression; use SPL::Operator::Instance::ExpressionTree; use SPL::Operator::Instance::ExpressionTreeEvaluator; use SPL::Operator::Instance::ExpressionTreeVisitor; use SPL::Operator::Instance::ExpressionTreeCppGenVisitor; use SPL::Operator::Instance::InputAttribute; use SPL::Operator::Instance::InputPort; use SPL::Operator::Instance::OutputAttribute; use SPL::Operator::Instance::OutputPort; use SPL::Operator::Instance::Parameter; use SPL::Operator::Instance::StateVariable; use SPL::Operator::Instance::TupleValue; use SPL::Operator::Instance::Window;
44
sub main::generate($$) {
55
my ($xml, $signature) = @_;
66
print "// $$signature\n";

com.ibm.streamsx.regex/com.ibm.streamsx.regex.re2/native.function/function.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,43 @@
55
<cppNamespaceName>regex</cppNamespaceName>
66
<functions>
77
<function>
8-
<description>Compiles regex pattern and indexes it.</description>
8+
<description>Compiles and indexes regex pattern</description>
99
<prototype>&lt;enum E> public boolean regexCompile(rstring pattern, E patternIndex)</prototype>
1010
</function>
1111
<function>
12-
<description>Compiles regex pattern and indexes it, additionally allows to control max memory allocated.</description>
12+
<description>Compiles and indexes regex pattern, additionally allows to control max memory allocated</description>
1313
<prototype>&lt;enum E> public boolean regexCompile(rstring pattern, E patternIndex, int64 maxmem)</prototype>
1414
</function>
1515
<function>
16-
<description>Compiles regex pattern and indexes it - static version</description>
16+
<description>Compiles and indexes regex pattern. This is a static version - a pattern is visible on PE level</description>
1717
<prototype>&lt;enum E> public boolean regexCompileStatic(rstring pattern, E patternIndex)</prototype>
1818
</function>
1919
<function>
20-
<description>Compiles regex pattern and indexes it - static version, additionally allows to control max memory allocated.</description>
20+
<description>Compiles and indexes regex pattern, additionally allows to control max memory allocated. This is a static version - a pattern is visible on PE level</description>
2121
<prototype>&lt;enum E> public boolean regexCompileStatic(rstring pattern, E patternIndex, int64 maxmem)</prototype>
2222
</function>
2323
<function>
24-
<description>Tries to match the whole string with the pattern - doesn't use compiled regex.</description>
24+
<description>Performs a full match of the whole string with the pattern - runs in interpretation mode (like SPL regexMatch function)</description>
2525
<prototype>public boolean regexFullMatch(rstring str, rstring pattern)</prototype>
2626
</function>
2727
<function>
28-
<description>Tries to match the whole string with the pattern - uses compiled regex by it's index.</description>
28+
<description>Performs a full match of the whole string with the pattern - runs in compiled mode (uses compiled regex index to identify the pattern)</description>
2929
<prototype>&lt;enum E> public boolean regexFullMatch(rstring str, E patternIndex)</prototype>
3030
</function>
3131
<function>
32-
<description>Tries to match the whole string with the pattern - static version, uses compiled regex by it's index.</description>
32+
<description>Performs a full match of the whole string with the pattern - runs in compiled mode (uses compiled regex index to identify the pattern). This is a static version - a pattern is visible on PE level</description>
3333
<prototype>&lt;enum E> public boolean regexFullMatchStatic(rstring str, E patternIndex)</prototype>
3434
</function>
3535
<function>
36-
<description>Tries to match the string with the pattern - doesn't use compiled regex.</description>
36+
<description>Performs a partial match of the string with the pattern - runs in interpretation mode (like SPL regexMatch function).</description>
3737
<prototype>public boolean regexPartialMatch(rstring str, rstring pattern)</prototype>
3838
</function>
3939
<function>
40-
<description>Tries to match the string with the pattern - uses compiled regex by it's index.</description>
40+
<description>Performs a partial match of the string with the pattern - runs in compiled mode (uses compiled regex index to identify the pattern)</description>
4141
<prototype>&lt;enum E> public boolean regexPartialMatch(rstring str, E patternIndex)</prototype>
4242
</function>
4343
<function>
44-
<description>Tries to match the string with the pattern - static version, uses compiled regex by it's index.</description>
44+
<description>Performs a partial match of the string with the pattern - runs in compiled mode (uses compiled regex index to identify the pattern). This is a static version - a pattern is visible on PE level</description>
4545
<prototype>&lt;enum E> public boolean regexPartialMatchStatic(rstring str, E patternIndex)</prototype>
4646
</function>
4747
</functions>

com.ibm.streamsx.regex/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Each operator/native function implements partial or full regex match.
1717
**Third-party libraries**
1818
* This toolkit embeds RE2 headers/libraries under impl/&lt;include|lib>.
1919
</info:description>
20-
<info:version>1.4.2</info:version>
20+
<info:version>1.4.3</info:version>
2121
<info:requiredProductVersion>4.0.0</info:requiredProductVersion>
2222
</info:identity>
2323
<info:dependencies/>

0 commit comments

Comments
 (0)