line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::ClickHouse::Base; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
14292
|
use 5.010000; |
|
1
|
|
|
|
|
2
|
|
4
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use Scalar::Util qw/looks_like_number/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
501
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
HTTP::ClickHouse::Base - Base class for HTTP::ClickHouse modules |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 0.01 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
22
|
|
|
|
|
|
|
# my $baseclass = shift; |
23
|
|
|
|
|
|
|
# my $class = ref($baseclass) || $baseclass; |
24
|
1
|
|
|
1
|
0
|
11
|
my $class = shift; |
25
|
1
|
|
|
|
|
4
|
my $self = { @_ }; |
26
|
1
|
|
|
|
|
2
|
$self = bless $self, $class; |
27
|
|
|
|
|
|
|
# $self->_init(); |
28
|
1
|
|
|
|
|
2
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _init { |
32
|
1
|
|
|
1
|
|
869
|
my $self = shift; |
33
|
1
|
|
|
|
|
8
|
my %_attrs = ( |
34
|
|
|
|
|
|
|
host => '127.0.0.1', |
35
|
|
|
|
|
|
|
port => 8123, |
36
|
|
|
|
|
|
|
database => 'default', |
37
|
|
|
|
|
|
|
user => undef, |
38
|
|
|
|
|
|
|
password => undef, |
39
|
|
|
|
|
|
|
keep_alive => 1, |
40
|
|
|
|
|
|
|
nb_timeout => 25, |
41
|
|
|
|
|
|
|
debug => 0 |
42
|
|
|
|
|
|
|
); |
43
|
1
|
|
|
|
|
4
|
foreach my $_key ( keys %_attrs ) { |
44
|
8
|
100
|
|
|
|
19
|
unless ($self->{$_key}){ |
45
|
5
|
|
|
|
|
11
|
$self->{$_key} = $_attrs{$_key}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub data_prepare { |
51
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
52
|
0
|
|
|
|
|
|
my @_rows = map { [@$_] } @_; |
|
0
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
foreach my $row (@_rows) { |
54
|
0
|
|
|
|
|
|
foreach my $val (@$row) { |
55
|
0
|
0
|
0
|
|
|
|
unless (defined ($val)) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$val = qq{''}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
elsif (ref($val) eq 'ARRAY') { |
59
|
0
|
|
|
|
|
|
$val = q{'}.join ("','", @$val).q{'}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
elsif (defined ($val) && !looks_like_number($val)) { |
62
|
0
|
|
|
|
|
|
$val =~ s/\\/\\\\/g; |
63
|
0
|
|
|
|
|
|
$val =~ s/'/\\'/g; |
64
|
0
|
|
|
|
|
|
$val = qq{'$val'}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
0
|
0
|
|
|
|
|
return scalar @_rows ? join ",", map { "(".join (",", @{ $_ }).")" } @_rows : "\n"; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub body2array { |
72
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
73
|
0
|
|
|
|
|
|
my @_response = @_; |
74
|
0
|
|
|
|
|
|
return [ map { [ split (/\t/) ] } @_response ]; |
|
0
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub array2hash { |
78
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
79
|
0
|
|
|
|
|
|
my @_response = @_; |
80
|
0
|
|
|
|
|
|
my $response; |
81
|
0
|
|
|
|
|
|
my $key = shift @_response; |
82
|
0
|
|
|
|
|
|
for (0..$#_response) { |
83
|
0
|
|
|
|
|
|
my $row = $_; |
84
|
0
|
|
|
|
|
|
for (0..$#{$_response[$row]}) { |
|
0
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my $col = $_; |
86
|
0
|
|
|
|
|
|
$response->[$row]->{"".$key->[$col].""} = $_response[$row][$_]; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
0
|
|
|
|
|
|
return $response; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
0
|
|
|
sub DESTROY { |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 SYNOPSIS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
use IO::Compress::Base ; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 DESCRIPTION |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This module is not intended for direct use in application code. Its sole purpose is to be sub-classed by HTTP::ClickHouse modules. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SEE ALSO |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 MODIFICATION HISTORY |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 AUTHOR |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Maxim Motylkov |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
See the Changes file. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Copyright 2016 Maxim Motylkov |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
122
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |