Skip to content

Commit

Permalink
Clarify the status of "collate"
Browse files Browse the repository at this point in the history
And add tests
  • Loading branch information
lizmat committed May 31, 2024
1 parent 6a710c0 commit c0d678d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Revision history for ParaSeq
{{$NEXT}}
- Added Theory of operation section in documentation
- Updated status of ".sort" and added tests
- Updated status of ".collate" and added tests

0.0.7 2024-05-30T14:24:50+02:00
- Added optimized ".batch" and tests
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ batch
collate
-------

[`.collate`](https://docs.raku.org/type/Any#method_collate)
**Status**: the nature of the [`.collate`](https://docs.raku.org/type/Any#method_collate) method basically makes it impossible to hyper. Therefore, **no** specific hypering logic has been added for this method.

combinations
------------
Expand Down
8 changes: 6 additions & 2 deletions doc/ParaSeq.rakudoc
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ has been implemented.

=head2 collate

B<Status>: the nature of the
L<C<.collate>|https://docs.raku.org/type/Any#method_collate>
method basically makes it impossible to hyper. Therefore, B<no>
specific hypering logic has been added for this method.

=head2 combinations

Expand Down Expand Up @@ -942,11 +945,12 @@ be increased.

=begin code
/---------------------------------------------------------\
| | |
| | |
| ⬇ |
| -------------- ------------ |
| | statistics | /-----⮕ | producer | ⮕ -|
| -------------- / ------------ |
/ |
/ |
----------- ------------ ----------- ------------ |
| results | ⮕ | deliverer | ⮕ | batcher | ⮕ | producer | ⮕ -|
----------- ------------ ----------- ------------ |
Expand Down
4 changes: 2 additions & 2 deletions lib/ParaSeq.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -1472,8 +1472,8 @@ class ParaSeq does Sequence {
#- interfaces that are just infectious -----------------------------------------

proto method collate(|) {*}
multi method collate(ParaSeq:D: |c) {
self!pass-the-chain: self.List.collate(|c).iterator
multi method collate(ParaSeq:D:) {
self!pass-the-chain: self.List.collate.iterator
}

multi method combinations(ParaSeq:D: $of) {
Expand Down
6 changes: 3 additions & 3 deletions t/35-sort.rakutest
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use ParaSeq;

plan 12;

my constant $elems = 200000;
my constant $batch = 16;
my constant @list = (^$elems).reverse.List;
my constant $elems = 200000;
my constant @list = (^$elems).reverse.List;
my constant @sorted = @list.sort.List;
my constant $asStr = *.Str;
my constant @sorteds = @list.sort($asStr).List;
my constant $reverse = { $^b cmp $^a };
my constant @sortedr = @list.sort($reverse).List;
my constant $batch = 16;

for 1, ParaSeq.default-degree {
my $seq := @list.&hyperize($batch, $_).sort;
Expand Down
17 changes: 17 additions & 0 deletions t/36-collate.rakutest
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use Test;
use ParaSeq;

plan 4;

my constant $elems = 200000;
my constant @list = (^$elems).reverse.map(*.Str).List;
my constant @collated = @list.collate.List;
my constant $batch = 16;

for 1, ParaSeq.default-degree {
my $seq := @list.&hyperize($batch, $_).collate;
isa-ok $seq, $_ == 1 ?? Seq !! ParaSeq;
is-deeply $seq.List, @collated, ".collate with degree = $_";
}

# vim: expandtab shiftwidth=4

0 comments on commit c0d678d

Please sign in to comment.