Skip to content

Commit

Permalink
Fixed constructor issue in RegexMatch on PPC64. Added blob handling in
Browse files Browse the repository at this point in the history
RegexMatch. Updated descriptions. Update to v1.4.3.
  • Loading branch information
leongor committed Feb 5, 2017
1 parent 99fb30c commit 7641dba
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,71 +10,71 @@
my $maxMemory = ($_ = $model->getParameterByName('maxMemory')) ? $_->getValueAt(0)->getCppExpression() : 1000000;
%>

bool MY_OPERATOR::RegexFullMatch(const string & str) {
bool MY_OPERATOR::RegexFullMatch(const rstring & str) {
return RE2::FullMatch(str, _regex) == 1;
}

bool MY_OPERATOR::RegexFullMatch(const blob & blb) {
return RE2::FullMatch(re2::StringPiece(reinterpret_cast<const char*>(blb.getData()), blb.getSize()), _regex) == 1;
}

bool MY_OPERATOR::RegexFullMatch(const string & str, const string & pattern) {
bool MY_OPERATOR::RegexFullMatch(const rstring & str, const rstring & pattern) {

AutoPortMutex am(_mutex, *this);
if(_regexMap.count(pattern) == 0) {
string pat = pattern;
rstring pat = pattern;
_regexMap.insert(pat, new RE2(pattern, _options));
}

return RE2::FullMatch(str, _regexMap.at(pattern)) == 1;
}

bool MY_OPERATOR::RegexFullMatch(const blob & blb, const string & pattern) {
bool MY_OPERATOR::RegexFullMatch(const blob & blb, const rstring & pattern) {

AutoPortMutex am(_mutex, *this);
if(_regexMap.count(pattern) == 0) {
string pat = pattern;
rstring pat = pattern;
_regexMap.insert(pat, new RE2(pattern, _options));
}

return RE2::FullMatch(re2::StringPiece(reinterpret_cast<const char*>(blb.getData()), blb.getSize()), _regexMap.at(pattern)) == 1;
}

bool MY_OPERATOR::RegexPartialMatch(const string & str) {
bool MY_OPERATOR::RegexPartialMatch(const rstring & str) {
return RE2::PartialMatch(str, _regex) == 1;
}

bool MY_OPERATOR::RegexPartialMatch(const blob & blb) {
return RE2::PartialMatch(re2::StringPiece(reinterpret_cast<const char*>(blb.getData()), blb.getSize()), _regex) == 1;
}

bool MY_OPERATOR::RegexPartialMatch(const string & str, const string & pattern) {
bool MY_OPERATOR::RegexPartialMatch(const rstring & str, const rstring & pattern) {

AutoPortMutex am(_mutex, *this);
if(_regexMap.count(pattern) == 0) {
string pat = pattern;
rstring pat = pattern;
_regexMap.insert(pat, new RE2(pattern, _options));
}

return RE2::PartialMatch(str, _regexMap.at(pattern)) == 1;
}

bool MY_OPERATOR::RegexPartialMatch(const blob & blb, const string & pattern) {
bool MY_OPERATOR::RegexPartialMatch(const blob & blb, const rstring & pattern) {

AutoPortMutex am(_mutex, *this);
if(_regexMap.count(pattern) == 0) {
string pat = pattern;
rstring pat = pattern;
_regexMap.insert(pat, new RE2(pattern, _options));
}

return RE2::PartialMatch(re2::StringPiece(reinterpret_cast<const char*>(blb.getData()), blb.getSize()), _regexMap.at(pattern)) == 1;
}

bool MY_OPERATOR::RegexSimpleMatch(const string & str, const string & pattern) {
bool MY_OPERATOR::RegexSimpleMatch(const rstring & str, const rstring & pattern) {
return RE2::PartialMatch(str, pattern) == 1;
}

bool MY_OPERATOR::RegexSimpleMatch(const blob & blb, const string & pattern) {
bool MY_OPERATOR::RegexSimpleMatch(const blob & blb, const rstring & pattern) {
return RE2::PartialMatch(re2::StringPiece(reinterpret_cast<const char*>(blb.getData()), blb.getSize()), pattern) == 1;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <string>
#include <streams_boost/ptr_container/ptr_unordered_map.hpp>
#include <streams_boost/thread/tss.hpp>
#include "re2/re2.h"
Expand All @@ -23,19 +22,21 @@ private:
RE2 _regex;

Mutex _mutex;
ptr_unordered_map<string,RE2> _regexMap;
ptr_unordered_map<rstring,RE2> _regexMap;
static thread_specific_ptr<OPort0Type> otuplePtr_;

OPort0Type * getOutputTuple();

bool RegexFullMatch(const string & str);
bool RegexFullMatch(const rstring & str);
bool RegexFullMatch(const blob & blb);
bool RegexFullMatch(const string & str, const string & pattern);
bool RegexFullMatch(const blob & blb, const string & pattern);
bool RegexPartialMatch(const string & str);
bool RegexFullMatch(const rstring & str, const rstring & pattern);
bool RegexFullMatch(const blob & blb, const rstring & pattern);
bool RegexPartialMatch(const rstring & str);
bool RegexPartialMatch(const blob & blb);
bool RegexPartialMatch(const string & str, const string & pattern);
bool RegexPartialMatch(const blob & blb, const string & pattern);
bool RegexPartialMatch(const rstring & str, const rstring & pattern);
bool RegexPartialMatch(const blob & blb, const rstring & pattern);
bool RegexSimpleMatch(const rstring & str, const rstring & pattern);
bool RegexSimpleMatch(const blob & blb, const rstring & pattern);
};

<%SPL::CodeGen::headerEpilogue($model);%>
6 changes: 2 additions & 4 deletions samples/RegexMatchSample/sample/RegexMatchSample.spl
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ composite RegexMatchSample {
}

// Matching string with precompiled regex pattern (from parameter)
(stream<rstring str, boolean result> RegexMatch_2_out0)as
RegexMatch_2 = RegexMatch(Beacon_1_out0){
(stream<rstring str, boolean result> RegexMatch_2_out0) as RegexMatch_2 = RegexMatch(Beacon_1_out0){
param
pattern : "^Hello" ;
output
RegexMatch_2_out0 : result = RegexPartialMatch(str);
}

// Matching string with updated precompiled regex pattern (from input attribute)
(stream<rstring str, boolean result> RegexMatch_3_out0)as
RegexMatch_3 = RegexMatch(Beacon_2_out0){
(stream<rstring str, boolean result> RegexMatch_3_out0) as RegexMatch_3 = RegexMatch(Beacon_2_out0){
output
RegexMatch_3_out0 : result = RegexPartialMatch(str, pattern);
}
Expand Down

0 comments on commit 7641dba

Please sign in to comment.