| 1 | package BenchmarkAnything::Storage::Backend::SQL::Search::MCE; | ||
| 2 | our $AUTHORITY = 'cpan:TAPPER'; | ||
| 3 | # ABSTRACT: searchengine support functions using MCE | ||
| 4 | $BenchmarkAnything::Storage::Backend::SQL::Search::MCE::VERSION = '0.028'; | ||
| 5 | use MCE::Flow; | ||
| 6 | |||
| 7 | |||
| 8 | sub sync_search_engine_mce | ||
| 9 | { | ||
| 10 | my ( $or_sql, $b_force, $i_start, $i_bulkcount) = @_; | ||
| 11 | |||
| 12 | require BenchmarkAnything::Storage::Backend::SQL::Search; | ||
| 13 | |||
| 14 | my $i_count_datapoints = $or_sql->{query}->select_count_datapoints->fetch->[0]; | ||
| 15 | |||
| 16 | MCE::Flow::init( chunk_size => $i_bulkcount, | ||
| 17 | max_workers => 8, | ||
| 18 | bounds_only => 1); | ||
| 19 | mce_flow_s sub { | ||
| 20 | BenchmarkAnything::Storage::Backend::SQL::Search::_sync_search_engine_process_chunk ($or_sql, $b_force, $_->[0], $_->[1]); | ||
| 21 | }, $i_start, $i_count_datapoints; | ||
| 22 | } | ||
| 23 | |||
| 24 | 1; | ||
| 25 | |||
| 26 | __END__ | ||
| 27 | |||
| 28 | =pod | ||
| 29 | |||
| 30 | =encoding UTF-8 | ||
| 31 | |||
| 32 | =head1 NAME | ||
| 33 | |||
| 34 | BenchmarkAnything::Storage::Backend::SQL::Search::MCE - searchengine support functions using MCE | ||
| 35 | |||
| 36 | =head1 SYNOPSIS | ||
| 37 | |||
| 38 | Inside a method of BenchmarkAnything::Storage::Backend::SQL: | ||
| 39 | |||
| 40 | require BenchmarkAnything::Storage::Backend::SQL::Search::MCE; | ||
| 41 | BenchmarkAnything::Storage::Backend::SQL::Search::MCE::sync_search_engine_mce( $or_self, $b_force, $i_start, $i_bulksize); | ||
| 42 | |||
| 43 | =head2 sync_search_engine_mce ($or_sql, $b_force, $i_start, $i_bulkcount) | ||
| 44 | |||
| 45 | =over 4 | ||
| 46 | |||
| 47 | =item $or_sql | ||
| 48 | |||
| 49 | The L<BenchmarkAnything::Storage::Backend::SQL|BenchmarkAnything::Storage::Backend::SQL> instance. | ||
| 50 | |||
| 51 | =item $b_force | ||
| 52 | |||
| 53 | Boolean. Re-sync without check if data already exist in index. Default C<false>. | ||
| 54 | |||
| 55 | =item $i_start | ||
| 56 | |||
| 57 | First element ID where to start. Default C<1>. | ||
| 58 | |||
| 59 | =item $i_bulkcount | ||
| 60 | |||
| 61 | How many elements to read and index per bunch. Default C<10000>. | ||
| 62 | |||
| 63 | =back | ||
| 64 | |||
| 65 | =head1 AUTHOR | ||
| 66 | |||
| 67 | Roberto Schaefer <schaefr@amazon.com> | ||
| 68 | |||
| 69 | =head1 COPYRIGHT AND LICENSE | ||
| 70 | |||
| 71 | This software is Copyright (c) 2020 by Amazon.com, Inc. or its affiliates. | ||
| 72 | |||
| 73 | This is free software, licensed under: | ||
| 74 | |||
| 75 | The (two-clause) FreeBSD License | ||
| 76 | |||
| 77 | =cut |