| 1 | package SeeAlso::Source::BeaconAggregator::Maintenance; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 37 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 37 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 37 | ▶ | use Exporter (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 37 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 37 | ▶ | $VERSION = '0.2_90'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 37 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | #Give a hoot don't pollute, do not export more than needed by default | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 37 | @EXPORT = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 37 | @EXPORT_OK = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 37 | %EXPORT_TAGS = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 37 | ▶ | use base ("SeeAlso::Source::BeaconAggregator"); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 37 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 37 | ▶ | use HTTP::Date; # not perfect, but the module is commonly installed... | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 37 | ▶ | use HTTP::Request; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 37 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 37 | ▶ | use File::Temp; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | sasbactrl.pl - command line interface to SeeAlso::Source::BeaconAggregator and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | auxiliary classes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | This Module allows a collection of BEACON files (cf. http://de.wikipedia.org/wiki/Wikipedia:BEACON) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | to be used as SeeAlso::Source (probably in the context of an SeeAlso::Server application). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | Therefore it implements the four methods documented in SeeAlso::Source | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | The BEACON files (lists of non-local identifiers of a certain type documenting the coverage of a given | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | online database plus means for access) are imported by the methods provided by | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | SeeAlso::Source::BeaconAggregator::Maintenance.pm, usually by employing the script sasbactrl.pl | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | as command line client. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | Serving other formats than SeeAlso or providing a BEACON file with respect to this | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | SeeAlso service is achieved by using SeeAlso::Source::BeaconAggregator::Publisher. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | =head1 USAGE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | Use the C<new()> method inherited from C<SeeAlso::Source::BeaconAggregator> to | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | access an existing database or create a new one. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | =head2 Database Methods | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | =head3 init( [ %options] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | Sets up and initializes the database structure for the object. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | This has to be done once after creating a new database and after | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | upgrading this module. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | Valid options include: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | =over 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | =item verbose | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | =item prepareRedirs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | =item identifierClass | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | The I<repos> table contains as columns all valid beacon fields plus | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | the following administrative fields which have to be prefixed with | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | "_" in the interface: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | =over 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | =item seqno | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | Sequence number: Is incremented on any successfull load | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | =item alias | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | Unique key: On update older seqences with the same alias are | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | automatically discarded. Most methods take an alias as | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | argument thus obliterating the need to determine the sequence | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | number. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | =item sort | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | optional sort key | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | =item uri | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | Overrides the #FEED header for updates | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | =item ruri | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | Real uri from which the last instance was loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | =item ftime | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | Fetch time: Timestamp as to when this instance was loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | Clear this or mtime to force automatic reload. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | =item fstat | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | Short statistics line of last successful reload on update. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | =item mtime | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | Modification time: Timestamp of the file / HTTP object from which this instance was loaded. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | Identical to ftime if no timestamp is provided | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | Clear this or ftime to force automatic reload on update. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | =item utime | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | Timestamp of last update attempt | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | =item ustat | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | Short status line of last update attempt. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | =item counti | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | Identifier count | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | =item countu | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | Unique identifier count | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | =item admin | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | Just to store some remarks. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | The I<beacons> table stores the individual beacon entries from the input files. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | Its columns are: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | =over 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | =item hash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | Identifier. If a (subclass of) C<SeeAlso::Source::Identifier> instance is provided, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | this will be transformed by the C<hash()> method. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | =item seqno | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | Sequence number of the beacon file in the database | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | =item altid | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | optional identifier from an alternative identifier system for use | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | with ALTTARGET templates. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | =item hits | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | optional number of hits for this identifier in the given resource | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | =item info | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | optional information text | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | =item link | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | optional explicit URL | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | The I<osd> table contains C<key>, C<val> pairs for various metadata | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | concerning the collection as such, notably the values needed for | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | the Open Search Description and the Header fields needed in case | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | of publishing a beacon file for this collection. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | The I<admin> table stores (unique) C<key>, C<val> pairs for | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | general persistent data. Currently the following keys are defined: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | =over 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | =item DATA_VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | Integer version number to migrate database layout. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | =item IDENTIFIER_CLASS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | Name of the Identifier class to be used. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | =item REDIRECTION_INDEX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | Control creation of an additional index for the I<altid> column | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | (facialiates reverse lookups as needed for clustering). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 9 | ▶ | my ($self, %options) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=51 SCAR=53.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 9 | ▶ | $options{'verbose'} = $self->{'verbose'} unless exists $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 9 | my @fieldlist = SeeAlso::Source::BeaconAggregator->beaconfields(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 9 | my @bf = map{ join(" ", @{[SeeAlso::Source::BeaconAggregator->beaconfields($_)]}[0..1]) } @fieldlist; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 9 | ▶ | my $hdl = $self->{dbh} or croak("no database handle?"); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 9 | local($") = ",\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 9 | ▶ | $hdl->do(<<"XxX" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | CREATE TABLE IF NOT EXISTS repos ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | seqno INTEGER PRIMARY KEY AUTOINCREMENT, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | alias TEXT, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | sort TEXT, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | uri VARCHAR(512), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | ruri VARCHAR(512), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | mtime INTEGER, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | utime INTEGER, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | ftime INTEGER, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | counti INTEGER DEFAULT 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | countu INTEGER DEFAULT 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | fstat TEXT, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | ustat TEXT, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | admin VARCHAR(512), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | @bf | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | ) or croak("Setup error: ".$hdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 9 | ▶ | $hdl->do("CREATE UNIQUE INDEX IF NOT EXISTS seqnos ON repos(seqno);") or croak("Setup error: ".$hdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 9 | ▶ | $hdl->do("CREATE INDEX IF NOT EXISTS aliases ON repos(alias);") or croak("Setup error: ".$hdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 9 | ▶ | $hdl->do(<<"XxX" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | CREATE TABLE IF NOT EXISTS beacons ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | hash CHARACTER(64) NOT NULL, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | seqno INTEGER REFERENCES repos(seqno) ON DELETE CASCADE, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | altid TEXT, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | hits INTEGER, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | info VARCHAR(255), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | link VARCHAR(1024) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | ) or croak("Setup error: ".$hdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # Faciliate lookups | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 9 | ▶ | $hdl->do("CREATE INDEX IF NOT EXISTS lookup ON beacons(hash);") or croak("Setup error: ".$hdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # maintenance and enforce constraints | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # (Problem: Dupes w/o altid but differing in link *and* info fields should be legitimate, too) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 9 | ▶ | $hdl->do("CREATE UNIQUE INDEX IF NOT EXISTS mntnce ON beacons(seqno, hash, altid);") or croak("Setup error: ".$hdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # foreign key on cascade does not work? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 9 | ▶ | $hdl->do(<<"XxX" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | CREATE TRIGGER IF NOT EXISTS on_delete_seqno BEFORE DELETE ON repos FOR EACH ROW | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | DELETE FROM beacons WHERE seqno=OLD.seqno; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | END; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | ) or croak("Setup error: ".$hdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # OpenSearchDescription | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 9 | ▶ | $hdl->do(<<"XxX" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | CREATE TABLE IF NOT EXISTS osd ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | key CHAR(20) NOT NULL, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | val VARCHAR(1024) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | ) or croak("Setup error: ".$hdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 9 | ▶ | $hdl->do("CREATE INDEX IF NOT EXISTS OSDKeys ON osd(key);") or croak("Setup error: ".$hdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # Admin Stuff | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 9 | ▶ | $hdl->do(<<"XxX" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | CREATE TABLE IF NOT EXISTS admin ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | key CHAR(20) PRIMARY KEY NOT NULL, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | val VARCHAR(1024) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | ) or croak("Setup error: ".$hdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 9 | ▶ | $hdl->do("CREATE UNIQUE INDEX IF NOT EXISTS ADMKeys ON admin(key);") or croak("Setup error: ".$hdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 9 | my $admref = $self->admhash(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 9 | my $verkey = "DATA_VERSION"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 9 | my $goalver = $SeeAlso::Source::BeaconAggregator::DATA_VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 9 | ▶ | my $dbver = $admref->{$verkey} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$admref->{$verkey} || 0
MC/DC100%1/1
$admref->{$verkey} || 0
$admref->{$verkey}
Truth table100%2/2
A
A= $admref->{$verkey}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 9 | ▶ | if ( $dbver != $goalver ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | print "NOTICE: Database version $dbver: Upgrading to $goalver\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # alter tables here | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 1 | ▶ | if ( $dbver < 2 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # my ($at, $type) = SeeAlso::Source::BeaconAggregator->beaconfields("COUNT"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # $hdl->do("ALTER TABLE repos ADD COLUMN $at $type;"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # ($at, $type) = SeeAlso::Source::BeaconAggregator->beaconfields("REMARK"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # $hdl->do("ALTER TABLE repos ADD COLUMN $at $type;"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | elsif ( $options{'verbose'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | print "INFO: Database version $dbver is current\n"}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 9 | ▶ | unless ( $dbver == $goalver) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 1 | my $verh = $self->stmtHdl("INSERT OR REPLACE INTO admin VALUES (?, ?);", "update version statement"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | ▶ | $verh->execute($verkey, $goalver) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | or croak("Could not execute update version statement: ".$verh->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 9 | ▶ | unless ( exists $options{'identifierClass'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 3 | ▶ | $options{'identifierClass'} = $self->{'identifierClass'} if exists $self->{'identifierClass'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 9 | my $ickey = "IDENTIFIER_CLASS"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 9 | ▶ | if ( (exists $options{identifierClass}) and (my $wanttype = ref($options{'identifierClass'})) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
exists $options{"identifierClass"} and my $wanttype = ref $options{"identifierClass"}
MC/DC100%2/2
exists $options{"identifierClass"} and my $wanttype = ref $options{"identifierClass"}
exists $options{"identifierClass"}
my $wanttype = ref $options{"identifierClass"}
Truth table100%3/3
A and B
A= exists $options{"identifierClass"}B= my $wanttype = ref $options{"identifierClass"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 5 | ▶ | if ( (exists $self->{identifierClass}) && (ref($self->{identifierClass}) ne $wanttype) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $self->{"identifierClass"} and ref $self->{"identifierClass"} ne $wanttype
MC/DC100%2/2
exists $self->{"identifierClass"} and ref $self->{"identifierClass"} ne $wanttype
exists $self->{"identifierClass"}
ref $self->{"identifierClass"} ne $wanttype
Truth table100%3/3
A and B
A= exists $self->{"identifierClass"}B= ref $self->{"identifierClass"} ne $wanttype
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 1 | croak("Cannot override identifierClass set on new()")}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 4 | ▶ | if ( my $oldtype = $admref->{$ickey} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 2 | ▶ | croak ("Identifier mismatch: Cannot set to $wanttype since database already branded to $oldtype") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | unless($oldtype eq $wanttype); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 2 | ▶ | print "fixing identifierClass as $wanttype\n" if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 2 | my $ichdl = $self->stmtHdl("INSERT INTO admin VALUES (?, ?);", "fix identifier class statement"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 2 | ▶ | $ichdl->execute($ickey, $wanttype) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | or croak("Could not execute fix identifier class statement: ".$ichdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 2 | $self->{identifierClass} = $options{identifierClass}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | ▶ | elsif ( (exists $options{identifierClass}) and (not $options{identifierClass}) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
exists $options{"identifierClass"} and not $options{"identifierClass"}
MC/DC50%1/2
exists $options{"identifierClass"} and not $options{"identifierClass"}
exists $options{"identifierClass"}
not $options{"identifierClass"}
Truth table66%2/3
A and not(B)
A= exists $options{"identifierClass"}B= not $options{"identifierClass"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 2 | ▶ | print "removing fixed identifierClass from admin table\n" if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 2 | my $ichdl = $self->stmtHdl("DELETE FROM admin WHERE key=?;", "identifier class statement"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 2 | ▶ | $ichdl->execute($ickey) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | or croak("Could not execute remove identifier class statement: ".$ichdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 2 | delete $self->{identifierClass}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 8 | my $rikey = "REDIRECTION_INDEX"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 8 | ▶ | if ( exists $options{prepareRedirs} or exists $admref->{$rikey} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $options{"prepareRedirs"} or exists $admref->{$rikey}
MC/DC0%0/2
exists $options{"prepareRedirs"} or exists $admref->{$rikey}
exists $options{"prepareRedirs"}
exists $admref->{$rikey}
Truth table33%1/3
A or B
A= exists $options{"prepareRedirs"}B= exists $admref->{$rikey}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my $rihdl = $self->stmtHdl("INSERT OR REPLACE INTO admin VALUES (?, ?);", "fix redirection index statement"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | if ( $options{prepareRedirs} or ( $admref->{$rikey} and not exists $options{prepareRedirs} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
$options{"prepareRedirs"} or $admref->{$rikey} and not exists $options{"prepareRedirs"}
$admref->{$rikey} and not exists $options{"prepareRedirs"}
MC/DC0%0/3
$options{"prepareRedirs"} or $admref->{$rikey} and not exists $options{"prepareRedirs"}
$options{"prepareRedirs"}
$admref->{$rikey}
not exists $options{"prepareRedirs"}
Truth table0%0/4
A or B and not(C)
A= $options{"prepareRedirs"}B= $admref->{$rikey}C= not exists $options{"prepareRedirs"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | print "creating redirection index\n" if $options{prepareRedirs} and $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$options{"prepareRedirs"} and $options{"verbose"}
MC/DC0%0/2
$options{"prepareRedirs"} and $options{"verbose"}
$options{"prepareRedirs"}
$options{"verbose"}
Truth table0%0/3
A and B
A= $options{"prepareRedirs"}B= $options{"verbose"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | $hdl->do("CREATE INDEX IF NOT EXISTS redir ON beacons(altid,seqno);") or croak("Setup error: ".$hdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | $rihdl->execute($rikey, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | or croak("Could not execute fix redirection index: ".$rihdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | ▶ | elsif ( not( $admref->{$rikey} and ($options{prepareRedirs} or (not exists $options{prepareRedirs})) ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$admref->{$rikey} && ($options{'prepareRedirs'} || !exists $options{'prepareRedirs'})
$options{"prepareRedirs"} or not exists $options{"prepareRedirs"}
MC/DC0%0/3
$admref->{$rikey} && ($options{'prepareRedirs'} || !exists $options{'prepareRedirs'})
$admref->{$rikey}
$options{"prepareRedirs"}
not exists $options{"prepareRedirs"}
Truth table0%0/4
A && B or not(C)
A= $admref->{$rikey}B= $options{"prepareRedirs"}C= not exists $options{"prepareRedirs"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | print "dropping redirection index\n" if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | $hdl->do("DROP INDEX IF EXISTS redir;") or croak("Setup error: ".$hdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | $rihdl->execute($rikey, 0) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | or croak("Could not execute fix redirection index: ".$rihdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | # $admref = $self->admhash(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 8 | ▶ | print "[ANALYZE ..." if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 8 | $hdl->do("ANALYZE;"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 8 | ▶ | print "]\n" if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 8 | return 1; # o.k. | |||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | =head3 deflate() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | Maintenance action: performs VACCUUM, REINDEX and ANALYZE on the database | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | sub deflate { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deflate: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 1 | ▶ | my $hdl = $self->{dbh} or croak("no handle?"); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 1 | local $hdl->{AutoCommit} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 1 | print "VACUUM\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 1 | ▶ | $hdl->do("VACUUM") or carp("could not VACUUM: Skipping..."); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 1 | print "REINDEX\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 1 | ▶ | $hdl->do("REINDEX") or croak("could not REINDEX: Abort"); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 1 | print "ANALYZE\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 1 | ▶ | $hdl->do("ANALYZE;") or croak("could not ANALYZE: Abort"); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | =head2 Handling of beacon files | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | =head3 loadFile ( $file, $fields, %options ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | Reads a physical beacon file and stores it with a new Sequence number in the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | database. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | Returns a triple: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | my ($seqno, $rec_ok, $message) = loadFile ( $file, $fields, %options ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | $seqno is undef on error | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | $seqno and $rec_ok are zero with $message containing an explanation in case | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | of no action taken. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | $seqno is an positive integer if something was loaded: The L<Sequence Number> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | (internal unique identifier) for the representation of the beacon file in | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | the database. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | =over 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | =item $file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | File to read: Must be a beacon file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | =item $fields | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | Hashref with additional meta and admin fields to store | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | =item Supported options: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | verbose => (0|1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | force => (0|1) process unconditionally without timestamp comparison | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | nostat => (0|1) don't refresh global identifier counters | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | If the file does not contain a minimal correct header (eg. is an empty file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | or an HTML error page accidentaly caught) no action is performed. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | Otherwise, a fresh SeqNo (sequence number) is generated and meta and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | BEACON-Lines are stored in the appropriate tables in the database. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | If the _alias field is provided, existing database entries for this | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | Alias are updated, identifiers not accounted for any more are | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | eventually discarded. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | sub loadFile { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 14 | ▶ | my ($self, $file, $fields, %options) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loadFile: called CC=130 SCAR=67.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 14 | ▶ | $options{'verbose'} = $self->{'verbose'} unless exists $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 14 | ▶ | $options{'verbose'} ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options{"verbose"} ||= 0
MC/DC100%1/1
$options{"verbose"} ||= 0
$options{"verbose"}
Truth table100%2/2
A
A= $options{"verbose"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 14 | ▶ | if ( ! $file ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | croak("Missing file argument")} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | elsif ( ! -e $file ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | print "ERROR: no such file $file\n" && return undef} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
"ERROR: no such file $file\n" && (return undef)
MC/DC0%0/1
"ERROR: no such file $file\n" && (return undef)
"ERROR: no such file $file\n"
Truth table0%0/2
A
A= "ERROR: no such file $file\n"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | elsif ( ! -r _ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | print "ERROR: no read permissions for $file\n" && return undef} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
"ERROR: no read permissions for $file\n" && (return undef)
MC/DC0%0/1
"ERROR: no read permissions for $file\n" && (return undef)
"ERROR: no read permissions for $file\n"
Truth table0%0/2
A
A= "ERROR: no read permissions for $file\n"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | elsif ( -z _ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | print "WARNING: empty file $file\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | return (0,0, "empty file: Will not process"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 14 | my $mtime = (stat(_))[9]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 14 | ▶ | open(BKN, "<:utf8", $file) or (print "ERROR: cannot read $file\n", return undef); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 14 | local($.) = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 14 | ▶ | unless ( defined $self->{identifierClass} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 14 | my $package = $self->autoIdentifier(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 14 | ▶ | $options{'verbose'} && ref($package) && print "Assuming identifiers of type ".ref($package)."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$options{"verbose"} and ref $package
MC/DC0%0/2
$options{"verbose"} and ref $package
$options{"verbose"}
ref $package
Truth table66%2/3
A and B
A= $options{"verbose"}B= ref $package
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 14 | ▶ | $fields = {} unless $fields; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 14 | ▶ | $fields->{'_ftime'} ||= time(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$fields->{"_ftime"} ||= time
MC/DC0%0/2
$fields->{"_ftime"} ||= time
$fields->{"_ftime"}
time
Truth table33%1/3
A ||= B
A= $fields->{"_ftime"}B= time
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 14 | ▶ | $fields->{'_mtime'} ||= $mtime; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$fields->{"_mtime"} ||= $mtime
MC/DC0%0/2
$fields->{"_mtime"} ||= $mtime
$fields->{"_mtime"}
$mtime
Truth table66%2/3
A ||= B
A= $fields->{"_mtime"}B= $mtime
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 14 | ▶ | delete $fields->{_uri} unless $fields->{_uri}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 14 | ▶ | delete $fields->{_alias} unless $fields->{_alias}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 14 | ▶ | my $autopurge = $fields->{_alias} || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$fields->{'_alias'} || ''
MC/DC0%0/1
$fields->{'_alias'} || ''
$fields->{'_alias'}
Truth table50%1/2
A
A= $fields->{'_alias'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 14 | ▶ | my $showme = $fields->{_alias} || $fields->{_uri} || $file; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$fields->{'_alias'} || $fields->{'_uri'} || $file
$fields->{"_alias"} or $fields->{"_uri"}
MC/DC0%0/3
$fields->{'_alias'} || $fields->{'_uri'} || $file
$fields->{"_alias"}
$fields->{"_uri"}
$file
Truth table25%1/4
A or B || C
A= $fields->{"_alias"}B= $fields->{"_uri"}C= $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 14 | ▶ | if ( $options{'verbose'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 9 | ▶ | printf("* Loading %s from URI %s\n", $fields->{_alias} || "<no alias>", $fields->{_uri} || "<direct file>"); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$fields->{'_alias'} || '<no alias>'
$fields->{'_uri'} || '<direct file>'
MC/DC0%0/1
$fields->{'_alias'} || '<no alias>'
$fields->{'_alias'}
MC/DC0%0/1
$fields->{'_uri'} || '<direct file>'
$fields->{'_uri'}
Truth table50%1/2
A
A= $fields->{'_alias'}
Truth table50%1/2
A
A= $fields->{'_uri'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 9 | printf("* local input %s (%s)\n", $file, SeeAlso::Source::BeaconAggregator::tToISO($mtime)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 14 | my ($collno, $inserthandle, $replacehandle, $err, $format); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 14 | my ($linecount, $headerseen, $oseq) = (0, 0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 14 | my ($reccount, $recill, $recign, $recnil, $recupd, $recnew, $recdupl, $recdel) = (0, 0, 0, 0, 0, 0, 0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 14 | local($_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | lines: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 14 | ▶ | while ( <BKN> ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 188 | s/[ \x0d\x0a]+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 188 | ▶ | unless ( $linecount++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 14 | ▶ | if ( s/^\x{FEFF}// ) { # BOM-Character | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | elsif ( s/^\xef\xbb\xbf// ) { # BOM-Bytes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | print "ERROR: cannot cope with doubly UTF-8 encoded $file\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | return (undef, undef, "encoding trouble")}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 14 | ▶ | if ( /^\s*$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | print "WARNING: Discarding blank line before beacon header [$showme l.$.]\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 188 | ▶ | if ( not defined $collno ) { # $collno used as flag: "still in header" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 103 | ▶ | if ( /^#\s*([A-Z][\w-]*):\s*(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 87 | $headerseen++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 87 | my ($field, $data) = ($1, $2); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 87 | ▶ | $field =~ s/^DATE$/TIMESTAMP/ && print "WARNING: corrected DATE to TIMESTAMP in Beacon-Header [$showme l.$.]\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 87 | $data =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 87 | ▶ | next if $data =~ /^\s*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 87 | ▶ | if ( SeeAlso::Source::BeaconAggregator->beaconfields($field) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 81 | ▶ | if ( $fields->{$field} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | print "WARNING: Skipping already set $field [$showme l.$.]\n"} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 81 | $fields->{$field} = $data} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 6 | print "WARNING: Ignoring unknown $field [$data] [$showme l.$.]\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | elsif ( /^(#[^:\s]+)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | print "WARNING: Discarding unparseable line >$1...< in beacon header context [$showme l.$.]\n"} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | elsif ( /^\s*$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 2 | ▶ | print "NOTICE: Discarding blank line in beacon header context [$showme l.$.]\n" if $options{'verbose'}} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | elsif ( ! $headerseen ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | print "ERROR: no header fields [$showme l.$.]\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | return (0, 0, "no header fields: Will not proceed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 14 | ($collno, $err, $format, $inserthandle, $replacehandle, $oseq) = $self->processbeaconheader($fields, %options); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 14 | ▶ | unless ( $collno ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | print "ERROR: metadata error [$showme l.$.]\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | return (0, 0, "metadata error: $err"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 14 | $self->{dbh}->{AutoCommit} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 14 | $linecount --; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 14 | redo lines; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 85 | s/^\s+//; s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 85 | my ($id, $altid, @rest); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 85 | ($id, @rest) = split(/\s*\|\s*/, $_, 4); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 85 | ▶ | ($id, $altid) = split(/\s*=\s*/, $id, 2) if $id; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 85 | ▶ | $id || ($recnil++, next); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 85 | ▶ | if ( $options{'filter'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 28 | ($id, $altid) = &{$options{'filter'}}($id, $altid, @rest); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 28 | ▶ | unless ( $id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 14 | $recign ++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 14 | ▶ | unless ( ++$reccount % 10000 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $self->{dbh}->{AutoCommit} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | print "$reccount\n" if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | $self->{dbh}->{AutoCommit} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 14 | next lines; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 71 | ▶ | $altid ||= ""; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$altid ||= ""
MC/DC100%1/1
$altid ||= ""
$altid
Truth table100%2/2
A
A= $altid
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 71 | my($hits, $info, $link); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 71 | ▶ | if ( @rest && ($rest[$#rest] =~ m!^\S+://\S+$!) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
@rest and $rest[$#rest] =~ m[^\S+://\S+$]
MC/DC100%2/2
@rest and $rest[$#rest] =~ m[^\S+://\S+$]
@rest
$rest[$#rest] =~ m[^\S+://\S+$]
Truth table100%3/3
A and B
A= @restB= $rest[$#rest] =~ m[^\S+://\S+$]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 27 | $link = pop @rest} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | elsif ( defined $rest[2] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | print "WARNING: unparseable link content >$rest[2]< [$showme l.$.]"}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 71 | ▶ | if ( @rest && ($rest[0] =~ /^\d*$/) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
@rest and $rest[0] =~ /^\d*$/
MC/DC100%2/2
@rest and $rest[0] =~ /^\d*$/
@rest
$rest[0] =~ /^\d*$/
Truth table100%3/3
A and B
A= @restB= $rest[0] =~ /^\d*$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 13 | $hits = shift @rest; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | # really disregard hits with explicit 0? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 13 | ▶ | if ( (!$altid) and (!$link) and ($format =~ /\baltTARGET\b/) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not $altid || $link and $format =~ /\baltTARGET\b/
$altid || $link
MC/DC66%2/3
not $altid || $link and $format =~ /\baltTARGET\b/
$altid
$link
$format =~ /\baltTARGET\b/
Truth table75%3/4
not(A || B) and C
A= $altidB= $linkC= $format =~ /\baltTARGET\b/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 2 | ▶ | $altid = shift @rest || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @rest || ''
MC/DC0%0/1
shift @rest || ''
shift @rest
Truth table50%1/2
A
A= shift @rest
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 11 | ▶ | $info = shift @rest || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift @rest || ''
MC/DC100%1/1
shift @rest || ''
shift @rest
Truth table100%2/2
A
A= shift @rest
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | elsif ( defined $rest[1] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 2 | $hits = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 2 | ▶ | if ( (!$altid) and (!$link) and ($format =~ /\baltTARGET\b/) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $altid || $link and $format =~ /\baltTARGET\b/
$altid || $link
MC/DC0%0/3
not $altid || $link and $format =~ /\baltTARGET\b/
$altid
$link
$format =~ /\baltTARGET\b/
Truth table25%1/4
not(A || B) and C
A= $altidB= $linkC= $format =~ /\baltTARGET\b/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 2 | $info = shift @rest; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 2 | $altid = shift @rest; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | shift @rest; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | $info = shift @rest; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | elsif ( defined $rest[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 45 | $hits = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 45 | $info = shift @rest; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 71 | ▶ | if ( @rest ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | print "WARNING: unparseable content >$_< [$showme l.$.]"}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 71 | ▶ | unless ( $link ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 44 | ▶ | if ( ($format =~ /\bhasTARGET\b/) ) { # ok | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | ▶ | elsif ( $altid && ($format =~ /\baltTARGET\b/) ) { # also ok | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$altid and $format =~ /\baltTARGET\b/
MC/DC0%0/2
$altid and $format =~ /\baltTARGET\b/
$altid
$format =~ /\baltTARGET\b/
Truth table33%1/3
A and B
A= $altidB= $format =~ /\baltTARGET\b/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | elsif ( $format =~ /\bnoTARGET\b/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | print "NOTICE: discarding >$id<".(defined $hits ? " ($hits)" : "")." without link [$showme l.$.]\n" if $options{'verbose'} > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $recill++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | next lines; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | print "WARNING: discarding >$id<".(defined $hits ? " ($hits)" : "")." without link [$showme l.$.] (assertion failed)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | $recill++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | next lines; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 71 | ▶ | if ( $format !~ /\baltTARGET\b/ ) { # Allow certain duplicates (force disambiguisation) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 4 | ▶ | $altid ||= $info || $link} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$altid ||= $info || $link
$info || $link
MC/DC0%0/3
$altid ||= $info || $link
$altid
$info
$link
Truth table0%0/4
A ||= B || C
A= $altidB= $infoC= $link
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 71 | ▶ | $hits = "" unless defined $hits; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 71 | ▶ | ($hits =~ /^0+/) && ($recnil++, next); # Explizit "0" => raus | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 71 | ▶ | $hits = 0 if $hits eq ""; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 71 | ▶ | $altid ||= ""; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$altid ||= ""
MC/DC100%1/1
$altid ||= ""
$altid
Truth table100%2/2
A
A= $altid
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 71 | my $hash; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 71 | ▶ | if ( defined $self->{identifierClass} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | $self->{identifierClass}->value($id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | ▶ | unless ( $self->{identifierClass}->valid ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | print "NOTICE: invalid identifier >$id< ($hits) [$showme l.$.]\n" if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | $recill++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | next lines; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | $hash = $self->{identifierClass}->hash(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 71 | $hash = $id}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 71 | my $did; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 71 | ▶ | if ( $replacehandle && ($did = $replacehandle->execute($hits, $info, $link, $hash, $altid)) ) { # UPDATE OR FAIL old record | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
$replacehandle and $did = $replacehandle->execute($hits, $info, $link, $hash, $altid)
MC/DC50%1/2
$replacehandle and $did = $replacehandle->execute($hits, $info, $link, $hash, $altid)
$replacehandle
$did = $replacehandle->execute($hits, $info, $link, $hash, $altid)
Truth table66%2/3
A and B
A= $replacehandleB= $did = $replacehandle->execute($hits, $info, $link, $hash, $altid)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 40 | ▶ | if ( $replacehandle->err ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | carp("update in trouble: $replacehandle->errstring [$showme l.$.]"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | $recdupl++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | elsif ( $did eq "0E0" ) { # not found, try insert | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 28 | $did = $inserthandle->execute($hash, $altid, $hits, $info, $link); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 28 | ▶ | if ( $did eq "0E0" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 10 | $recdupl++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 10 | ▶ | if ( $altid ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | ▶ | print "INFO: did not insert duplicate Id >$id< = >$altid< ($hits) [$showme l.$.]\n" if $options{'verbose'}} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 10 | ▶ | print "INFO: did not insert duplicate Id >$id< ($hits) [$showme l.$.]\n" if $options{'verbose'} > 1}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 18 | $recnew++}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 12 | $recupd++}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | elsif ( $did = $inserthandle->execute($hash, $altid, $hits, $info, $link) ) { # INSERT OR IGNORE new record | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 31 | ▶ | if ( $did eq "0E0" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 9 | $recdupl++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 9 | ▶ | print "INFO: did not insert duplicate Id $id ($hits) [$showme l.$.]\n" if $options{'verbose'} > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 22 | $recnew++}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | elsif ( $inserthandle->errstr =~ /constraint/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | $recdupl++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | print "INFO: duplicate Id $id ($hits): not inserting [$showme l.$.]\n" if $options{'verbose'} > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | croak("Could not insert: ($id, $hits, $info, $link): ".$inserthandle->errstr)}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 71 | ▶ | unless ( ++$reccount % 10000 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | $self->{dbh}->{AutoCommit} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | ▶ | print "$reccount\n" if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | $self->{dbh}->{AutoCommit} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 14 | ▶ | if ( not defined $collno ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | ▶ | if ( $headerseen ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ($collno, $err, $format, $inserthandle, $replacehandle, $oseq) = $self->processbeaconheader($fields, %options); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | if ( $collno ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | print "WARNING: no idn content in file [$showme l.$.]\n"} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | print "ERROR: metadata error [$showme l.$.]\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | return (0,0, "metadata error: $err"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | elsif ( $. ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | print "ERROR: no header fields [$showme l.$.]\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | return (0, 0, "no header fields: Will not proceed"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | print "WARNING: empty file [$showme]\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | return (0,0, "empty file"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 14 | $self->{dbh}->{AutoCommit} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 14 | ▶ | if ( $autopurge ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 14 | $self->{dbh}->{AutoCommit} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 14 | ▶ | if ( $oseq ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 8 | my ($bcdelh, $bcdelexpl) = $self->stmtHdl("DELETE FROM beacons WHERE seqno==?"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 8 | ▶ | $self->stmtExplain($bcdelexpl, $oseq) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 8 | ▶ | my $rows = $bcdelh->execute($oseq) or croak("Could not execute >".$bcdelh->{Statement}."<: ".$bcdelh->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 8 | $self->{dbh}->{AutoCommit} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 8 | ▶ | printf("INFO: Purged %s surplus identifiers from old sequence %u\n", $rows, $oseq) if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 8 | ▶ | $rows = "0" if $rows eq "0E0"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 8 | $recdel += $rows; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 14 | $self->{dbh}->{AutoCommit} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 14 | my ($rpdelh, $rpdelexpl) = $self->stmtHdl("DELETE FROM repos WHERE (alias=?) AND (seqno<?);"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 14 | ▶ | $self->stmtExplain($rpdelexpl, $autopurge, $collno) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 14 | ▶ | my $rows = $rpdelh->execute($autopurge, $collno) or croak("Could not execute >".$rpdelh->{Statement}."<: ".$rpdelh->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 14 | $self->{dbh}->{AutoCommit} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 14 | ▶ | $rows = "0" if $rows eq "0E0"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 14 | ▶ | printf("INFO: %u old sequences discarded\n", $rows) if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 14 | ▶ | printf "NOTICE: New sequence %u for %s: processed %u Records from %u lines\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$autopurge || '???'
MC/DC0%0/1
$autopurge || '???'
$autopurge
Truth table50%1/2
A
A= $autopurge
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | $collno, $autopurge || "???", $reccount, $linecount; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 14 | my $statline = sprintf "%u replaced, %u new, %u deleted, %u duplicate, %u nil, %u invalid, %u ignored", | |||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | $recupd, $recnew, $recdel, $recdupl, $recnil, $recill, $recign; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 14 | print " ($statline)\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 14 | my $recok = $recupd + $recnew; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 14 | ▶ | my $numchg = ($recnew or $recdel) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$recnew or $recdel
MC/DC100%2/2
$recnew or $recdel
$recnew
$recdel
Truth table100%3/3
A or B
A= $recnewB= $recdel
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | # my $ct1hdl = $self->stmtHdl("SELECT COUNT(*) FROM beacons WHERE seqno==? LIMIT 1;"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | # $ct1hdl->execute($collno) or croak("could not execute live count: ".$ct1hdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | # my $ct1ref = $ct1hdl->fetchrow_arrayref(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | # my $counti = $ct1ref->[0] || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | # my $ct2hdl = $self->stmtHdl("SELECT COUNT(DISTINCT hash) FROM beacons WHERE seqno==?"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | # using subquery to trick SQLite into using indices | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | # my $ct2hdl = $self->stmtHdl("SELECT COUNT(*) FROM (SELECT DISTINCT hash FROM beacons WHERE seqno==?) LIMIT 1;"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | # $ct2hdl->execute($collno) or croak("could not execute live count: ".$ct2hdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | # my $ct2ref = $ct2hdl->fetchrow_arrayref(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | # my $countu = $ct2ref->[0] || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | # combined query turned out as not as efficient | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | # my $ct0hdl = $self->stmtHdl("SELECT COUNT(*), COUNT(DISTINCT hash) FROM beacons WHERE seqno==? LIMIT 1;"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | # $ct0hdl->execute($collno) or croak("could not execute live count: ".$ct0hdl->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | # my $ct0ref = $ct0hdl->fetchrow_arrayref(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | # my ($counti, $countu) = ($ct0ref->[0] || 0, $ct0ref->[1] || 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 14 | my ($updh, $updexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | UPDATE OR FAIL repos SET counti=?,countu=?,fstat=?,utime=?,ustat=?,sort=? WHERE seqno==?; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 14 | ▶ | my $counti = $self->idStat($collno, 'distinct' => 0) || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->idStat($collno, 'distinct', 0) || 0
MC/DC0%0/1
$self->idStat($collno, 'distinct', 0) || 0
$self->idStat($collno, 'distinct', 0)
Truth table50%1/2
A
A= $self->idStat($collno, 'distinct', 0)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 14 | ▶ | printf("WARNING: expected %u valid records, counted %u\n", $recok, $counti) if $recok != $counti; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 14 | ▶ | unless ( $numchg ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 2 | ▶ | $fields->{'_counti'} ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$fields->{"_counti"} ||= 0
MC/DC0%0/1
$fields->{"_counti"} ||= 0
$fields->{"_counti"}
Truth table50%1/2
A
A= $fields->{"_counti"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 2 | ▶ | printf("WARNING: expected unchanged number %u valid records, counted %u\n", $fields->{'_counti'}, $counti) if $fields->{'_counti'} != $counti; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 14 | ▶ | my $sort = $fields->{'_sort'} || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$fields->{'_sort'} || ''
MC/DC0%0/1
$fields->{'_sort'} || ''
$fields->{'_sort'}
Truth table50%1/2
A
A= $fields->{'_sort'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | my $countu = $numchg ? ( $self->idStat($collno, 'distinct' => 1) || 0 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 14 | ▶ | : ( $fields->{'_countu'} || $self->idStat($collno, 'distinct' => 1) || 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition42%3/7
$self->idStat($collno, "distinct", 1) or 0
$fields->{"_countu"} or $self->idStat($collno, "distinct", 1) or 0
$fields->{"_countu"} or $self->idStat($collno, "distinct", 1)
MC/DC0%0/1
$self->idStat($collno, "distinct", 1) or 0
$self->idStat($collno, "distinct", 1)
MC/DC0%0/2
$fields->{"_countu"} or $self->idStat($collno, "distinct", 1) or 0
$fields->{"_countu"}
$self->idStat($collno, "distinct", 1)
Truth table50%1/2
A
A= $self->idStat($collno, "distinct", 1)
Truth table33%1/3
A or B
A= $fields->{"_countu"}B= $self->idStat($collno, "distinct", 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 14 | ▶ | $self->stmtExplain($updexpl, $counti, $countu, $statline, time(), "successfully loaded", $sort, $collno) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | $updh->execute($counti, $countu, $statline, time(), "successfully loaded", $sort, $collno) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 14 | ▶ | or croak("Could not execute >".$updh->{Statement}."<: ".$updh->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 14 | close(BKN); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 14 | ▶ | if ( $numchg or $options{'force'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$numchg or $options{"force"}
MC/DC0%0/2
$numchg or $options{"force"}
$numchg
$options{"force"}
Truth table66%2/3
A or B
A= $numchgB= $options{"force"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | # if ( $options{'force'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | # print "[ANALYZE ..." if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | # $self->{dbh}->do("ANALYZE;"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | # print "]\n" if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | # }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 14 | ▶ | if ( $options{'nostat'} ) { # invalidate since they might have changed | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | $self->admin('gcounti', undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | $self->admin('gcountu', undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 14 | ▶ | $self->admin('gcounti', $self->idStat(undef, 'distinct' => 0) || 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->idStat(undef, 'distinct', 0) || 0
MC/DC0%0/1
$self->idStat(undef, 'distinct', 0) || 0
$self->idStat(undef, 'distinct', 0)
Truth table50%1/2
A
A= $self->idStat(undef, 'distinct', 0)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 14 | ▶ | $self->admin('gcountu', $self->idStat(undef, 'distinct' => 1) || 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->idStat(undef, 'distinct', 1) || 0
MC/DC0%0/1
$self->idStat(undef, 'distinct', 1) || 0
$self->idStat(undef, 'distinct', 1)
Truth table50%1/2
A
A= $self->idStat(undef, 'distinct', 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 14 | return ($collno, $recok, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | =head4 processbeaconheader($self, $fieldref, [ %options] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | Internal subroutine used by C<loadFile()>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | =over 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | =item $fieldref | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | Hash with raw fields. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | =item Supported options: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | verbose => (0|1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | Show seqnos of old instances which are met by the alias | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | sub processbeaconheader { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 14 | ▶ | my ($self, $fieldref, %options) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
processbeaconheader: called CC=76 SCAR=60.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 14 | my $osq = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 14 | my @carp; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 14 | ▶ | if ( my $alias = $fieldref->{_alias} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 14 | my $stampfield = SeeAlso::Source::BeaconAggregator->beaconfields("TIMESTAMP"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 14 | my ($listh, $listexpl) = $self->stmtHdl("SELECT seqno, $stampfield, mtime, counti, countu FROM repos WHERE alias=?;"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 14 | ▶ | $self->stmtExplain($listexpl, $alias) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 14 | ▶ | $listh->execute($alias) or croak("Could not execute >".$listh->{Statement}."<: ".$listh->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 14 | my ($rowcnt, $ocounti, $ocountu); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 14 | ▶ | while ( my($row) = $listh->fetchrow_arrayref ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 22 | ▶ | last unless defined $row; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 8 | $rowcnt ++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 8 | ($ocounti, $ocountu) = ($row->[3], $row->[4]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 8 | ▶ | if ( $options{'verbose'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 4 | ▶ | print "* Old Instances for $alias:\n" unless $osq; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 4 | $osq = $row->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 4 | ▶ | print "+\t#$osq ", SeeAlso::Source::BeaconAggregator::tToISO($row->[1] || $row->[2]), " (", $row->[3] || "???", ")\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
$row->[1] || $row->[2]
$row->[3] || '???'
MC/DC0%0/2
$row->[1] || $row->[2]
$row->[1]
$row->[2]
MC/DC0%0/1
$row->[3] || '???'
$row->[3]
Truth table66%2/3
A || B
A= $row->[1]B= $row->[2]
Truth table50%1/2
A
A= $row->[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 4 | $osq = $row->[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 14 | ▶ | if ( $rowcnt && ($rowcnt == 1) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$rowcnt and $rowcnt == 1
MC/DC50%1/2
$rowcnt and $rowcnt == 1
$rowcnt
$rowcnt == 1
Truth table66%2/3
A and B
A= $rowcntB= $rowcnt == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 8 | ▶ | $fieldref->{_counti} ||= $ocounti if $ocounti; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$fieldref->{"_counti"} ||= $ocounti
MC/DC0%0/2
$fieldref->{"_counti"} ||= $ocounti
$fieldref->{"_counti"}
$ocounti
Truth table33%1/3
A ||= B
A= $fieldref->{"_counti"}B= $ocounti
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 8 | ▶ | $fieldref->{_countu} ||= $ocountu if $ocountu; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$fieldref->{"_countu"} ||= $ocountu
MC/DC0%0/2
$fieldref->{"_countu"} ||= $ocountu
$fieldref->{"_countu"}
$ocountu
Truth table33%1/3
A ||= B
A= $fieldref->{"_countu"}B= $ocountu
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 14 | my $format = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 14 | ▶ | if ( $fieldref->{'FORMAT'} && $self->{accept}->{'FORMAT'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition100%3/3
$fieldref->{"FORMAT"} and $self->{"accept"}{"FORMAT"}
MC/DC100%2/2
$fieldref->{"FORMAT"} and $self->{"accept"}{"FORMAT"}
$fieldref->{"FORMAT"}
$self->{"accept"}{"FORMAT"}
Truth table100%3/3
A and B
A= $fieldref->{"FORMAT"}B= $self->{"accept"}{"FORMAT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 4 | ▶ | if ( $fieldref->{'FORMAT'} =~ $self->{accept}->{'FORMAT'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 4 | $format = $fieldref->{'FORMAT'}} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | push(@carp, "ERROR: only FORMAT '".$self->{accept}->{'FORMAT'}."' are supported, this is ".$fieldref->{'FORMAT'})} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | elsif ( $fieldref->{'FORMAT'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 8 | $format = $fieldref->{'FORMAT'}} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | ▶ | elsif ( $fieldref->{'VERSION'} or $fieldref->{'TARGET'} or $fieldref->{'PREFIX'} or $fieldref->{'MESSAGE'} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%3/9
$fieldref->{"VERSION"} or $fieldref->{"TARGET"} or $fieldref->{"PREFIX"} or $fieldref->{"MESSAGE"}
$fieldref->{"VERSION"} or $fieldref->{"TARGET"} or $fieldref->{"PREFIX"}
$fieldref->{"VERSION"} or $fieldref->{"TARGET"}
MC/DC0%0/4
$fieldref->{"VERSION"} or $fieldref->{"TARGET"} or $fieldref->{"PREFIX"} or $fieldref->{"MESSAGE"}
$fieldref->{"VERSION"}
$fieldref->{"TARGET"}
$fieldref->{"PREFIX"}
$fieldref->{"MESSAGE"}
Truth table20%1/5
A or B or C or D
A= $fieldref->{"VERSION"}B= $fieldref->{"TARGET"}C= $fieldref->{"PREFIX"}D= $fieldref->{"MESSAGE"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 2 | push(@carp, "WARNING: header line #FORMAT: BEACON should be supplied")} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | elsif ( $self->{accept}->{'FORMAT'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | push(@carp, "ERROR: header line #FORMAT is missing")} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | push(@carp, "WARNING: header line #FORMAT: BEACON should be supplied")}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 14 | ▶ | if ( $fieldref->{'FORMAT'} && ($fieldref->{'FORMAT'} =~ /v(?:ersion)?\s*(\d+(?:\.\d*)?)/i) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$fieldref->{"FORMAT"} and $fieldref->{"FORMAT"} =~ /v(?:ersion)?\s*(\d+(?:\.\d*)?)/i
MC/DC0%0/2
$fieldref->{"FORMAT"} and $fieldref->{"FORMAT"} =~ /v(?:ersion)?\s*(\d+(?:\.\d*)?)/i
$fieldref->{"FORMAT"}
$fieldref->{"FORMAT"} =~ /v(?:ersion)?\s*(\d+(?:\.\d*)?)/i
Truth table66%2/3
A and B
A= $fieldref->{"FORMAT"}B= $fieldref->{"FORMAT"} =~ /v(?:ersion)?\s*(\d+(?:\.\d*)?)/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | ▶ | $fieldref->{'VERSION'} ||= $1}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fieldref->{"VERSION"} ||= $1
MC/DC0%0/2
$fieldref->{"VERSION"} ||= $1
$fieldref->{"VERSION"}
$1
Truth table0%0/3
A ||= B
A= $fieldref->{"VERSION"}B= $1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 14 | ▶ | unless ( $fieldref->{'VERSION'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 3 | ▶ | $fieldref->{'VERSION'} = $fieldref->{'FORMAT'} ? "0.1" : "1.0"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 3 | push(@carp, "NOTICE: added header field #VERSION as '".$fieldref->{'VERSION'}."'"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 14 | ▶ | if ( $self->{accept}->{'VERSION'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | ($fieldref->{'VERSION'} =~ $self->{accept}->{'VERSION'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 5 | ▶ | || push(@carp, "ERROR: only VERSION '".$self->{accept}->{'VERSION'}."' is supported, this is ".$fieldref->{'VERSION'}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 14 | ▶ | if ( $fieldref->{'ALTTARGET'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 11 | ▶ | $fieldref->{'ALTTARGET'} = "" unless defined $fieldref->{'ALTTARGET'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 11 | my $parsed = hDecode($fieldref, 'ALTTARGET'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 11 | ▶ | if ( $parsed && ($parsed =~ /(^|[^%])(%.)*%\d\$s/) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$parsed and $parsed =~ /(^|[^%])(%.)*%\d\$s/
MC/DC0%0/2
$parsed and $parsed =~ /(^|[^%])(%.)*%\d\$s/
$parsed
$parsed =~ /(^|[^%])(%.)*%\d\$s/
Truth table33%1/3
A and B
A= $parsedB= $parsed =~ /(^|[^%])(%.)*%\d\$s/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 11 | $fieldref->{'ALTTARGET'} = $parsed; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 11 | $format =~ s/\s*-altTARGET//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 11 | $format .= " -altTARGET"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 11 | ▶ | ($parsed =~ /(^|[^%])(%.)*%2\$s/) or | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | push(@carp, "WARNING: header field #ALTTARGET should contain placeholder {ALTID}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | elsif ( $parsed ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | push(@carp, "ERROR: header field #ALTTARGET must contain placeholder {ALTID} (or {ID})"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | delete $fieldref->{'ALTTARGET'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | push(@carp, "ERROR: could not parse header field #ALTTARGET: '".$fieldref->{'ALTTARGET'}."'"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | delete $fieldref->{'ALTTARGET'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 14 | ▶ | if ( $fieldref->{'IMGTARGET'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | ▶ | $fieldref->{'IMGTARGET'} = "" unless defined $fieldref->{'IMGTARGET'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | my $parsed = hDecode($fieldref, 'IMGTARGET'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | ▶ | if ( $parsed && ($parsed =~ /(^|[^%])(%.)*%\d\$s/) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$parsed and $parsed =~ /(^|[^%])(%.)*%\d\$s/
MC/DC0%0/2
$parsed and $parsed =~ /(^|[^%])(%.)*%\d\$s/
$parsed
$parsed =~ /(^|[^%])(%.)*%\d\$s/
Truth table0%0/3
A and B
A= $parsedB= $parsed =~ /(^|[^%])(%.)*%\d\$s/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | $fieldref->{'IMGTARGET'} = $parsed; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | $format =~ s/\s*-imgTARGET//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | $format .= " -imgTARGET"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | elsif ( $parsed ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | push(@carp, "WARNING: header field #IMGTARGET should contain placeholders {ID} or {ALTID}")} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | push(@carp, "ERROR: could not parse header field #IMGTARGET: '".$fieldref->{'IMGTARGET'}."'"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | delete $fieldref->{'IMGTARGET'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 14 | ▶ | if ( exists $fieldref->{'TARGET'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 14 | ▶ | $fieldref->{'TARGET'} = "" unless defined $fieldref->{'TARGET'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 14 | my $parsed = hDecode($fieldref, 'TARGET'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 14 | ▶ | if ( $parsed && ($parsed =~ /(^|[^%])(%.)*%1\$s/) && ($parsed !~ /(^|[^%])(%.)*%[2-9]\$s/) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
$parsed and $parsed =~ /(^|[^%])(%.)*%1\$s/ and not $parsed =~ /(^|[^%])(%.)*%[2-9]\$s/
$parsed and $parsed =~ /(^|[^%])(%.)*%1\$s/
MC/DC33%1/3
$parsed and $parsed =~ /(^|[^%])(%.)*%1\$s/ and not $parsed =~ /(^|[^%])(%.)*%[2-9]\$s/
$parsed
$parsed =~ /(^|[^%])(%.)*%1\$s/
not $parsed =~ /(^|[^%])(%.)*%[2-9]\$s/
Truth table50%2/4
A and B and not(C)
A= $parsedB= $parsed =~ /(^|[^%])(%.)*%1\$s/C= not $parsed =~ /(^|[^%])(%.)*%[2-9]\$s/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 12 | $fieldref->{'TARGET'} = $parsed; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 12 | $format .= " -hasTARGET"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | elsif ( $parsed ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 2 | ▶ | if ( exists $fieldref->{'ALTTARGET'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | push(@carp, "ERROR: header field #TARGET must contain placeholder {ID} only"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 2 | push(@carp, "WARNING: Adding implicit {ID} to #TARGET as #ALTTARGET"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 2 | $fieldref->{'ALTTARGET'} = $parsed."%2\$s"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 2 | $format .= " -altTARGET"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 2 | delete $fieldref->{'TARGET'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | push(@carp, "ERROR: could not parse header field #TARGET: '".$fieldref->{'TARGET'}."'"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | delete $fieldref->{'TARGET'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | elsif ( $format =~ /^BEACON/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | push(@carp, "WARNING: header field #TARGET not set: ALL beacon lines will have to provide their link by other means!"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | $format =~ s/\s*-noTARGET//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | $format .= " -noTARGET"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | push(@carp, "ERROR: header field #TARGET is mandatory")}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 14 | ▶ | $fieldref->{'MESSAGE'} = hDecode($fieldref, 'MESSAGE') if $fieldref->{'MESSAGE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 14 | ▶ | if ( $fieldref->{'TIMESTAMP'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 2 | ▶ | if ( my $parsed = hDecode($fieldref, 'TIMESTAMP') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 2 | ▶ | printf("* %-30s %s\n", "Beacon Timestamp:", hEncode($parsed, 'TIMESTAMP')) if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 2 | $fieldref->{'TIMESTAMP'} = $parsed; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | else { # unparseable => use current | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | push(@carp, "WARNING: cannot parse TIMESTAMP '".$fieldref->{'TIMESTAMP'}."', using current time"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | $fieldref->{'TIMESTAMP'} = $^T; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | # $fieldref->{'TIMESTAMP'} = $fieldref->{'_mtime'} || $^T; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 12 | push(@carp, "NOTICE: no header field #TIMESTAMP detected"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 14 | ▶ | if ( $fieldref->{'REVISIT'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | ▶ | if ( my $parsed = hDecode($fieldref, 'REVISIT') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | ▶ | if ( $parsed < $^T ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | printf("* %-30s %s [%s]\n", "STALE Revisit hint parsed as", hEncode($parsed, 'REVISIT'), $fieldref->{'REVISIT'})} # if $options{'verbose'} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | ▶ | printf("* %-30s %s\n", "Revisit hint parsed as", hEncode($parsed, 'REVISIT')) if $options{'verbose'}}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | $fieldref->{'REVISIT'} = $parsed; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | else { # unparseable => discard | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | push(@carp, "WARNING: cannot parse #REVISIT '".$fieldref->{'REVISIT'}."', discarding"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | delete $fieldref->{'REVISIT'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 14 | push(@carp, "INFO: no header field #REVISIT detected"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 14 | my $cancontinue = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 14 | my $err = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 14 | foreach ( @carp ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 33 | print "$_\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 33 | ▶ | if ( s/^ERROR: // ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | $cancontinue = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | ▶ | $err .= " | " if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | $err .= $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 14 | ▶ | unless ( $cancontinue or $options{'ignore-header-errors'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$cancontinue or $options{"ignore-header-errors"}
MC/DC0%0/2
$cancontinue or $options{"ignore-header-errors"}
$cancontinue
$options{"ignore-header-errors"}
Truth table33%1/3
A or B
A= $cancontinueB= $options{"ignore-header-errors"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | print "CRITICAL: Aborting because of Header Errors\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | return (undef, $err, $format); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 14 | ▶ | $fieldref->{'_uri'} ||= $fieldref->{'FEED'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$fieldref->{"_uri"} ||= $fieldref->{"FEED"}
MC/DC50%1/2
$fieldref->{"_uri"} ||= $fieldref->{"FEED"}
$fieldref->{"_uri"}
$fieldref->{"FEED"}
Truth table66%2/3
A ||= B
A= $fieldref->{"_uri"}B= $fieldref->{"FEED"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 14 | ▶ | delete $fieldref->{'_uri'} unless $fieldref->{'_uri'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 14 | ▶ | $fieldref->{'_alias'} ||= $fieldref->{'FEED'} || $fieldref->{'TARGET'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition16%1/6
$fieldref->{"_alias"} ||= $fieldref->{"FEED"} || $fieldref->{"TARGET"}
$fieldref->{'FEED'} || $fieldref->{'TARGET'}
MC/DC0%0/3
$fieldref->{"_alias"} ||= $fieldref->{"FEED"} || $fieldref->{"TARGET"}
$fieldref->{"_alias"}
$fieldref->{'FEED'}
$fieldref->{'TARGET'}
Truth table0%0/4
A ||= B || C
A= $fieldref->{"_alias"}B= $fieldref->{'FEED'}C= $fieldref->{'TARGET'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 14 | my (@fn, @fd); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 14 | ▶ | while ( my ($key, $val) = each %$fieldref ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 175 | ▶ | next unless defined $val; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 171 | my $dbkey = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 171 | ▶ | if ( $dbkey = SeeAlso::Source::BeaconAggregator->beaconfields($key) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 84 | push(@fn, $dbkey)} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | elsif ( $key =~ /_(\w+)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 87 | push(@fn, $1)} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | next}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 171 | my $myval = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 171 | ▶ | unless ( $myval =~ /^\d+$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 129 | $myval =~ s/'/''/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 129 | $myval = "'".$myval."'"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 171 | push(@fd, $myval); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 14 | local($") = ",\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 14 | my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | INSERT INTO repos ( seqno, @fn ) VALUES ( NULL, @fd ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 14 | ▶ | $self->stmtExplain($sthexpl) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 14 | ▶ | $sth->execute() or croak("Could not execute >".$sth->{Statement}."<:".$sth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 14 | my $collno = $self->{dbh}->last_insert_id("", "", "", ""); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 14 | my $rhandle; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 14 | ▶ | if ( $osq ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 8 | $rhandle = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | UPDATE OR FAIL beacons SET seqno=$collno, hits=?, info=?, link=? WHERE hash=? AND seqno==$osq AND altid=?; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 14 | my $ihandle = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | INSERT OR IGNORE INTO beacons ( hash, seqno, altid, hits, info, link ) VALUES (?, $collno, ?, ?, ?, ?); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 14 | return ($collno, "", $format, $ihandle, $rhandle, $osq); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 37 | my ($lwpcarp817, $lwpcarp827); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | =head3 update ($sq_or_alias, $params, %options) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | Loads a beacon file into the database, possibly replacing a previous instance. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | Some magic is employed to autoconvert ISO-8859-1 or doubly UTF-8 encoded files | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | back to UTF-8. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | Returns undef, if something goes wrong, or the file was not modified since, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | otherwise returns a pair (new seqence number, number of lines imported). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | =over 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | =item $sq_or_alias | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | Sequence number or alias: Used to determine an existing instance. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | =item $params | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | Hashref, containing | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | agent => LWP::UserAgent to use | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | _uri => Feed URL to load from | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | =item %options | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | Hash, propagated to C<loadFile()> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | verbose => (0|1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | force => (0|1) process unconditionally without timestamp comparison | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | nostat => (0|1) don't refresh global identifier counters | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | Incorporates a new beacon source from a URI in the database or updates an existing one. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | For HTTP URIs care is taken not to reload an unmodified BEACON feed (unless the 'force' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | option is provided). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | If the feed appears to be newer than the previously loaded version it is fetched, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | some UTF-8 adjustments are performed if necessary, then it is stored to a temporary file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | and from there finally processed by the C<loadFile()> method above. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | The URI to load is determined by the following order of precedence: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | =over 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | =item 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | _uri Option | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | =item 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | admin field uri stored in the database | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | =item 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | meta field #FEED taken from the database | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | Typical use is with an alias, not with a sequence number: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | $db->update('whatever'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | Can be used to initially load beacon files from URIs: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | $db->update("new_alias", {_uri => $file_uri} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | sub update { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 13 | ▶ | my ($self, $sq_or_alias, $params, %options) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: called CC=67 SCAR=60.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 13 | ▶ | $params = {} unless $params; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 13 | ▶ | $options{'verbose'} = $self->{'verbose'} unless exists $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 13 | my $ua = $params->{'agent'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 13 | ▶ | unless ( $ua ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 13 | require LWP::UserAgent; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 13 | ▶ | $ua = LWP::UserAgent->new(agent => "SA-S-BeaconAggregator ", # end with space to get default agent appended | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | env_proxy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | timeout => 300, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | ) or croak("cannot create UserAgent"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 13 | my ($cond, @cval) = SeeAlso::Source::BeaconAggregator::mkConstraint($sq_or_alias); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 13 | ▶ | my $alias = ($sq_or_alias =~ /^\d+$/) ? "" : $sq_or_alias; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 13 | my $feedname = SeeAlso::Source::BeaconAggregator->beaconfields("FEED"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 13 | my ($ssth, $ssthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | SELECT seqno, uri, alias, $feedname, ftime, mtime, sort FROM repos $cond; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 13 | ▶ | $self->stmtExplain($ssthexpl, @cval) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 13 | ▶ | $ssth->execute(@cval) or croak("Could not execute >".$ssth->{Statement}."<: ".$ssth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 13 | ▶ | croak("Select old instance error: ".$ssth->errstr) if $ssth->err; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 13 | my $aryref = $ssth->fetchrow_arrayref; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 13 | ▶ | my ($osq, $ouri, $oalias, $feed, $fetchtime, $modtime, $osort) = $aryref ? @$aryref : (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 13 | ▶ | my $uri = $params->{'_uri'} || $ouri || $feed; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$params->{'_uri'} || $ouri || $feed
$params->{"_uri"} or $ouri
MC/DC0%0/3
$params->{'_uri'} || $ouri || $feed
$params->{"_uri"}
$ouri
$feed
Truth table50%2/4
A or B || C
A= $params->{"_uri"}B= $ouriC= $feed
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 13 | ▶ | croak("Cannot update $sq_or_alias: URI not given nor determinable from previous content") unless $uri; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 13 | $uri =~ s/\s$//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 13 | ▶ | $alias ||= $oalias || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
$alias ||= $oalias || ""
$oalias || ''
MC/DC0%0/2
$alias ||= $oalias || ""
$alias
$oalias
Truth table66%2/3
A ||= B
A= $aliasB= $oalias
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 13 | ▶ | print "Requesting $uri\n" if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 13 | ▶ | my $rq = HTTP::Request->new('GET', $uri, ['Accept' => 'text/*']) or croak("could not construct request from $uri"); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 13 | ▶ | if ( $fetchtime && $modtime && !$options{'force'} ) { # allow force-reload by deleting _ftime or _mtime | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$fetchtime and $modtime and not $options{"force"}
$fetchtime and $modtime
MC/DC100%3/3
$fetchtime and $modtime and not $options{"force"}
$fetchtime
$modtime
not $options{"force"}
Truth table100%4/4
A and B and not(C)
A= $fetchtimeB= $modtimeC= not $options{"force"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 1 | ▶ | printf(" %-30s %s\n", "Old instance stamped", scalar localtime($modtime)) if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 1 | $rq->header('If-Modified-Since', HTTP::Date::time2str($modtime)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 13 | ▶ | if ( $rq->can("accept_decodable") ) { # LWP 5.817 and newer | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 13 | $rq->accept_decodable} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 0 | ▶ | carp("please upgrade to LWP >= 5.817 for compression negotiation") if $options{'verbose'} && (!$lwpcarp817++)}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$options{"verbose"} and not $lwpcarp817++
MC/DC0%0/2
$options{"verbose"} and not $lwpcarp817++
$options{"verbose"}
not $lwpcarp817++
Truth table0%0/3
A and not(B)
A= $options{"verbose"}B= not $lwpcarp817++
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 13 | my $response = $ua->request($rq); # Well, we hoggishly slurp everything into memory, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | # however explicit decompression of an already dumped result would be PITA | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 13 | my $nuri = ($response->request)->uri; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 13 | ▶ | print "NOTICE: Differing result URI: $nuri\n" if $uri ne $nuri; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | 13 | ▶ | if ( $response->is_success ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 12 | ▶ | print $osq ? "INFO: refreshing $alias sq $osq from $uri\n" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | : "INFO: importing previously unseen $alias from $uri\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 12 | my $charset; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 12 | ▶ | if ( $response->can("content_charset") ) { # LWP 5.827 and above | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 12 | $charset = $response->content_charset; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 12 | ▶ | print "DEBUG: Content charset is $charset\n" if $charset && $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$charset and $options{"verbose"}
MC/DC50%1/2
$charset and $options{"verbose"}
$charset
$options{"verbose"}
Truth table66%2/3
A and B
A= $charsetB= $options{"verbose"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | ▶ | carp("please upgrade to LWP >= 5.827 for better detection of content_charset") if $options{'verbose'} && (!$lwpcarp827++)}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$options{"verbose"} and not $lwpcarp827++
MC/DC0%0/2
$options{"verbose"} and not $lwpcarp827++
$options{"verbose"}
not $lwpcarp827++
Truth table0%0/3
A and not(B)
A= $options{"verbose"}B= not $lwpcarp827++
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 12 | ▶ | $charset ||= "UTF-8"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$charset ||= "UTF-8"
MC/DC0%0/1
$charset ||= "UTF-8"
$charset
Truth table50%1/2
A
A= $charset
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 12 | my $lm = $response->last_modified; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 12 | ▶ | printf(" %-30s %s\n", "Last modified", scalar localtime($lm)) if $lm && $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$lm and $options{"verbose"}
MC/DC50%1/2
$lm and $options{"verbose"}
$lm
$options{"verbose"}
Truth table66%2/3
A and B
A= $lmB= $options{"verbose"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 12 | ▶ | $lm ||= $^T; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$lm ||= $^T
MC/DC0%0/2
$lm ||= $^T
$lm
$^T
Truth table33%1/3
A ||= B
A= $lmB= $^T
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 12 | my $vt = $response->fresh_until(h_min => 1800, h_max => 30 * 86400); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 12 | ▶ | printf(" %-30s %s\n", "Should be valid until", scalar localtime($vt)) if $vt && $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$vt and $options{"verbose"}
MC/DC50%1/2
$vt and $options{"verbose"}
$vt
$options{"verbose"}
Truth table66%2/3
A and B
A= $vtB= $options{"verbose"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 12 | ▶ | $vt ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$vt ||= 0
MC/DC0%0/1
$vt ||= 0
$vt
Truth table50%1/2
A
A= $vt
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | # temporary file for dumped contents | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 12 | ▶ | my ($tmpfh, $tmpfile) = File::Temp::tempfile("BeaconAggregator-XXXXXXXX", SUFFIX => ".txt", TMPDIR => 1) or croak("Could not acquire temporary file for storage"); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 12 | my $contref; # reference to content buffer | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 12 | ▶ | if ( ! $response->content_is_text ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 0 | my $ct = $response->content_type; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | print "WARNING: Response content is $ct, not text/*\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 0 | ▶ | if ( my $ce = $response->content_encoding ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 0 | print "NOTICE: Response is also Content-encoded: $ce\n"} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 0 | my $ctt = join("|", $response->decodable()); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 0 | ▶ | if ( $ct =~ s!^(.+\/)?($ctt)$!$2! ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | # yes: decode anyway since it could be a gzip-encoded .txt.gz file! | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 0 | my $cr = $response->decoded_content( raise_error => 1, ref => 1); # method exists since LWP 5.802 (2004-11-30) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | $response->remove_content_headers; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | my $newresp = HTTP::Response->new($response->code, $response->message, $response->headers); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 0 | $newresp->content_type("text/plain; charset: $charset"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 0 | $newresp->content_encoding($ct); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 0 | $newresp->content_ref($cr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 0 | $response = $newresp; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 12 | $contref = $response->decoded_content( raise_error => 1, ref => 1); # method exists since LWP 5.802 (2004-11-30) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 12 | ▶ | if ( $$contref =~ /^\x{FFEF}/ ) { # properly encoded BOM => put Characters to file | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | binmode($tmpfh, ":utf8"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 0 | print "INFO: properly encoded BOM detected: Groked UTF8\n"; # if $options{'verbose'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | elsif ( $$contref =~ s/^\xef\xbb\xbf// ) { # BOM Bytes => put Bytes to file, re-read as UTF-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 0 | print "INFO: Byte coded BOM detected: trying to restitute character semantics\n"; # if $options{'verbose'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | ▶ | print "INFO: Length is ", length($$contref), " ", (utf8::is_utf8($$contref) ? "characters" : "bytes"), "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 0 | binmode($tmpfh, ":bytes"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | ▶ | utf_deduplicate($contref) && binmode($tmpfh, ":utf8"); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | elsif ( utf8::is_utf8($$contref) ) { # already Upgraded strings should be written as utf-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 10 | ▶ | print "INFO: UTF8-ness already established\n" if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 10 | binmode($tmpfh, ":utf8"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 10 | utf_deduplicate($contref); # but don't trust it (older LWP with file URLs, ...) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | elsif ( utf8::decode($$contref) ) { # everything in character semantics now | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 2 | ▶ | print "INFO: Could decode bytes to UTF8-characters\n" if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 2 | binmode($tmpfh, ":utf8"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | else { # leave it alone | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 0 | print "WARNING: No clue about character encoding: Assume ISO 8859-1\n"; # if $options{'verbose'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 0 | binmode($tmpfh, ":utf8"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 12 | print $tmpfh $$contref; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 12 | close($tmpfh); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | # early cleanup since everything might be huge.... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | 12 | $contref = $response = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 12 | my ($collno, $count, $statref) = $self->loadFile($tmpfile, {_alias => $alias, _uri => $uri, _ruri => $nuri, _mtime => $lm, _sort => $osort}, %options); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 12 | ▶ | if ( ! $collno && $osq ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $collno and $osq
MC/DC0%0/2
not $collno and $osq
not $collno
$osq
Truth table33%1/3
not(A) and B
A= not $collnoB= $osq
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 0 | my ($usth, $usthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | UPDATE OR FAIL repos SET utime=?,ustat=? WHERE seqno==?; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 0 | ▶ | $self->stmtExplain($usthexpl, time(), ($statref ? "load error: $statref" : "internal error"), $osq) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | $usth->execute(time(), ($statref ? "load error: $statref" : "internal error"), $osq) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | ▶ | or croak("Could not execute >".$usth->{Statement}."<: ".$usth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 12 | ▶ | unlink($tmpfile) if -f $tmpfile; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 12 | ▶ | return $collno ? ($collno, $count) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | elsif ( $response->code == 304 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 1 | ▶ | print "INFO: $alias not modified since ".HTTP::Date::time2str($modtime)."\n" if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 1 | my $vt = $response->fresh_until(h_min => 1800, h_max => 6 * 86400); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 1 | ▶ | printf(" %-30s %s\n", "Will not try again before", scalar localtime($vt)) if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 1 | my ($usth, $usthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | UPDATE OR FAIL repos SET utime=?,ustat=?,ruri=? WHERE seqno==?; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 1 | ▶ | $self->stmtExplain($usthexpl, time(), $response->status_line, $nuri, $osq) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | $usth->execute(time(), $response->status_line, $nuri, $osq) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 1 | ▶ | or croak("Could not execute >".$usth->{Statement}."<: ".$usth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 0 | print "WARNING: No access to $uri for $alias [".$response->status_line."]\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 0 | print $response->headers_as_string, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | ▶ | return undef unless $osq; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | my ($usth, $usthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | UPDATE OR FAIL repos SET utime=?,ustat=?,ruri=? WHERE seqno==?; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 0 | ▶ | $self->stmtExplain($usthexpl, time(), $response->status_line, $nuri, $osq) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | $usth->execute(time(), $response->status_line, $nuri, $osq) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | ▶ | or croak("Could not execute >".$usth->{Statement}."<: ".$usth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | sub utf_deduplicate { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 10 | ▶ | my ($success, $stringref) = (0, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
utf_deduplicate: called CC=6 SCAR=26.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 10 | ▶ | if ( utf8::downgrade($$stringref, 1) ) { # 1 = FAIL_OK | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 10 | my $prevlength = length($$stringref); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | 10 | ▶ | print "INFO: Downgrade was possible, length now $prevlength ", (utf8::is_utf8($$stringref) ? "characters" : "bytes"), "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 10 | ▶ | while ( utf8::decode($$stringref) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | 0 | $success ++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | 0 | my $newlength = length($$stringref); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | 0 | ▶ | print "DEBUG: Reassembling as UTF-8 succeeded, length now $newlength ", (utf8::is_utf8($$stringref) ? "characters" : "bytes"), "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 0 | ▶ | last if $newlength == $prevlength; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 0 | $prevlength = $newlength; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | # last unless utf8::downgrade($$stringref, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | print "WARNING: no downgrade possible, proceed with byte semantics"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 10 | return $success; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | =head3 unload ( [ $seqno_or_alias, %options ] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | Deletes the sequence(s). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | =over 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | =item $seqno_or_alias | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | numeric sequence number, Alias or SQL pattern. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | =item Supported options: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | force => (0|1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | Needed to purge the complete database ($seqno_or_alias empty) or to purge | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | more than one sequence ($seqno_or_alias yields more than one seqno). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | sub unload { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 3 | ▶ | my ($self, $seqno_or_alias, %options) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unload: called CC=23 SCAR=46.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | 3 | ▶ | $options{'verbose'} = $self->{'verbose'} unless exists $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 3 | my @seqnos = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 3 | ▶ | if ( $seqno_or_alias && ($seqno_or_alias =~ /^\d+$/) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$seqno_or_alias and $seqno_or_alias =~ /^\d+$/
MC/DC0%0/2
$seqno_or_alias and $seqno_or_alias =~ /^\d+$/
$seqno_or_alias
$seqno_or_alias =~ /^\d+$/
Truth table33%1/3
A and B
A= $seqno_or_aliasB= $seqno_or_alias =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 0 | @seqnos = ($seqno_or_alias)} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | ▶ | elsif ( $seqno_or_alias || $options{'force'} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$seqno_or_alias or $options{"force"}
MC/DC0%0/2
$seqno_or_alias or $options{"force"}
$seqno_or_alias
$options{"force"}
Truth table33%1/3
A or B
A= $seqno_or_aliasB= $options{"force"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 3 | ▶ | @seqnos = $self->Seqnos('_alias', $seqno_or_alias ? ($seqno_or_alias) : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | 3 | ▶ | unless ( @seqnos ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 0 | carp("no Seqnos selected by $seqno_or_alias"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 3 | ▶ | unless ( $options{'force'} or (@seqnos == 1) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$options{"force"} or @seqnos == 1
MC/DC0%0/2
$options{"force"} or @seqnos == 1
$options{"force"}
@seqnos == 1
Truth table33%1/3
A or B
A= $options{"force"}B= @seqnos == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 0 | carp("Use --force to purge more than one sequence (@seqnos)"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | 0 | carp("Use --force to purge the complete database"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 3 | ▶ | if ( $options{'force'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 0 | my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | DELETE FROM beacons WHERE seqno==?; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | 0 | foreach my $seqno ( @seqnos ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 0 | ▶ | $self->stmtExplain($sthexpl, $seqno_or_alias) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | ▶ | my $rows = $sth->execute($seqno_or_alias) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | 0 | ▶ | print "INFO: $rows forced for $seqno\n" if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | 3 | my ($cond, @cval) = SeeAlso::Source::BeaconAggregator::mkConstraint($seqno_or_alias); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 3 | my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | DELETE FROM repos $cond; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | 3 | ▶ | $self->stmtExplain($sthexpl, @cval) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 3 | ▶ | my $rows = $sth->execute(@cval) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 3 | ▶ | $rows = 0 if $rows eq "0E0"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | 3 | ▶ | if ( $rows or $options{'force'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$rows or $options{"force"}
MC/DC0%0/2
$rows or $options{"force"}
$rows
$options{"force"}
Truth table33%1/3
A or B
A= $rowsB= $options{"force"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | # if ( $options{'force'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | # print "[ANALYZE ..." if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | # $self->{dbh}->do("ANALYZE;"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | # print "]\n" if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | # }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 3 | ▶ | if ( $options{'nostat'} ) { # invalidate since they might have changed | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | 0 | $self->admin('gcounti', undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | 0 | $self->admin('gcountu', undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | 3 | ▶ | $self->admin('gcounti', $self->idStat(undef, 'distinct' => 0) || 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->idStat(undef, 'distinct', 0) || 0
MC/DC0%0/1
$self->idStat(undef, 'distinct', 0) || 0
$self->idStat(undef, 'distinct', 0)
Truth table50%1/2
A
A= $self->idStat(undef, 'distinct', 0)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 3 | ▶ | $self->admin('gcountu', $self->idStat(undef, 'distinct' => 1) || 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->idStat(undef, 'distinct', 1) || 0
MC/DC0%0/1
$self->idStat(undef, 'distinct', 1) || 0
$self->idStat(undef, 'distinct', 1)
Truth table50%1/2
A
A= $self->idStat(undef, 'distinct', 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | 3 | return $rows; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | =head3 purge ( $seqno_or_alias[, %options ] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | Deletes all identifiers from the database to the given pattern, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | but leaves the stored header information intact, such that it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | can be updated automatically. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | =over 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | =item $seqno_or_alias | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | Pattern | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | =item Supported options: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | force => (0|1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | Allow purging of more than one sequence. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | sub purge { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | 2 | ▶ | my ($self, $seqno_or_alias, %options) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
purge: called CC=22 SCAR=41.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | 2 | ▶ | $options{'verbose'} = $self->{'verbose'} unless exists $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | 2 | my @seqnos; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | 2 | ▶ | if ( $seqno_or_alias && ($seqno_or_alias =~ /^\d+$/) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$seqno_or_alias and $seqno_or_alias =~ /^\d+$/
MC/DC0%0/2
$seqno_or_alias and $seqno_or_alias =~ /^\d+$/
$seqno_or_alias
$seqno_or_alias =~ /^\d+$/
Truth table33%1/3
A and B
A= $seqno_or_aliasB= $seqno_or_alias =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | 0 | @seqnos = ($seqno_or_alias)} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | ▶ | elsif ( $seqno_or_alias || $options{'force'} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$seqno_or_alias or $options{"force"}
MC/DC0%0/2
$seqno_or_alias or $options{"force"}
$seqno_or_alias
$options{"force"}
Truth table33%1/3
A or B
A= $seqno_or_aliasB= $options{"force"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | 2 | ▶ | @seqnos = $self->Seqnos('_alias', $seqno_or_alias ? ($seqno_or_alias) : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | 2 | ▶ | unless ( @seqnos ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 0 | carp("no Seqnos selected by $seqno_or_alias"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 2 | ▶ | unless ( $options{'force'} or (@seqnos == 1) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$options{"force"} or @seqnos == 1
MC/DC0%0/2
$options{"force"} or @seqnos == 1
$options{"force"}
@seqnos == 1
Truth table33%1/3
A or B
A= $options{"force"}B= @seqnos == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | 0 | carp("Use --force to purge more than one sequence (@seqnos)"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 0 | carp("Use --force to purge the complete database"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 2 | my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | DELETE FROM beacons WHERE seqno==?; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | 2 | my ($usth, $usthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | UPDATE OR FAIL repos SET counti=?,countu=?,utime=?,ustat=? WHERE seqno==?; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | 2 | my $trows = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | 2 | foreach my $seqno ( @seqnos ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 2 | ▶ | $self->stmtExplain($sthexpl, $seqno) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | 2 | ▶ | my $rows = $sth->execute($seqno) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | 2 | ▶ | $rows = "0" if $rows eq "0E0"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | 2 | ▶ | print "INFO: $rows purged for $seqno\n" if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | 2 | $trows += $rows; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | 2 | ▶ | $self->stmtExplain($usthexpl, 0, 0, time, "purged", $seqno) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | $usth->execute(0, 0, time, "purged", $seqno) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 2 | ▶ | or croak("Could not execute >".$usth->{Statement}."<: ".$usth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 2 | ▶ | if ( $trows or $options{'force'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$trows or $options{"force"}
MC/DC0%0/2
$trows or $options{"force"}
$trows
$options{"force"}
Truth table33%1/3
A or B
A= $trowsB= $options{"force"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | # if ( $options{'force'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | # print "[ANALYZE ..." if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | # $self->{dbh}->do("ANALYZE;"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | # print "]\n" if $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | # }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | 2 | ▶ | if ( $options{'nostat'} ) { # invalidate since they might have changed | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | 0 | $self->admin('gcounti', undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | 0 | $self->admin('gcountu', undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | 2 | ▶ | $self->admin('gcounti', $self->idStat(undef, 'distinct' => 0) || 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->idStat(undef, 'distinct', 0) || 0
MC/DC0%0/1
$self->idStat(undef, 'distinct', 0) || 0
$self->idStat(undef, 'distinct', 0)
Truth table50%1/2
A
A= $self->idStat(undef, 'distinct', 0)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | 2 | ▶ | $self->admin('gcountu', $self->idStat(undef, 'distinct' => 1) || 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->idStat(undef, 'distinct', 1) || 0
MC/DC0%0/1
$self->idStat(undef, 'distinct', 1) || 0
$self->idStat(undef, 'distinct', 1)
Truth table50%1/2
A
A= $self->idStat(undef, 'distinct', 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | 2 | return $trows; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | =head2 Methods for headers | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | =head3 ($rows, @oldvalues) = headerfield ( $sq_or_alias, $key [, $value] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | Gets or sets an meta or admin Entry for the constituent file indicated by $sq_or_alias | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | sub headerfield { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 9 | ▶ | my ($self, $sq_or_alias, $key, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
headerfield: called CC=14 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | 9 | my $dbkey = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | 9 | ▶ | if ( $dbkey = SeeAlso::Source::BeaconAggregator->beaconfields($key) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | elsif ( $key =~ /_(\w+)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | 5 | $dbkey = $1} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | carp "Field $key not known"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | 9 | my ($cond, @cval) = SeeAlso::Source::BeaconAggregator::mkConstraint($sq_or_alias); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | 9 | my ($osth, $osthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | SELECT $dbkey FROM repos $cond; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | 9 | ▶ | $self->stmtExplain($osthexpl, @cval) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | 9 | ▶ | $osth->execute(@cval) or croak("Could not execute >".$osth->{Statement}."<:".$osth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | 9 | my $tmpval = $osth->fetchall_arrayref(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | 9 | ▶ | my @oval = map { hEncode($_, $key) } map { (defined $_->[0]) ? ($_->[0]) : () } @$tmpval; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | 9 | my $rows = scalar @oval; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | 9 | ▶ | if ( (defined $value) and ($value ne "") ) { # set | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $value and $value ne ""
MC/DC50%1/2
defined $value and $value ne ""
defined $value
$value ne ""
Truth table66%2/3
A and B
A= defined $valueB= $value ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | 3 | my ($usth, $usthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | UPDATE OR FAIL repos SET $dbkey=? $cond; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | 3 | ▶ | $value = hDecode($value, $key) || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
hDecode($value, $key) || ''
MC/DC100%1/1
hDecode($value, $key) || ''
hDecode($value, $key)
Truth table100%2/2
A
A= hDecode($value, $key)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | 3 | ▶ | $self->stmtExplain($usthexpl, $value, @cval) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | 3 | ▶ | $rows = $usth->execute($value, @cval) or croak("Could not execute >".$usth->{Statement}."<:".$usth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | elsif ( defined $value ) { # clear | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 0 | my ($dsth, $dsthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | UPDATE OR FAIL repos SET $dbkey=? $cond; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | 0 | ▶ | $self->stmtExplain($dsthexpl, undef, @cval) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | 0 | ▶ | $rows = $dsth->execute(undef, @cval) or croak("Could not execute >".$dsth->{Statement}."<:".$dsth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | else { # read | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | 9 | return ($rows, @oval); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | =head3 ($resultref, $metaref) = headers ( [ $seqno_or_alias ] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | Iterates over all | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | For each iteration returns two hash references: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | =over 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | =item 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | all official beacon fields | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | =item 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | all administrative fields (_alias, ...) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | sub headers { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | 5 | ▶ | my ($self, $seqno_or_alias) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
headers: called CC=10 SCAR=23.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | 5 | ▶ | unless ( $self->{_iterator_info} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | 1 | my ($constraint, @cval) = SeeAlso::Source::BeaconAggregator::mkConstraint($seqno_or_alias); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | 1 | my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | SELECT * FROM repos $constraint; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | 1 | ▶ | $self->stmtExplain($sthexpl, @cval) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | 1 | ▶ | $sth->execute(@cval) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | 1 | $self->{_iterator_info} = $sth; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | 5 | my $info = $self->{_iterator_info}->fetchrow_hashref; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | 5 | ▶ | unless ( defined $info ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 1 | ▶ | croak("Error listing Collections: $self->{_iterator_info}->errstr") if $self->{_iterator_info}->err; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | 1 | delete $self->{_iterator_info}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | 4 | ▶ | my $collno = $info->{seqno} || $seqno_or_alias; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$info->{'seqno'} || $seqno_or_alias
MC/DC0%0/2
$info->{'seqno'} || $seqno_or_alias
$info->{'seqno'}
$seqno_or_alias
Truth table33%1/3
A || B
A= $info->{'seqno'}B= $seqno_or_alias
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | 4 | my %meta = (_seqno => $collno); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | 4 | my %result = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | 4 | ▶ | while ( my($key, $val) = each %$info ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | 136 | ▶ | next unless defined $val; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | 71 | my $pval = hEncode($val, $key); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | 71 | ▶ | if ( $key =~ /^bc(\w+)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | 25 | $result{$1} = $pval} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | 46 | $meta{"_$key"} = $pval}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | 4 | return \%result, \%meta; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | =head3 listCollections ( [ $seqno_or_alias ] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | Iterates over all Sequences and returns on each call an array of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | Seqno, Alias, Uri, Modification time, Identifier Count and Unique identifier count | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | Returns undef if done. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | sub listCollections { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | 31 | ▶ | my ($self, $seqno_or_alias) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listCollections: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | 31 | ▶ | unless ( $self->{_iterator_listCollections} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | 8 | my ($constraint, @cval) = SeeAlso::Source::BeaconAggregator::mkConstraint($seqno_or_alias); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | 8 | my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | SELECT seqno, alias, uri, mtime, counti, countu FROM repos $constraint; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | 8 | ▶ | $self->stmtExplain($sthexpl, @cval) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | 8 | ▶ | $sth->execute(@cval) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | 8 | $self->{_iterator_listCollections} = $sth; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | 31 | my $onerow = $self->{_iterator_listCollections}->fetchrow_arrayref; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | 31 | ▶ | unless ( $onerow ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | 8 | ▶ | croak("Error listing Collections: $self->{_iterator_listCollections}->errstr") if $self->{_iterator_listCollections}->err; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | 8 | delete $self->{_iterator_listCollections}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | 8 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | 23 | return @$onerow; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | =head2 Statistics | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | =head3 idStat ( [ $seqno_or_alias, %options ] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | Count identifiers for the given pattern. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | =over 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | =item Supported options: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | distinct => (0|1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | Count multiple occurences only once | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | verbose => (0|1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | sub idStat { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | 82 | ▶ | my ($self, $seqno_or_alias, %options) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
idStat: called CC=10 SCAR=23.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | 82 | ▶ | $options{'verbose'} = $self->{'verbose'} unless exists $options{'verbose'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | 82 | my $cond = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | 82 | ▶ | if ( $seqno_or_alias && ($seqno_or_alias =~ /^\d+$/) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$seqno_or_alias and $seqno_or_alias =~ /^\d+$/
MC/DC100%2/2
$seqno_or_alias and $seqno_or_alias =~ /^\d+$/
$seqno_or_alias
$seqno_or_alias =~ /^\d+$/
Truth table100%3/3
A and B
A= $seqno_or_aliasB= $seqno_or_alias =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | 26 | $cond = "WHERE seqno==$seqno_or_alias"} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | elsif ( $seqno_or_alias ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | 5 | my @seqnos = $self->Seqnos('_alias', $seqno_or_alias); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | 5 | ▶ | if ( @seqnos ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | 5 | $cond = "WHERE seqno IN (".join(",", @seqnos).")"} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | 0 | carp("no Seqnos selected by $seqno_or_alias"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | # my $count_what = $options{'distinct'} ? "DISTINCT hash" : "*"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | # will not be optimized by SQLite or mySQL: SELECT COUNT($count_what) FROM beacons $cond; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | # my $sth= $self->stmtHdl("SELECT COUNT($count_what) FROM beacons $cond LIMIT 1;"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | 82 | ▶ | my $from = $options{'distinct'} ? "(SELECT DISTINCT hash FROM beacons $cond)" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | : "beacons $cond"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | 82 | my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | SELECT COUNT(*) FROM $from LIMIT 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | 82 | ▶ | $self->stmtExplain($sthexpl) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | 82 | ▶ | $sth->execute() or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | 82 | my $hits = $sth->fetchrow_arrayref; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | 82 | ▶ | return $hits->[0] || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$hits->[0] || 0
MC/DC0%0/1
$hits->[0] || 0
$hits->[0]
Truth table50%1/2
A
A= $hits->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | =head3 idCounts ( [ $pattern, %options ] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | Iterates through the entries according to the optional id filter expression. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | For each iteration the call returns a triple consisting of (identifier, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | number of rows, and sum of all individual counts). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | =over 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | =item Supported options: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | distinct => (0|1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | Count multiple occurences in one beacon file only once. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | sub idCounts { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | 76 | ▶ | my ($self, $pattern, %options) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
idCounts: called CC=14 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | 76 | ▶ | my $cond = $pattern ? qq!WHERE hash LIKE "$pattern"! : ""; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | 76 | ▶ | my $count_what = $options{'distinct'} ? "DISTINCT seqno" : "seqno"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | 76 | ▶ | unless ( $self->{_iterator_idCounts} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | 10 | my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | SELECT hash, COUNT($count_what), SUM(hits) FROM beacons $cond GROUP BY hash ORDER BY hash; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | 10 | ▶ | $self->stmtExplain($sthexpl) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | 10 | ▶ | $sth->execute() or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | 10 | $self->{_iterator_idCounts} = $sth; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | 10 | ▶ | unless ( defined $self->{identifierClass} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | 4 | my $package = $self->autoIdentifier(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | 4 | ▶ | $options{'verbose'} && ref($package) && carp "Assuming identifiers of type ".ref($package)."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$options{"verbose"} and ref $package
MC/DC0%0/2
$options{"verbose"} and ref $package
$options{"verbose"}
ref $package
Truth table66%2/3
A and B
A= $options{"verbose"}B= ref $package
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | 76 | my $onerow = $self->{_iterator_idCounts}->fetchrow_arrayref; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | 76 | ▶ | unless ( $onerow ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | 10 | ▶ | croak("Error listing Collections: $self->{_iterator_idCounts}->errstr") if $self->{_iterator_idCounts}->err; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | 10 | delete $self->{_iterator_idCounts}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | 10 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | 66 | ▶ | if ( defined $self->{identifierClass} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | 42 | my $c = $self->{identifierClass}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | # compat: hash might not take an argument, must resort to value, has to be cleared before... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | 42 | $c->value(""); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | 42 | ▶ | my $did = $c->hash($onerow->[0]) || $c->value($onerow->[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$c->hash($onerow->[0]) || $c->value($onerow->[0])
MC/DC100%2/2
$c->hash($onerow->[0]) || $c->value($onerow->[0])
$c->hash($onerow->[0])
$c->value($onerow->[0])
Truth table100%3/3
A || B
A= $c->hash($onerow->[0])B= $c->value($onerow->[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | 42 | ▶ | $onerow->[0] = $c->can("pretty") ? $c->pretty() : $c->value(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | 66 | return @$onerow; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | =head3 idList ( [ $pattern ] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | Iterates through the entries according to the optional selection. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | For each iteration the call returns a tuple consisting of identifier and an | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | list of array references (Seqno, Hits, Info, explicit Link, AltId) or the emtpy list | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | if finished. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | Hits, Info, Link and AltId are normalized to the empty string if undefined (or < 2 for hits). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | It is important to finish all iterations before calling this method for "new" arguments: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | 1 while $db->idList(); # flush pending results | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | sub idList { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | 62 | ▶ | my ($self, $pattern) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
idList: called CC=22 SCAR=31.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | 62 | ▶ | my $cond = $pattern ? ($pattern =~ /%/ ? "WHERE hash LIKE ?" : qq"WHERE hash=?") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | : ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | 62 | ▶ | unless ( $self->{_iterator_idList_handle} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | 11 | my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | SELECT hash, seqno, hits, info, link, altid FROM beacons $cond ORDER BY hash, seqno, altid; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | 11 | ▶ | $self->stmtExplain($sthexpl, ($pattern ? ($pattern) : () )) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | 11 | ▶ | $sth->execute(($pattern ? ($pattern) : () )) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | 11 | $self->{_iterator_idList_handle} = $sth; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | 11 | $self->{_iterator_idList_crosscheck} = $self->RepoCols("ALTTARGET"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | 11 | $self->{_iterator_idList_prefetch} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | 11 | ▶ | $self->autoIdentifier() unless defined $self->{identifierClass}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | 62 | ▶ | unless ( exists $self->{_iterator_idList_prefetch} ) { # deferred exit | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | 11 | delete $self->{_iterator_idList_handle}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | 11 | delete $self->{_iterator_idList_crosscheck}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 11 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | 51 | my $pf = $self->{_iterator_idList_prefetch}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | 51 | ▶ | while ( my $onerow = $self->{_iterator_idList_handle}->fetchrow_arrayref ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | # $onerow->[2] = "" unless $self->{_iterator_idList_crosscheck}->{$onerow->[1]}; # kill artefacts | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | 71 | ▶ | $onerow->[2] = "" unless $onerow->[2]; # kill artefacts | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | 71 | ▶ | $onerow->[3] = "" unless defined $onerow->[3]; # kill artefacts | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | 71 | ▶ | $onerow->[4] = "" unless defined $onerow->[4]; # kill artefacts | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | 71 | ▶ | $onerow->[5] = "" unless defined $onerow->[5]; # kill artefacts | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | 71 | ▶ | if ( defined $self->{identifierClass} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | 36 | my $c = $self->{identifierClass}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | # compat: hash might not take an argument, must resort to value, has to be cleared before... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | 36 | $c->value(""); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | 36 | ▶ | my $did = $c->hash($onerow->[0]) || $c->value($onerow->[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$c->hash($onerow->[0]) || $c->value($onerow->[0])
MC/DC100%2/2
$c->hash($onerow->[0]) || $c->value($onerow->[0])
$c->hash($onerow->[0])
$c->value($onerow->[0])
Truth table100%3/3
A || B
A= $c->hash($onerow->[0])B= $c->value($onerow->[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | 36 | ▶ | $onerow->[0] = $c->can("pretty") ? $c->pretty() : $c->value(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | 71 | ▶ | if ( $pf ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | 60 | ▶ | if ( $pf->[0] eq $onerow->[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | 20 | push(@$pf, [@$onerow[1..@$onerow-1]]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | 20 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | 40 | $self->{_iterator_idList_prefetch} = [$onerow->[0], [@$onerow[1..@$onerow-1]]]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | 40 | return @$pf; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | 11 | $pf = [$onerow->[0], [@$onerow[1..@$onerow-1]]]}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | 11 | ▶ | if ( $self->{_iterator_idList_handle}->err ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | 0 | croak("Error listing Collections: $self->{_iterator_idList_handle}->errstr"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | 11 | delete $self->{_iterator_idList_prefetch}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | 11 | ▶ | return $pf ? @$pf : (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | =head2 Manipulation of global metadata: Open Search Description | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | =head3 setOSD ( $field, @values } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | Sets the field $field of the OpenSearchDescription to @value(s). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | sub setOSD { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | 20 | ▶ | my ($self) = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setOSD: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | 20 | ▶ | $self->clearOSD($_[0]) or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | 18 | ▶ | return (defined $_[1]) ? $self->addOSD(@_) : 0; # value(s) to set | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | =head3 clearOSD ( $field } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | Clears the field $field of the OpenSearchDescription. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | sub clearOSD { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | 27 | ▶ | my ($self, $field) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clearOSD: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | 27 | ▶ | $field || (carp("no OSD field name provided"), return undef); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | 25 | ▶ | defined $self->osdKeys($field) || (carp("no valid OSD field '$field'"), return undef); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | 23 | my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | DELETE FROM osd WHERE key=?; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | 23 | ▶ | $self->stmtExplain($sthexpl, $field) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | 23 | ▶ | $sth->execute($field) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | 23 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | =head3 addOSD ( $field, @values } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | Adds more @value(s) as (repeatable) field $field of the OpenSearchDescription. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | sub addOSD { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | 24 | ▶ | my ($self, $field, @values) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addOSD: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | 24 | ▶ | $field || (carp("no OSD field name provided"), return undef); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | 23 | ▶ | return 0 unless @values; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | 22 | ▶ | defined $self->osdKeys($field) || (carp("no valid OSD field '$field'"), return undef); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | 21 | my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | INSERT INTO osd ( key, val ) VALUES ( ?, ? ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | 21 | ▶ | $self->stmtExplain($sthexpl, $field, $values[0]) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | 21 | my $tstatus = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | 21 | ▶ | my $tuples = $sth->execute_array({ArrayTupleStatus => $tstatus}, $field, \@values) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | 21 | return $tuples; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | =head2 Manipulation of global metadata: Beacon Metadata | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | These headers are used when you will be publishing a beacon file for the collection. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | =head3 setBeaconMeta ( $field, $value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | Sets the field $field of the Beacon meta table (used to generate a BEACON file for this | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | service) to $value. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | sub setBeaconMeta { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | 4 | ▶ | my ($self) = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setBeaconMeta: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | 4 | ▶ | $self->clearBeaconMeta(@_) or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | 2 | ▶ | return (defined $_[1]) ? $self->addBeaconMeta(@_) : 0; # value to set | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | =head3 clearBeaconMeta ( $field } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | Deletes the field $field of the Beacon meta table. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | sub clearBeaconMeta { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | 7 | ▶ | my ($self, $rfield) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clearBeaconMeta: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | 7 | ▶ | $rfield || (carp("no Beacon field name provided"), return undef); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | 5 | ▶ | my $field = $self->beaconfields($rfield) or (carp("no valid Beacon field '$rfield'"), return undef); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | 3 | my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | DELETE FROM osd WHERE key=?; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | 3 | ▶ | $self->stmtExplain($sthexpl, $field) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | 3 | ▶ | $sth->execute($field) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | =head3 addBeaconMeta ( $field, $value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | Appends $value to the field $field of the BEACON meta table | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | sub addBeaconMeta { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | 7 | ▶ | my ($self, $rfield, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addBeaconMeta: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | 7 | ▶ | $rfield || (carp("no Beacon field name provided"), return undef); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | 6 | ▶ | my $field = $self->beaconfields($rfield) or (carp("no valid Beacon field '$rfield'"), return undef); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | 5 | my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | INSERT INTO osd ( key, val ) VALUES ( ?, ? ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | XxX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | 5 | ▶ | $self->stmtExplain($sthexpl, $field, $value) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | 5 | ▶ | $sth->execute($field, $value) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | 5 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | =head3 admin ( [$field, [$value]] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | Manipulates the admin table. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | Yields a hashref to the admin table if called without arguments. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | If called with $field, returns the current value, and sets the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | table entry to $value if defined. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | sub admin { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | 54 | ▶ | my ($self, $field, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
admin: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | 54 | my $admref = $self->admhash(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | 54 | ▶ | return $admref unless $field; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | 51 | my $retval = $admref->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | 51 | ▶ | return $retval unless defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | 40 | my ($admh, $admexpl) = $self->stmtHdl("INSERT OR REPLACE INTO admin VALUES (?, ?);"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | 40 | ▶ | $self->stmtExplain($admexpl, $field, $value) if $ENV{'DBI_PROFILE'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | 40 | ▶ | $admh->execute($field, $value) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | or croak("Could not execute update to admin table: ".$admh->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | 40 | ▶ | return defined($retval) ? $retval : ""; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | # on-the-fly conversions | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | sub hDecode { # external time to numeric timestamp, printf placeholders | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | 30 | ▶ | my ($val, $fnam) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hDecode: called CC=9 SCAR=23.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | 30 | ▶ | return $val unless $fnam; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | 30 | ▶ | local($_) = (ref $val) ? $val->{$fnam} : $val; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | 30 | ▶ | return undef unless defined $_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | 30 | ▶ | if ( $fnam =~ /target$/i ) { s/%/%%/g; s/(\{id\}|\$PND)/%1\$s/gi; s/(\{altid\}|\$PND)/%2\$s/gi; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | 0 | elsif ( $fnam =~ /message$/i ) { s/%/%%/g; s/\{hits?\}/%s/gi; } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | elsif ( $fnam =~ /time|revisit/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | 3 | ▶ | if ( /^\d+$/ ) { # legacy UNIX timestamp | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | elsif ( my $p = HTTP::Date::str2time($_, "GMT") ) { # all unqualified times are GMT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | 2 | $_ = $p} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | 0 | carp("could not parse value '$_' as time in field $fnam"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | 30 | return $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | sub hEncode { # timestamp to beacon format | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | 80 | ▶ | my ($val, $fnam) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hEncode: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | 80 | ▶ | local($_) = (ref $val) ? $val->{$fnam} : $val; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | 80 | ▶ | return undef unless defined $_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | 80 | ▶ | if ( $fnam =~ /time|revisit/i ) { $_ = SeeAlso::Source::BeaconAggregator::tToISO($_) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | 2 | elsif ( $fnam =~ /message/i ) { s/%s/{hits}/; s/%%/%/g; } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | 6 | elsif ( $fnam =~ /target/i ) { s/%s/{ID}/; s/%1\$s/{ID}/; s/%2\$s/{ALTID}/; s/%%/%/g; }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | 80 | return $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | Thomas Berger | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | CPAN ID: THB | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | gymel.com | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | THB@cpan.org | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | This program is free software; you can redistribute | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | it and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | The full text of the license can be found in the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | LICENSE file included with this module. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | 37 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | |||||||||||||||||||||||||||||||||||||||||||||||||||