| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CogBase::Connection; |
|
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
47
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
46
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use CogBase::Base -base; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
13
|
|
|
5
|
1
|
|
|
1
|
|
521
|
use CogBase::Factory; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
11
|
|
|
6
|
1
|
|
|
1
|
|
772
|
use CogBase::Index; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
field 'db_location'; |
|
9
|
|
|
|
|
|
|
field factory => -init => |
|
10
|
|
|
|
|
|
|
'CogBase::Factory->New(connection => $self)'; |
|
11
|
|
|
|
|
|
|
field index => -init => |
|
12
|
|
|
|
|
|
|
'CogBase::Index->New(connection => $self)'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub connection { |
|
15
|
1
|
|
|
1
|
0
|
4
|
my ($class, $location) = @_; |
|
16
|
1
|
50
|
|
|
|
31
|
my $connection_class = |
|
|
|
50
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$location =~ m!^https?://! |
|
18
|
|
|
|
|
|
|
? 'CogBase::Connection::HTTP' |
|
19
|
|
|
|
|
|
|
: -d $location |
|
20
|
|
|
|
|
|
|
? 'CogBase::Connection::FileSystem' |
|
21
|
|
|
|
|
|
|
: die "'$location' is an invalid CogBase location"; |
|
22
|
1
|
50
|
|
|
|
14
|
unless ($connection_class->can('New')) { |
|
23
|
1
|
50
|
|
|
|
57
|
eval "require $connection_class; 1" |
|
24
|
|
|
|
|
|
|
or die $@; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
1
|
|
|
|
|
12
|
return $connection_class->New(db_location => $location); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub node { |
|
30
|
2
|
|
|
2
|
0
|
21
|
my ($self, $type) = @_; |
|
31
|
2
|
|
|
|
|
68
|
return $self->factory->new_node($type); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub fetch { |
|
35
|
0
|
|
|
0
|
0
|
0
|
my ($self, @nodes) = @_; |
|
36
|
0
|
|
|
|
|
0
|
my @result; |
|
37
|
0
|
|
|
|
|
0
|
for my $node (@nodes) { |
|
38
|
0
|
0
|
|
|
|
0
|
$node = CogBase::Node->New(Id => $node) |
|
39
|
|
|
|
|
|
|
unless ref $node; |
|
40
|
0
|
|
|
|
|
0
|
$self->fetch_node($node); |
|
41
|
0
|
|
|
|
|
0
|
push @result, $node; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
0
|
|
|
|
|
0
|
return @result; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub store { |
|
47
|
1
|
|
|
1
|
0
|
51
|
my ($self, @nodes) = @_; |
|
48
|
1
|
|
|
|
|
4
|
for my $node (@nodes) { |
|
49
|
1
|
|
|
|
|
10
|
$self->store_node($node); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
1
|
|
|
|
|
299
|
return; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub disconnect { |
|
55
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
56
|
0
|
|
|
|
|
0
|
bless $self, ref($self) . '::disconnected'; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub fetchSchemaNode { |
|
60
|
1
|
|
|
1
|
0
|
24
|
my ($self, $type) = @_; |
|
61
|
1
|
50
|
|
|
|
7
|
my ($id) = $self->query("!Schema") |
|
62
|
|
|
|
|
|
|
or return; |
|
63
|
0
|
|
|
|
|
|
my $node = CogBase::Node->New( |
|
64
|
|
|
|
|
|
|
Id => $id, |
|
65
|
|
|
|
|
|
|
Type => 'Schema', |
|
66
|
|
|
|
|
|
|
); |
|
67
|
0
|
|
|
|
|
|
$self->fetch($node); |
|
68
|
0
|
|
|
|
|
|
return $node; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |