Skip to content

Commit e9cefa8

Browse files
committed
clang-format
1 parent 8948cfb commit e9cefa8

File tree

6 files changed

+83
-50
lines changed

6 files changed

+83
-50
lines changed

core/analysis/collation_token_stream.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ using namespace irs;
4141

4242
constexpr std::string_view LOCALE_PARAM_NAME{"locale"};
4343

44-
bool locale_from_slice(VPackSlice slice, IRESEARCH_ICU_NAMESPACE::Locale& locale) {
44+
bool locale_from_slice(VPackSlice slice,
45+
IRESEARCH_ICU_NAMESPACE::Locale& locale) {
4546
if (!slice.isString()) {
4647
IRS_LOG_WARN(absl::StrCat(
4748
"Non-string value in '", LOCALE_PARAM_NAME,
@@ -52,7 +53,8 @@ bool locale_from_slice(VPackSlice slice, IRESEARCH_ICU_NAMESPACE::Locale& locale
5253

5354
const auto locale_name = slice.copyString();
5455

55-
locale = IRESEARCH_ICU_NAMESPACE::Locale::createCanonical(locale_name.c_str());
56+
locale =
57+
IRESEARCH_ICU_NAMESPACE::Locale::createCanonical(locale_name.c_str());
5658

5759
if (locale.isBogus()) {
5860
IRS_LOG_WARN(absl::StrCat(
@@ -247,8 +249,8 @@ collation_token_stream::collation_token_stream(const options_t& options)
247249
bool collation_token_stream::reset(std::string_view data) {
248250
if (!state_->collator) {
249251
auto err = UErrorCode::U_ZERO_ERROR;
250-
state_->collator.reset(
251-
IRESEARCH_ICU_NAMESPACE::Collator::createInstance(state_->options.locale, err));
252+
state_->collator.reset(IRESEARCH_ICU_NAMESPACE::Collator::createInstance(
253+
state_->options.locale, err));
252254

253255
if (!U_SUCCESS(err) || !state_->collator) {
254256
state_->collator.reset();
@@ -262,8 +264,10 @@ bool collation_token_stream::reset(std::string_view data) {
262264
return false; // ICU UnicodeString signatures can handle at most INT32_MAX
263265
}
264266

265-
const IRESEARCH_ICU_NAMESPACE::UnicodeString icu_token = IRESEARCH_ICU_NAMESPACE::UnicodeString::fromUTF8(
266-
IRESEARCH_ICU_NAMESPACE::StringPiece(data.data(), static_cast<int32_t>(data.size())));
267+
const IRESEARCH_ICU_NAMESPACE::UnicodeString icu_token =
268+
IRESEARCH_ICU_NAMESPACE::UnicodeString::fromUTF8(
269+
IRESEARCH_ICU_NAMESPACE::StringPiece(data.data(),
270+
static_cast<int32_t>(data.size())));
267271

268272
byte_type raw_term_buf[MAX_TOKEN_SIZE];
269273
static_assert(sizeof raw_term_buf == sizeof state_->term_buf);

core/analysis/text_token_normalizing_stream.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ struct normalizing_token_stream::state_t {
5656
IRESEARCH_ICU_NAMESPACE::UnicodeString data;
5757
IRESEARCH_ICU_NAMESPACE::UnicodeString token;
5858
std::string term_buf;
59-
const IRESEARCH_ICU_NAMESPACE::Normalizer2* normalizer; // reusable object owned by ICU
59+
const IRESEARCH_ICU_NAMESPACE::Normalizer2*
60+
normalizer; // reusable object owned by ICU
6061
std::unique_ptr<IRESEARCH_ICU_NAMESPACE::Transliterator> transliterator;
6162
const options_t options;
6263

@@ -82,7 +83,8 @@ constexpr frozen::unordered_map<
8283
{"upper", analysis::normalizing_token_stream::UPPER},
8384
};
8485

85-
bool locale_from_slice(VPackSlice slice, IRESEARCH_ICU_NAMESPACE::Locale& locale) {
86+
bool locale_from_slice(VPackSlice slice,
87+
IRESEARCH_ICU_NAMESPACE::Locale& locale) {
8688
if (!slice.isString()) {
8789
IRS_LOG_WARN(
8890
absl::StrCat("Non-string value in '", LOCALE_PARAM_NAME,
@@ -97,8 +99,8 @@ bool locale_from_slice(VPackSlice slice, IRESEARCH_ICU_NAMESPACE::Locale& locale
9799
locale = IRESEARCH_ICU_NAMESPACE::Locale::createFromName(locale_name.c_str());
98100

99101
if (!locale.isBogus()) {
100-
locale = IRESEARCH_ICU_NAMESPACE::Locale{locale.getLanguage(), locale.getCountry(),
101-
locale.getVariant()};
102+
locale = IRESEARCH_ICU_NAMESPACE::Locale{
103+
locale.getLanguage(), locale.getCountry(), locale.getVariant()};
102104
}
103105

104106
if (locale.isBogus()) {
@@ -349,7 +351,8 @@ bool normalizing_token_stream::reset(std::string_view data) {
349351

350352
if (!state_->normalizer) {
351353
// reusable object owned by ICU
352-
state_->normalizer = IRESEARCH_ICU_NAMESPACE::Normalizer2::getNFCInstance(err);
354+
state_->normalizer =
355+
IRESEARCH_ICU_NAMESPACE::Normalizer2::getNFCInstance(err);
353356

354357
if (!U_SUCCESS(err) || !state_->normalizer) {
355358
state_->normalizer = nullptr;
@@ -366,8 +369,9 @@ bool normalizing_token_stream::reset(std::string_view data) {
366369
"NFD; [:Nonspacing Mark:] Remove; NFC");
367370

368371
// reusable object owned by *this
369-
state_->transliterator.reset(IRESEARCH_ICU_NAMESPACE::Transliterator::createInstance(
370-
collationRule, UTransDirection::UTRANS_FORWARD, err));
372+
state_->transliterator.reset(
373+
IRESEARCH_ICU_NAMESPACE::Transliterator::createInstance(
374+
collationRule, UTransDirection::UTRANS_FORWARD, err));
371375

372376
if (!U_SUCCESS(err) || !state_->transliterator) {
373377
state_->transliterator.reset();
@@ -383,7 +387,8 @@ bool normalizing_token_stream::reset(std::string_view data) {
383387
}
384388

385389
state_->data = IRESEARCH_ICU_NAMESPACE::UnicodeString::fromUTF8(
386-
IRESEARCH_ICU_NAMESPACE::StringPiece{data.data(), static_cast<int32_t>(data.size())});
390+
IRESEARCH_ICU_NAMESPACE::StringPiece{data.data(),
391+
static_cast<int32_t>(data.size())});
387392

388393
// normalize unicode
389394
state_->normalizer->normalize(state_->data, state_->token, err);

core/analysis/text_token_stemming_stream.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ using namespace irs;
3939

4040
constexpr std::string_view LOCALE_PARAM_NAME{"locale"};
4141

42-
bool locale_from_slice(VPackSlice slice, IRESEARCH_ICU_NAMESPACE::Locale& locale) {
42+
bool locale_from_slice(VPackSlice slice,
43+
IRESEARCH_ICU_NAMESPACE::Locale& locale) {
4344
if (!slice.isString()) {
4445
IRS_LOG_WARN(absl::StrCat(
4546
"Non-string value in '", LOCALE_PARAM_NAME,

core/analysis/text_token_stream.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ struct icu_objects {
9393

9494
std::unique_ptr<IRESEARCH_ICU_NAMESPACE::Transliterator> transliterator;
9595
std::unique_ptr<IRESEARCH_ICU_NAMESPACE::BreakIterator> break_iterator;
96-
const IRESEARCH_ICU_NAMESPACE::Normalizer2* normalizer{}; // reusable object owned by ICU
96+
const IRESEARCH_ICU_NAMESPACE::Normalizer2*
97+
normalizer{}; // reusable object owned by ICU
9798
stemmer_ptr stemmer;
9899
};
99100

@@ -445,7 +446,8 @@ bool init_from_options(const analysis::text_token_stream::options_t& options,
445446
UErrorCode::U_ZERO_ERROR; // a value that passes the U_SUCCESS() test
446447

447448
// reusable object owned by ICU
448-
objects->normalizer = IRESEARCH_ICU_NAMESPACE::Normalizer2::getNFCInstance(err);
449+
objects->normalizer =
450+
IRESEARCH_ICU_NAMESPACE::Normalizer2::getNFCInstance(err);
449451

450452
if (!U_SUCCESS(err) || !objects->normalizer) {
451453
objects->normalizer = nullptr;
@@ -469,8 +471,9 @@ bool init_from_options(const analysis::text_token_stream::options_t& options,
469471
// leaks in ICU
470472

471473
// reusable object owned by *this
472-
objects->transliterator.reset(IRESEARCH_ICU_NAMESPACE::Transliterator::createInstance(
473-
collationRule, UTransDirection::UTRANS_FORWARD, err));
474+
objects->transliterator.reset(
475+
IRESEARCH_ICU_NAMESPACE::Transliterator::createInstance(
476+
collationRule, UTransDirection::UTRANS_FORWARD, err));
474477

475478
if (!U_SUCCESS(err) || !objects->transliterator) {
476479
objects->transliterator.reset();
@@ -488,7 +491,8 @@ bool init_from_options(const analysis::text_token_stream::options_t& options,
488491

489492
// reusable object owned by *this
490493
objects->break_iterator.reset(
491-
IRESEARCH_ICU_NAMESPACE::BreakIterator::createWordInstance(options.locale, err));
494+
IRESEARCH_ICU_NAMESPACE::BreakIterator::createWordInstance(options.locale,
495+
err));
492496

493497
if (!U_SUCCESS(err) || !objects->break_iterator) {
494498
objects->break_iterator.reset();
@@ -519,12 +523,13 @@ bool init_from_options(const analysis::text_token_stream::options_t& options,
519523
return true;
520524
}
521525

522-
bool locale_from_string(std::string locale_name, IRESEARCH_ICU_NAMESPACE::Locale& locale) {
526+
bool locale_from_string(std::string locale_name,
527+
IRESEARCH_ICU_NAMESPACE::Locale& locale) {
523528
locale = IRESEARCH_ICU_NAMESPACE::Locale::createFromName(locale_name.c_str());
524529

525530
if (!locale.isBogus()) {
526-
locale = IRESEARCH_ICU_NAMESPACE::Locale{locale.getLanguage(), locale.getCountry(),
527-
locale.getVariant()};
531+
locale = IRESEARCH_ICU_NAMESPACE::Locale{
532+
locale.getLanguage(), locale.getCountry(), locale.getVariant()};
528533
}
529534

530535
if (locale.isBogus()) {
@@ -538,7 +543,8 @@ bool locale_from_string(std::string locale_name, IRESEARCH_ICU_NAMESPACE::Locale
538543
return true;
539544
}
540545

541-
bool locale_from_slice(VPackSlice slice, IRESEARCH_ICU_NAMESPACE::Locale& locale) {
546+
bool locale_from_slice(VPackSlice slice,
547+
IRESEARCH_ICU_NAMESPACE::Locale& locale) {
542548
if (!slice.isString()) {
543549
IRS_LOG_WARN(absl::StrCat(
544550
"Non-string value in '", LOCALE_PARAM_NAME,
@@ -1001,7 +1007,8 @@ bool text_token_stream::reset(std::string_view data) {
10011007
}
10021008

10031009
state_->data = IRESEARCH_ICU_NAMESPACE::UnicodeString::fromUTF8(
1004-
IRESEARCH_ICU_NAMESPACE::StringPiece{data.data(), static_cast<int32_t>(data.size())});
1010+
IRESEARCH_ICU_NAMESPACE::StringPiece{data.data(),
1011+
static_cast<int32_t>(data.size())});
10051012

10061013
// tokenise the unicode data
10071014
state_->break_iterator->setText(state_->data);

tests/analysis/collation_token_stream_test.cpp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,9 @@ TEST(collation_token_stream_test, check_collation) {
194194
auto get_collation_key = [&](std::string_view data) -> irs::bytes_view {
195195
err = UErrorCode::U_ZERO_ERROR;
196196
IRESEARCH_ICU_NAMESPACE::CollationKey key;
197-
coll->getCollationKey(IRESEARCH_ICU_NAMESPACE::UnicodeString::fromUTF8(IRESEARCH_ICU_NAMESPACE::StringPiece{
198-
data.data(), static_cast<int32_t>(data.size())}),
197+
coll->getCollationKey(IRESEARCH_ICU_NAMESPACE::UnicodeString::fromUTF8(
198+
IRESEARCH_ICU_NAMESPACE::StringPiece{
199+
data.data(), static_cast<int32_t>(data.size())}),
199200
key, err);
200201
EXPECT_TRUE(U_SUCCESS(err));
201202

@@ -277,8 +278,9 @@ TEST(collation_token_stream_test, check_collation_with_variant1) {
277278
auto get_collation_key = [&](std::string_view data) -> irs::bytes_view {
278279
err = UErrorCode::U_ZERO_ERROR;
279280
IRESEARCH_ICU_NAMESPACE::CollationKey key;
280-
coll->getCollationKey(IRESEARCH_ICU_NAMESPACE::UnicodeString::fromUTF8(IRESEARCH_ICU_NAMESPACE::StringPiece{
281-
data.data(), static_cast<int32_t>(data.size())}),
281+
coll->getCollationKey(IRESEARCH_ICU_NAMESPACE::UnicodeString::fromUTF8(
282+
IRESEARCH_ICU_NAMESPACE::StringPiece{
283+
data.data(), static_cast<int32_t>(data.size())}),
282284
key, err);
283285
EXPECT_TRUE(U_SUCCESS(err));
284286

@@ -558,8 +560,9 @@ TEST(collation_token_stream_test, check_collation_with_variant2) {
558560
auto get_collation_key = [&](std::string_view data) -> irs::bytes_view {
559561
err = UErrorCode::U_ZERO_ERROR;
560562
IRESEARCH_ICU_NAMESPACE::CollationKey key;
561-
coll->getCollationKey(IRESEARCH_ICU_NAMESPACE::UnicodeString::fromUTF8(IRESEARCH_ICU_NAMESPACE::StringPiece{
562-
data.data(), static_cast<int32_t>(data.size())}),
563+
coll->getCollationKey(IRESEARCH_ICU_NAMESPACE::UnicodeString::fromUTF8(
564+
IRESEARCH_ICU_NAMESPACE::StringPiece{
565+
data.data(), static_cast<int32_t>(data.size())}),
563566
key, err);
564567
EXPECT_TRUE(U_SUCCESS(err));
565568

@@ -715,7 +718,8 @@ TEST(collation_token_stream_test, check_tokens_utf8) {
715718

716719
constexpr std::string_view locale_name = "en-EN.UTF-8";
717720

718-
const auto icu_locale = IRESEARCH_ICU_NAMESPACE::Locale::createFromName(locale_name.data());
721+
const auto icu_locale =
722+
IRESEARCH_ICU_NAMESPACE::Locale::createFromName(locale_name.data());
719723

720724
CollationEncoder encodedKey;
721725
std::unique_ptr<IRESEARCH_ICU_NAMESPACE::Collator> coll{
@@ -726,8 +730,9 @@ TEST(collation_token_stream_test, check_tokens_utf8) {
726730
auto get_collation_key = [&](std::string_view data) -> irs::bytes_view {
727731
err = UErrorCode::U_ZERO_ERROR;
728732
IRESEARCH_ICU_NAMESPACE::CollationKey key;
729-
coll->getCollationKey(IRESEARCH_ICU_NAMESPACE::UnicodeString::fromUTF8(IRESEARCH_ICU_NAMESPACE::StringPiece{
730-
data.data(), static_cast<int32_t>(data.size())}),
733+
coll->getCollationKey(IRESEARCH_ICU_NAMESPACE::UnicodeString::fromUTF8(
734+
IRESEARCH_ICU_NAMESPACE::StringPiece{
735+
data.data(), static_cast<int32_t>(data.size())}),
731736
key, err);
732737
EXPECT_TRUE(U_SUCCESS(err));
733738

@@ -816,7 +821,8 @@ TEST(collation_token_stream_test, check_tokens) {
816821

817822
constexpr std::string_view locale_name = "de-DE";
818823

819-
const auto icu_locale = IRESEARCH_ICU_NAMESPACE::Locale::createFromName(locale_name.data());
824+
const auto icu_locale =
825+
IRESEARCH_ICU_NAMESPACE::Locale::createFromName(locale_name.data());
820826

821827
CollationEncoder encodedKey;
822828
std::unique_ptr<IRESEARCH_ICU_NAMESPACE::Collator> coll{
@@ -828,8 +834,9 @@ TEST(collation_token_stream_test, check_tokens) {
828834
auto get_collation_key = [&](std::string_view data) -> irs::bytes_view {
829835
IRESEARCH_ICU_NAMESPACE::CollationKey key;
830836
err = UErrorCode::U_ZERO_ERROR;
831-
coll->getCollationKey(IRESEARCH_ICU_NAMESPACE::UnicodeString::fromUTF8(IRESEARCH_ICU_NAMESPACE::StringPiece{
832-
data.data(), static_cast<int32_t>(data.size())}),
837+
coll->getCollationKey(IRESEARCH_ICU_NAMESPACE::UnicodeString::fromUTF8(
838+
IRESEARCH_ICU_NAMESPACE::StringPiece{
839+
data.data(), static_cast<int32_t>(data.size())}),
833840
key, err);
834841
EXPECT_TRUE(U_SUCCESS(err));
835842

tests/analysis/text_analyzer_tests.cpp

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ TEST_F(TextAnalyzerParserTestSuite, consts) {
107107
TEST_F(TextAnalyzerParserTestSuite, test_nbsp_whitespace) {
108108
irs::analysis::text_token_stream::options_t options;
109109

110-
options.locale =
111-
IRESEARCH_ICU_NAMESPACE::Locale::createFromName("C.UTF-8"); // utf8 encoding used bellow
110+
options.locale = IRESEARCH_ICU_NAMESPACE::Locale::createFromName(
111+
"C.UTF-8"); // utf8 encoding used bellow
112112

113113
std::string sDataUTF8 = "1,24 prosenttia";
114114

@@ -153,7 +153,8 @@ TEST_F(TextAnalyzerParserTestSuite, test_text_analyzer) {
153153
{
154154
irs::analysis::text_token_stream::options_t options;
155155

156-
options.locale = IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.UTF-8");
156+
options.locale =
157+
IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.UTF-8");
157158

158159
std::string data =
159160
" A hErd of quIck brown foXes ran and Jumped over a "
@@ -256,7 +257,8 @@ TEST_F(TextAnalyzerParserTestSuite, test_text_analyzer) {
256257

257258
{
258259
irs::analysis::text_token_stream::options_t options;
259-
options.locale = IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.UTF-8");
260+
options.locale =
261+
IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.UTF-8");
260262

261263
irs::analysis::text_token_stream stream(options,
262264
options.explicit_stopwords);
@@ -296,7 +298,8 @@ TEST_F(TextAnalyzerParserTestSuite, test_text_analyzer) {
296298
{
297299
irs::analysis::text_token_stream::options_t options;
298300
options.case_convert = irs::analysis::text_token_stream::LOWER;
299-
options.locale = IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.UTF-8");
301+
options.locale =
302+
IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.UTF-8");
300303
irs::analysis::text_token_stream stream(options,
301304
options.explicit_stopwords);
302305
testFunc(data, &stream);
@@ -335,7 +338,8 @@ TEST_F(TextAnalyzerParserTestSuite, test_text_analyzer) {
335338
{
336339
irs::analysis::text_token_stream::options_t options;
337340
options.case_convert = irs::analysis::text_token_stream::UPPER;
338-
options.locale = IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.UTF-8");
341+
options.locale =
342+
IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.UTF-8");
339343
irs::analysis::text_token_stream stream(options,
340344
options.explicit_stopwords);
341345
testFunc(data, &stream);
@@ -374,7 +378,8 @@ TEST_F(TextAnalyzerParserTestSuite, test_text_analyzer) {
374378
{
375379
irs::analysis::text_token_stream::options_t options;
376380
options.case_convert = irs::analysis::text_token_stream::NONE;
377-
options.locale = IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.UTF-8");
381+
options.locale =
382+
IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.UTF-8");
378383
irs::analysis::text_token_stream stream(options,
379384
options.explicit_stopwords);
380385
testFunc(data, &stream);
@@ -428,7 +433,8 @@ TEST_F(TextAnalyzerParserTestSuite, test_text_analyzer) {
428433
{
429434
irs::analysis::text_token_stream::options_t options;
430435
options.explicit_stopwords = {"a", "of", "and"};
431-
options.locale = IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.UTF-8");
436+
options.locale =
437+
IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.UTF-8");
432438
irs::analysis::text_token_stream stream(options,
433439
options.explicit_stopwords);
434440
testFunc(data, &stream);
@@ -525,7 +531,8 @@ TEST_F(TextAnalyzerParserTestSuite, test_text_analyzer) {
525531
{
526532
irs::analysis::text_token_stream::options_t options;
527533
// we ignore encoding specified in locale
528-
options.locale = IRESEARCH_ICU_NAMESPACE::Locale::createFromName("ru_RU.UTF-16");
534+
options.locale =
535+
IRESEARCH_ICU_NAMESPACE::Locale::createFromName("ru_RU.UTF-16");
529536
irs::analysis::text_token_stream stream(options,
530537
options.explicit_stopwords);
531538
testFunc(irs::ViewCast<char>(data), &stream);
@@ -586,8 +593,8 @@ TEST_F(TextAnalyzerParserTestSuite, test_text_analyzer) {
586593

587594
{
588595
irs::analysis::text_token_stream::options_t options;
589-
options.locale =
590-
IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.utf32"); // ignore encoding
596+
options.locale = IRESEARCH_ICU_NAMESPACE::Locale::createFromName(
597+
"en_US.utf32"); // ignore encoding
591598
irs::analysis::text_token_stream stream(options,
592599
options.explicit_stopwords);
593600

@@ -1306,7 +1313,8 @@ TEST_F(TextAnalyzerParserTestSuite, test_text_ngrams) {
13061313

13071314
{
13081315
irs::analysis::text_token_stream::options_t options;
1309-
options.locale = IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.UTF-8");
1316+
options.locale =
1317+
IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.UTF-8");
13101318
options.explicit_stopwords.emplace("a");
13111319
options.min_gram = 4;
13121320
options.min_gram_set = true;
@@ -1340,7 +1348,8 @@ TEST_F(TextAnalyzerParserTestSuite, test_text_ngrams) {
13401348

13411349
{
13421350
irs::analysis::text_token_stream::options_t options;
1343-
options.locale = IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.UTF-8");
1351+
options.locale =
1352+
IRESEARCH_ICU_NAMESPACE::Locale::createFromName("en_US.UTF-8");
13441353
options.explicit_stopwords.emplace("a");
13451354
options.min_gram = 4;
13461355
options.min_gram_set = true;

0 commit comments

Comments
 (0)