| 1 | ## -*- Mode: CPerl -*- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## File: DiaColloDB::Compat::v0_11::Relation::Unigrams.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Author: Bryan Jurish <moocow@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Description: collocation db, profiling relation: unigram database (using DiaColloDB::PackedFile) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | package DiaColloDB::Compat::v0_11::Relation::Unigrams; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use DiaColloDB::Relation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use DiaColloDB::PackedFile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use DiaColloDB::Utils qw(:fcntl :sort :env :run :pack :file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Fcntl qw(:DEFAULT :seek); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use File::Basename qw(dirname); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | ## Globals & Constants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | our @ISA = qw(DiaColloDB::Relation::Unigrams DiaColloDB::Compat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ## Constructors etc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ## $ug = CLASS_OR_OBJECT->new(%args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ## + %args, object structure: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ## ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ## ##-- user options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ## base => $basename, ##-- file basename (default=undef:none); use files "${base}.dba1", "${base}.dba2", "${base}.hdr" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ## flags => $flags, ##-- fcntl flags or open-mode (default='r') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ## perms => $perms, ##-- creation permissions (default=(0666 &~umask)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ## pack_i => $pack_i, ##-- pack-template for IDs (default='N') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ## pack_f => $pack_f, ##-- pack-template for frequencies (default='N') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ## pack_d => $pack_d, ##-- pack-tempalte for dates (default='n') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ## keeptmp => $bool, ##-- keep temporary files? (default=false) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ## mmap => $bool, ##-- use mmap access? (default=true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ## logCompat => $level, ##-- log-level for compatibility warnings (default='warn') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ## ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ## ##-- size info (after open() or load()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ## size1 => $size1, ##-- == $r1->size() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ## size2 => $size2, ##-- == $r2->size() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ## ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ## ##-- low-level data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ## r1 => $r1, ##-- pf: [$end2] @ $i1 : constant (logical index) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ## r2 => $r2, ##-- pf: [$d1,$f1]* @ end2($i1-1)..(end2($i1+1)-1) : sorted by $d1 for each $i1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | ## N => $N, ##-- sum($f1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ## version => $version, ##-- file version, for compatibility checks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ## ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ## inherited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ## Persistent API: disk usage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # inherited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ## I/O | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ##-------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ## I/O: open/close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ## $ug_or_undef = $ug->open($base,$flags) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ## $ug_or_undef = $ug->open($base) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | ## $ug_or_undef = $ug->open() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub open { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my ($ug,$base,$flags) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | $base //= $ug->{base}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$base //= $ug->{"base"}
MC/DC0%0/2
$base //= $ug->{"base"}
$base
$ug->{"base"}
Truth table0%0/3
A //= B
A= $baseB= $ug->{"base"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $flags //= $ug->{flags}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$flags //= $ug->{"flags"}
MC/DC0%0/2
$flags //= $ug->{"flags"}
$flags
$ug->{"flags"}
Truth table0%0/3
A //= B
A= $flagsB= $ug->{"flags"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | $ug->close() if ($ug->opened); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $ug->{base} = $base; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $ug->{flags} = $flags = fcflags($flags); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my ($hdr); ##-- save header, for version-checking | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if (fcread($flags) && !fctrunc($flags)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
fcread($flags) and not fctrunc($flags)
MC/DC0%0/2
fcread($flags) and not fctrunc($flags)
fcread($flags)
not fctrunc($flags)
Truth table0%0/3
A and not(B)
A= fcread($flags)B= not fctrunc($flags)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | $hdr = ($ug->readHeader() || $ug->readHeader("$ug->{base}.dba.hdr")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ug->readHeader || $ug->readHeader("$ug->{'base'}.dba.hdr")
MC/DC0%0/2
$ug->readHeader || $ug->readHeader("$ug->{'base'}.dba.hdr")
$ug->readHeader
$ug->readHeader("$ug->{'base'}.dba.hdr")
Truth table0%0/3
A || B
A= $ug->readHeaderB= $ug->readHeader("$ug->{'base'}.dba.hdr")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | or $ug->logconfess("failed to read header data from '$ug->{base}.hdr': $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | $ug->loadHeaderData($hdr) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | or $ug->logconess("failed to load header data from '$ug->{base}.hdr': $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ##-- check compatibility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $min_version = qv(0.10.000); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if ($hdr && (!defined($hdr->{version}) || version->parse($hdr->{version}) < $min_version)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$hdr and !defined($hdr->{"version"}) || "version"->parse($hdr->{"version"}) < $min_version
not defined $hdr->{"version"} or "version"->parse($hdr->{"version"}) < $min_version
MC/DC0%0/3
$hdr and !defined($hdr->{"version"}) || "version"->parse($hdr->{"version"}) < $min_version
$hdr
not defined $hdr->{"version"}
"version"->parse($hdr->{"version"}) < $min_version
Truth table0%0/4
A and not(B) or C
A= $hdrB= not defined $hdr->{"version"}C= "version"->parse($hdr->{"version"}) < $min_version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $ug->vlog($ug->{logCompat}, "using v0.09 compatibility mode for $ug->{base}.*; consider running \`dcdb-upgrade.perl ", dirname($ug->{base}), "\'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | DiaColloDB::Compat->usecompat('v0_09'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | bless($ug, 'DiaColloDB::Compat::v0_09::Relation::Unigrams'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $ug->{version} = $hdr->{version}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | return $ug->open("$base.dba",$flags); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ##-- open low-level data structures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | $ug->{r1}->open("$base.dba1", $flags, perms=>$ug->{perms}, packas=>"$ug->{pack_i}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | or $ug->logconfess("open failed for $base.dba1: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | $ug->{r2}->open("$base.dba2", $flags, perms=>$ug->{perms}, packas=>"$ug->{pack_d}$ug->{pack_f}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | or $ug->logconfess("open failed for $base.dba2: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $ug->{size1} = $ug->{r1}->size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $ug->{size2} = $ug->{r2}->size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | return $ug; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | ## $ug_or_undef = $ug->close() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | sub close { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my $ug = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if ($ug->opened && fcwrite($ug->{flags})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ug->opened and fcwrite($ug->{"flags"})
MC/DC0%0/2
$ug->opened and fcwrite($ug->{"flags"})
$ug->opened
fcwrite($ug->{"flags"})
Truth table0%0/3
A and B
A= $ug->openedB= fcwrite($ug->{"flags"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | $ug->saveHeader() or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | $ug->{r1}->close() or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | $ug->{r2}->close() or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | undef $ug->{base}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | return $ug; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ## $bool = $ug->opened() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | sub opened { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
opened: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $ug = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | (defined($ug->{base}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | && defined($ug->{r1}) && $ug->{r1}->opened | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | && defined($ug->{r2}) && $ug->{r2}->opened | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/12
defined $ug->{'base'} && defined $ug->{'r1'} && $ug->{'r1'}->opened && defined $ug->{'r2'} && $ug->{'r2'}->opened
defined $ug->{"base"} and defined $ug->{"r1"} and $ug->{"r1"}->opened and defined $ug->{"r2"}
defined $ug->{"base"} and defined $ug->{"r1"} and $ug->{"r1"}->opened
defined $ug->{"base"} and defined $ug->{"r1"}
MC/DC0%0/5
defined $ug->{'base'} && defined $ug->{'r1'} && $ug->{'r1'}->opened && defined $ug->{'r2'} && $ug->{'r2'}->opened
defined $ug->{"base"}
defined $ug->{"r1"}
$ug->{"r1"}->opened
defined $ug->{"r2"}
$ug->{'r2'}->opened
Truth table0%0/6
A and B and C and D && E
A= defined $ug->{"base"}B= defined $ug->{"r1"}C= $ug->{"r1"}->openedD= defined $ug->{"r2"}E= $ug->{'r2'}->opened
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | ##-------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ## I/O: header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | ## + inherited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ##-------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | ## I/O: text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | ## + inherited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ## $bool = $obj->loadTextFile($filename_or_handle, %opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | ## + wraps loadTextFh() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | ## + INHERITED from DiaColloDB::Persistent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | ## $ug = $ug->loadTextFh($fh,%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | ## + loads from text file as saved by saveTextFh() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ## + input fh must be sorted by $i1,$d1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | ## + supports multiple lines for pairs ($i1,$d1) provided the above conditions hold | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | ## + supports loading of $ug->{N} from single-component lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | ## + %opts: clobber %$ug | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 1 | *loadTextFh = __PACKAGE__->nocompat('loadTextFh'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | ## $bool = $obj->saveTextFile($filename_or_handle, %opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | ## + wraps saveTextFh() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | ## + INHERITED from DiaColloDB::Persistent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | ## $bool = $ug->saveTextFh($fh,%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | ## + save from text file with lines of the form: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | ## N ##-- 1 field : N | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ## FREQ ID1 DATE ##-- 3 fields: unigram frequency for (ID1,DATE) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ## + %opts: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | ## i2s => \&CODE, ##-- code-ref for formatting indices; called as $s=CODE($i) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | ## Relation API: create, union | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ## + disabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | *create = __PACKAGE__->nocompat('create'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | *union = __PACKAGE__->nocompat('union'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | ## Relation API: dbinfo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | ## + inherited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ## Utilities: lookup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ## $N = $cof->sliceN($slice,$dateLo) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | ## + get total slice co-occurrence count (compatible wrapper uses constant $cof->{N} for all slices) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | sub sliceN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sliceN: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | #my ($cof,$slice,$dlo) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | return $_[0]{N}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | ## Relation API: default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | ## + inherited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | ## Footer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||