line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBD::Cassandra::dr; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TVDW'; |
3
|
|
|
|
|
|
|
$DBD::Cassandra::dr::VERSION = '0.56_003'; # TRIAL |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$DBD::Cassandra::dr::VERSION = '0.56003';# ABSTRACT: DBD::Cassandra driver handle |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
13
|
use 5.010; |
|
1
|
|
|
|
|
2
|
|
8
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
9
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
308
|
use Cassandra::Client 0.10; |
|
1
|
|
|
|
|
144372
|
|
|
1
|
|
|
|
|
444
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# "*FIX ME* Explain what the imp_data_size is, so that implementors aren't |
14
|
|
|
|
|
|
|
# practicing cargo-cult programming" - DBI::DBD docs |
15
|
|
|
|
|
|
|
$DBD::Cassandra::dr::imp_data_size = 0; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub connect { |
18
|
0
|
|
|
0
|
0
|
|
my ($drh, $dr_dsn, $user, $auth, $attr)= @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Iterate through the DSN, write to $attr |
21
|
0
|
|
|
|
|
|
my $driver_prefix= 'cass_'; |
22
|
0
|
|
|
|
|
|
for my $var (split /;/, $dr_dsn) { |
23
|
0
|
|
|
|
|
|
my ($attr_name, $attr_val)= split '=', $var, 2; |
24
|
0
|
0
|
|
|
|
|
return $drh->set_err($DBI::stderr, "Can't parse DSN part '$var'") |
25
|
|
|
|
|
|
|
unless defined $attr_val; |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
$attr_name= "cass_$attr_name" unless $attr_name =~ /\A$driver_prefix/o; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$attr->{$attr_name}= $attr_val; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
0
|
|
|
|
my $keyspace= delete $attr->{cass_database} || delete $attr->{cass_db} || delete $attr->{cass_keyspace}; |
33
|
0
|
|
0
|
|
|
|
my $host= delete $attr->{cass_host} || delete $attr->{cass_hostname} || delete $attr->{cass_hosts} || delete $attr->{cass_hostnames} || 'localhost'; |
34
|
0
|
|
|
|
|
|
my $hosts= [ grep $_, split /,/, $host ]; |
35
|
0
|
|
0
|
|
|
|
my $port= delete $attr->{cass_port} || 9042; |
36
|
0
|
|
|
|
|
|
my $global_consistency= delete $attr->{cass_consistency}; |
37
|
0
|
|
|
|
|
|
my $compression= delete $attr->{cass_compression}; |
38
|
0
|
|
|
|
|
|
my $cql_version= delete $attr->{cass_cql_version}; |
39
|
0
|
|
|
|
|
|
my $read_timeout= delete $attr->{cass_read_timeout}; |
40
|
0
|
|
|
|
|
|
my $write_timeout= delete $attr->{cass_write_timeout}; |
41
|
0
|
|
|
|
|
|
my $connect_timeout= delete $attr->{cass_connect_timeout}; #XXX |
42
|
0
|
|
|
|
|
|
my $request_timeout= delete $attr->{cass_request_timeout}; |
43
|
0
|
|
|
|
|
|
my $tls= delete $attr->{cass_tls}; |
44
|
0
|
0
|
0
|
|
|
|
if ($read_timeout || $write_timeout) { |
45
|
0
|
0
|
|
|
|
|
if ($request_timeout) { |
46
|
0
|
|
|
|
|
|
warn 'Ignoring read_timeout and write_timeout settings, as request_timeout is passed'; |
47
|
|
|
|
|
|
|
} else { |
48
|
0
|
|
0
|
|
|
|
$request_timeout= ($read_timeout || 6) + ($write_timeout || 6); |
|
|
|
0
|
|
|
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $client= Cassandra::Client->new( |
53
|
|
|
|
|
|
|
contact_points => $hosts, |
54
|
|
|
|
|
|
|
port => $port, |
55
|
|
|
|
|
|
|
username => $user, |
56
|
|
|
|
|
|
|
password => $auth, |
57
|
|
|
|
|
|
|
keyspace => $keyspace, |
58
|
|
|
|
|
|
|
compression => $compression, |
59
|
|
|
|
|
|
|
default_consistency => $global_consistency, |
60
|
|
|
|
|
|
|
cql_version => $cql_version, |
61
|
|
|
|
|
|
|
request_timeout => $request_timeout, |
62
|
|
|
|
|
|
|
anyevent => 0, |
63
|
|
|
|
|
|
|
tls => $tls, |
64
|
|
|
|
|
|
|
); |
65
|
0
|
|
|
|
|
|
my ($error)= $client->call_connect; |
66
|
0
|
0
|
|
|
|
|
return $drh->set_err($DBI::stderr, "Can't connect to $dr_dsn: $error") if $error; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my ($outer, $dbh)= DBI::_new_dbh($drh, { Name => $dr_dsn }); |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$dbh->STORE('Active', 1); |
71
|
0
|
|
|
|
|
|
$dbh->{cass_client}= $client; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return $outer; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub data_sources { |
77
|
0
|
|
|
0
|
0
|
|
my ($drh, $attr)= @_; |
78
|
0
|
|
|
|
|
|
my @array= (qw/dbi:Cassandra/); |
79
|
0
|
|
|
|
|
|
return @array; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
0
|
0
|
|
sub disconnect_all { |
83
|
|
|
|
|
|
|
# TODO: not needed? |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |