-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Users can remove regexp dependency at compile time #8
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Jubatus: Online machine learning framework for distributed environment | ||
// Copyright (C) 2014 Preferred Infrastructure and Nippon Telegraph and Telephone Corporation. | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License version 2.1 as published by the Free Software Foundation. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
#ifndef JUBATUS_CORE_FV_CONVERTER_NULL_REGEXP_FILTER_HPP_ | ||
#define JUBATUS_CORE_FV_CONVERTER_NULL_REGEXP_FILTER_HPP_ | ||
|
||
#include "string_filter.hpp" | ||
#include "exception.hpp" | ||
|
||
namespace jubatus { | ||
namespace core { | ||
namespace fv_converter { | ||
|
||
class regexp_filter : public string_filter { | ||
public: | ||
regexp_filter(const std::string& regexp, const std::string& replace) { | ||
throw JUBATUS_EXCEPTION( | ||
converter_exception("regexp support is disabled")); | ||
} | ||
|
||
void filter(const std::string& input, std::string& output) const {} | ||
}; | ||
|
||
} // namespace fv_converter | ||
} // namespace core | ||
} // namespace jubatus | ||
|
||
#endif // JUBATUS_CORE_FV_CONVERTER_NULL_REGEXP_FILTER_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Jubatus: Online machine learning framework for distributed environment | ||
// Copyright (C) 2011 Preferred Infrastructure and Nippon Telegraph and Telephone Corporation. | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License version 2.1 as published by the Free Software Foundation. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
#ifndef JUBATUS_CORE_FV_CONVERTER_NULL_REGEXP_MATCH_HPP_ | ||
#define JUBATUS_CORE_FV_CONVERTER_NULL_REGEXP_MATCH_HPP_ | ||
|
||
#include "key_matcher.hpp" | ||
#include "exception.hpp" | ||
|
||
namespace jubatus { | ||
namespace core { | ||
namespace fv_converter { | ||
|
||
class regexp_match : public key_matcher { | ||
public: | ||
explicit regexp_match(const std::string& regexp) { | ||
throw JUBATUS_EXCEPTION( | ||
converter_exception("regexp support is disabled")); | ||
} | ||
|
||
bool match(const std::string& key) { | ||
return false; | ||
} | ||
}; | ||
|
||
} // namespace fv_converter | ||
} // namespace core | ||
} // namespace jubatus | ||
|
||
#endif // JUBATUS_CORE_FV_CONVERTER_NULL_REGEXP_MATCH_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Jubatus: Online machine learning framework for distributed environment | ||
// Copyright (C) 2012 Preferred Infrastructure and Nippon Telegraph and Telephone Corporation. | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License version 2.1 as published by the Free Software Foundation. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
#ifndef JUBATUS_CORE_FV_CONVERTER_NULL_REGEXP_SPLITTER_HPP_ | ||
#define JUBATUS_CORE_FV_CONVERTER_NULL_REGEXP_SPLITTER_HPP_ | ||
|
||
#include "word_splitter.hpp" | ||
#include "exception.hpp" | ||
|
||
namespace jubatus { | ||
namespace core { | ||
namespace fv_converter { | ||
|
||
class regexp_splitter : public word_splitter { | ||
public: | ||
regexp_splitter(const std::string& regexp, int group) { | ||
throw JUBATUS_EXCEPTION( | ||
converter_exception("regexp support is disabled")); | ||
} | ||
|
||
void split( | ||
const std::string& str, | ||
std::vector<std::pair<size_t, size_t> >& bounds) const {}; | ||
}; | ||
|
||
} // namespace fv_converter | ||
} // namespace core | ||
} // namespace jubatus | ||
|
||
#endif // JUBATUS_CORE_FV_CONVERTER_NULL_REGEXP_SPLITTER_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
import Options | ||
|
||
def options(opt): | ||
opt.add_option('--enable-re2', | ||
action='store_true', | ||
default=False, | ||
help='do use re2 instead of oniguruma') | ||
opt.add_option('--regexp-library', | ||
default='oniguruma', | ||
help='use regexp library: oniguruma (default), re2 or none') | ||
|
||
def configure(conf): | ||
if Options.options.enable_re2: | ||
regexp_lib = Options.options.regexp_library | ||
if regexp_lib == 're2': | ||
conf.check_cxx(lib = 're2', define_name = 'HAVE_RE2', | ||
errmsg = 'not found') | ||
elif regexp_lib == 'oniguruma': | ||
conf.check_cxx(lib = 'onig', define_name = 'HAVE_ONIGURUMA', | ||
errmsg = 'not found') | ||
elif regexp_lib == 'none': | ||
pass | ||
else: | ||
conf.check_cxx(lib = 'onig', define_name = 'HAVE_ONIGURUMA') | ||
conf.fatal('unsupported regexp library specified: ' + regexp_lib) | ||
|
||
def make_test(bld, use, src): | ||
bld.program( | ||
|
@@ -74,30 +79,7 @@ def build(bld): | |
'type.hpp', | ||
'factory.hpp', | ||
'util.hpp', | ||
] | ||
use = ['jubatus_util', 'MSGPACK'] | ||
|
||
if bld.env.HAVE_RE2: | ||
source.append('re2_match.cpp') | ||
source.append('re2_filter.cpp') | ||
source.append('re2_splitter.cpp') | ||
use.append('RE2') | ||
else: | ||
source.append('onig_match.cpp') | ||
source.append('onig_filter.cpp') | ||
source.append('onig_splitter.cpp') | ||
use.append('ONIG') | ||
|
||
bld.core_sources.extend(bld.add_prefix(source)) | ||
bld.core_headers.extend(bld.add_prefix(headers)) | ||
bld.core_use.extend(use) | ||
|
||
n = bld.path.get_bld().make_node('test_input') | ||
n.mkdir() | ||
bld(rule = 'cp ${SRC} ${TGT}', | ||
source = bld.path.ant_glob('test_input/*'), | ||
target = n) | ||
|
||
] | ||
test_source = [ | ||
'json_converter_test.cpp', | ||
'msgpack_converter_test.cpp', | ||
|
@@ -119,12 +101,39 @@ def build(bld): | |
'keyword_weights_test.cpp', | ||
'feature_hasher_test.cpp', | ||
'except_match_test.cpp', | ||
'mixable_weight_manager_test.cpp', | ||
] | ||
regex_test_source = [ | ||
'regexp_match_test.cpp', | ||
'regexp_filter_test.cpp', | ||
'regexp_splitter_test.cpp', | ||
'mixable_weight_manager_test.cpp', | ||
] | ||
] | ||
|
||
use = ['jubatus_util', 'MSGPACK'] | ||
|
||
if bld.env.HAVE_RE2: | ||
source.append('re2_match.cpp') | ||
source.append('re2_filter.cpp') | ||
source.append('re2_splitter.cpp') | ||
test_source.append(regex_test_source) | ||
use.append('RE2') | ||
elif bld.env.HAVE_ONIGURUMA: | ||
source.append('onig_match.cpp') | ||
source.append('onig_filter.cpp') | ||
source.append('onig_splitter.cpp') | ||
test_source.append(regex_test_source) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace append with +=. |
||
use.append('ONIG') | ||
|
||
bld.core_sources.extend(bld.add_prefix(source)) | ||
bld.core_headers.extend(bld.add_prefix(headers)) | ||
bld.core_use.extend(use) | ||
|
||
n = bld.path.get_bld().make_node('test_input') | ||
n.mkdir() | ||
bld(rule = 'cp ${SRC} ${TGT}', | ||
source = bld.path.ant_glob('test_input/*'), | ||
target = n) | ||
|
||
test_use = ['jubatus_util', 'jubatus_core'] | ||
|
||
make_tests(bld, test_use, test_source) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace append with +=.