Sort::External 0.16
Sponsored Links
Sort::External 0.16 Ranking & Summary
File size:
0.022 MB
Platform:
Any Platform
License:
Perl Artistic License
Price:
Downloads:
886
Date added:
2007-05-21
Publisher:
Marvin Humphrey
Sort::External 0.16 description
Sort::External is a Perl module that can sort huge lists.
SYNOPSIS
my $sortex = Sort::External->new( -mem_threshold => 2**24 );
while (
) {
$sortex->feed($_);
}
$sortex->finish;
while ( defined( $_ = $sortex->fetch ) ) {
&do_stuff_with($_);
}
Problem: You have a list which is too big to sort in-memory.
Solution: "feed, finish, and fetch" with Sort::External, the closest thing to a drop-in replacement for Perls sort() function when dealing with unmanageably large lists.
How it works:
Cache sortable items in memory. Periodically sort the cache and empty it into a temporary sortfile. As sortfiles accumulate, interleave them into larger sortfiles. Complete the sort by sorting the input cache and any existing sortfiles into an output stream.
Note that if Sort::External hasnt yet flushed the cache to disk when finish() is called, the whole operation completes in-memory.
In the CompSci world, "internal sorting" refers to sorting data in RAM, while "external sorting" refers to sorting data which is stored on disk, tape, punchcards, or any storage medium except RAM -- hence, this modules name.
Stringification
Items fed to Sort::External will be returned in stringified form (assuming that the cache gets flushed at least once): $foo = "$foo". Since this is unlikely to be desirable when objects or deep data structures are involved, Sort::External throws an error if you feed it anything other than simple scalars.
Taint and UTF-8 flags
Expert: Sort::External does a little extra bookkeeping to sustain each items taint and UTF-8 flags through the journey to disk and back.
METHODS
new()
my $sortscheme = sub { $Sort::External::b <=> $Sort::External::a };
my $sortex = Sort::External->new(
-mem_threshold => 2**24, # default: 2**20 (1Mb)
-cache_size => 100_000, # default: undef (disabled)
-sortsub => $sortscheme, # default sort: standard lexical
-working_dir => $temp_directory, # default: see below
);
Construct a Sort::External object.
-mem_threshold -- Allow the input cache to consume approximately -mem_threshold bytes before sorting it and flushing to disk. Experience suggests that the optimum setting is somewhere between 2**20 and 2**24: 1-16Mb.
-cache_size -- Specify a hard limit for the input cache in terms of sortable items. If set, overrides -mem_threshold.
-sortsub -- A sorting subroutine. Be advised that you MUST use $Sort::External::a and $Sort::External::b instead of $a and $b in your sub. Before deploying a sortsub, consider using a GRT instead, as described in the Sort::External::Cookbook. Its probably a lot faster.
-working_dir -- The directory where the temporary sortfiles will reside. By default, this directory is created using File::Temps tempdir() command.
feed()
$sortex->feed( @items );
Feed one or more sortable items to your Sort::External object. It is normal for occasional pauses to occur during feeding as caches are flushed and sortfiles are merged.
finish()
# if you intend to call fetch...
$sortex->finish;
# otherwise....
use Fcntl;
$sortex->finish(
-outfile => sorted.txt,
-flags => (O_CREAT | O_WRONLY),
);
Prepare to output items in sorted order.
If you specify the parameter -outfile, Sort::External will attempt to write your sorted list to that location. By default, Sort::External will refuse to overwrite an existing file; if you want to override that behavior, you can pass Fcntl flags to finish() using the optional -flags parameter.
Note that you can either finish() to an -outfile, or finish() then fetch()... but not both.
fetch()
while ( defined( $_ = $sortex->fetch ) ) {
&do_stuff_with($_);
}
Fetch the next sorted item.
SYNOPSIS
my $sortex = Sort::External->new( -mem_threshold => 2**24 );
while (
$sortex->feed($_);
}
$sortex->finish;
while ( defined( $_ = $sortex->fetch ) ) {
&do_stuff_with($_);
}
Problem: You have a list which is too big to sort in-memory.
Solution: "feed, finish, and fetch" with Sort::External, the closest thing to a drop-in replacement for Perls sort() function when dealing with unmanageably large lists.
How it works:
Cache sortable items in memory. Periodically sort the cache and empty it into a temporary sortfile. As sortfiles accumulate, interleave them into larger sortfiles. Complete the sort by sorting the input cache and any existing sortfiles into an output stream.
Note that if Sort::External hasnt yet flushed the cache to disk when finish() is called, the whole operation completes in-memory.
In the CompSci world, "internal sorting" refers to sorting data in RAM, while "external sorting" refers to sorting data which is stored on disk, tape, punchcards, or any storage medium except RAM -- hence, this modules name.
Stringification
Items fed to Sort::External will be returned in stringified form (assuming that the cache gets flushed at least once): $foo = "$foo". Since this is unlikely to be desirable when objects or deep data structures are involved, Sort::External throws an error if you feed it anything other than simple scalars.
Taint and UTF-8 flags
Expert: Sort::External does a little extra bookkeeping to sustain each items taint and UTF-8 flags through the journey to disk and back.
METHODS
new()
my $sortscheme = sub { $Sort::External::b <=> $Sort::External::a };
my $sortex = Sort::External->new(
-mem_threshold => 2**24, # default: 2**20 (1Mb)
-cache_size => 100_000, # default: undef (disabled)
-sortsub => $sortscheme, # default sort: standard lexical
-working_dir => $temp_directory, # default: see below
);
Construct a Sort::External object.
-mem_threshold -- Allow the input cache to consume approximately -mem_threshold bytes before sorting it and flushing to disk. Experience suggests that the optimum setting is somewhere between 2**20 and 2**24: 1-16Mb.
-cache_size -- Specify a hard limit for the input cache in terms of sortable items. If set, overrides -mem_threshold.
-sortsub -- A sorting subroutine. Be advised that you MUST use $Sort::External::a and $Sort::External::b instead of $a and $b in your sub. Before deploying a sortsub, consider using a GRT instead, as described in the Sort::External::Cookbook. Its probably a lot faster.
-working_dir -- The directory where the temporary sortfiles will reside. By default, this directory is created using File::Temps tempdir() command.
feed()
$sortex->feed( @items );
Feed one or more sortable items to your Sort::External object. It is normal for occasional pauses to occur during feeding as caches are flushed and sortfiles are merged.
finish()
# if you intend to call fetch...
$sortex->finish;
# otherwise....
use Fcntl;
$sortex->finish(
-outfile => sorted.txt,
-flags => (O_CREAT | O_WRONLY),
);
Prepare to output items in sorted order.
If you specify the parameter -outfile, Sort::External will attempt to write your sorted list to that location. By default, Sort::External will refuse to overwrite an existing file; if you want to override that behavior, you can pass Fcntl flags to finish() using the optional -flags parameter.
Note that you can either finish() to an -outfile, or finish() then fetch()... but not both.
fetch()
while ( defined( $_ = $sortex->fetch ) ) {
&do_stuff_with($_);
}
Fetch the next sorted item.
Sort::External 0.16 Screenshot
Sort::External 0.16 Keywords
External 0.16
Perl module
finish
sort
sorting
items
fetch
cache
Sort::External
SortExternal
Sort::External 0.16
Libraries
Programming
Bookmark Sort::External 0.16
Sort::External 0.16 Copyright
WareSeeker periodically updates pricing and software information of Sort::External 0.16 full version from the publisher, so some information may be slightly out-of-date. You should confirm all information before relying on it. Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future development of Sort::External 0.16 Edition. Download links are directly from our publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed
Featured Software
Want to place your software product here?
Please contact us for consideration.
Contact WareSeeker.com
Related Information
Related Software
external IP shows your current external IP in the browsers statusbar. Free Download
Exporter::Easy is a Perl module that takes the drudgery out of Exporting symbols. Free Download
Sort::Radix is a Perl module with multiple passes distribution sort algorithm. Free Download
StreamTuned plays and records audio and video streams using mplayer as backend. Free Download
Sort::Fields is a Perl module that can sort lines containing delimited fields. Free Download
Sort::Versions is a Perl 5 module for sorting of revision-like numbers. Free Download
Text::Emoticon::GoogleTalk is a Perl module emoticon filter of GoogleTalk. Free Download
Robsort Sorting Algorithm is a sorting algorithm which uses random numbers. Free Download
Latest Software
Popular Software
Favourite Software