DBIO-PostgreSQL
view release on metacpan or search on metacpan
lib/DBIO/PostgreSQL/InflateColumn/Vector.pm view on Meta::CPAN
Carp::croak(
'cannot deflate a sparsevec hashref without dimensions: '
. 'declare the column as sparsevec(N) or pass { dims => N, values => { idx => val } }'
) unless defined $d;
my $body = join(',', map { "$_:$values->{$_}" } sort { $a <=> $b } keys %$values);
return "{$body}/$d";
}
# Numeric-looking values come back as numbers (the natural Perl shape for a
# vector); 'NaN'/'Infinity' and anything else stay strings.
sub _coerce_number {
my ($class, $value) = @_;
return $value unless $value =~ /\A-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\z/;
return 0 + $value;
}
sub _trim {
my ($value) = @_;
$value =~ s/\A\s+//;
( run in 0.748 second using v1.01-cache-2.11-cpan-60884a8df76 )