line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Copyright (c) 2004-2006 IBM Corporation. |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# All rights reserved. This program and the accompanying materials |
5
|
|
|
|
|
|
|
# are made available under the terms of the Eclipse Public License v1.0 |
6
|
|
|
|
|
|
|
# which accompanies this distribution, and is available at |
7
|
|
|
|
|
|
|
# http://www.eclipse.org/legal/epl-v10.html |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# File: $Source: /var/lib/cvs/ODO/lib/ODO/Graph/Storage/Memory.pm,v $ |
10
|
|
|
|
|
|
|
# Created by: Stephen Evanchik( evanchik@us.ibm.com ) |
11
|
|
|
|
|
|
|
# Created on: 12/22/2004 |
12
|
|
|
|
|
|
|
# Revision: $Id: Memory.pm,v 1.4 2010-02-17 17:17:09 ubuntu Exp $ |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Contributors: |
15
|
|
|
|
|
|
|
# IBM Corporation - initial API and implementation |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
package ODO::Graph::Storage::Memory; |
18
|
|
|
|
|
|
|
|
19
|
5
|
|
|
5
|
|
22125
|
use strict; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
192
|
|
20
|
5
|
|
|
5
|
|
27
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
195
|
|
21
|
|
|
|
|
|
|
|
22
|
5
|
|
|
5
|
|
32
|
use ODO::Exception; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
250
|
|
23
|
5
|
|
|
5
|
|
31
|
use ODO::Statement; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
215
|
|
24
|
5
|
|
|
5
|
|
778
|
use ODO::Query::Simple; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
226
|
|
25
|
5
|
|
|
5
|
|
3241
|
use ODO::Query::Simple::Result; |
|
5
|
|
|
|
|
59
|
|
|
5
|
|
|
|
|
228
|
|
26
|
|
|
|
|
|
|
|
27
|
5
|
|
|
5
|
|
725
|
use ODO::Query::RDQL::Parser; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
213
|
|
28
|
5
|
|
|
5
|
|
2626
|
use ODO::Query::RDQL::DefaultHandler; |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
276
|
|
29
|
|
|
|
|
|
|
|
30
|
5
|
|
|
5
|
|
29
|
use base qw/ODO::Graph::Storage/; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
3180
|
|
31
|
|
|
|
|
|
|
|
32
|
5
|
|
|
5
|
|
30
|
use vars qw /$VERSION/; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
3460
|
|
33
|
|
|
|
|
|
|
$VERSION = sprintf "%d.%02d", q$Revision: 1.4 $ =~ /: (\d+)\.(\d+)/; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw/subjects predicates objects statements/); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
ODO::Graph::Storage::Memory - Memory backed storage for graphs. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 DESCRIPTION |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Description. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 METHODS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=over |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item add( ) |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub add { |
54
|
16
|
|
|
16
|
1
|
24
|
my ($self, $statements) = @_; |
55
|
16
|
|
|
|
|
24
|
foreach my $stmt (@{ $statements }) { |
|
16
|
|
|
|
|
33
|
|
56
|
23
|
100
|
|
|
|
89
|
$self->{'statement_count'}++ |
57
|
|
|
|
|
|
|
if(!exists($self->{'statements'}->{ $stmt->hash() })); |
58
|
|
|
|
|
|
|
|
59
|
23
|
|
|
|
|
69
|
$self->{'statements'}->{ $stmt->hash() } = $stmt; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
16
|
|
|
|
|
66
|
return $self; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item remove( ) |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub remove { |
71
|
1
|
|
|
1
|
1
|
3
|
my ($self, $statements) = @_; |
72
|
1
|
|
|
|
|
2
|
foreach my $stmt (@{ $statements }) { |
|
1
|
|
|
|
|
3
|
|
73
|
1
|
|
|
|
|
5
|
delete($self->{'statements'}->{ $stmt->hash() }); |
74
|
1
|
|
|
|
|
3
|
$self->{'statement_count'}--; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
5
|
return $self; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item size( ) |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub size { |
86
|
3
|
|
|
3
|
1
|
4
|
my $self = shift; |
87
|
3
|
|
|
|
|
17
|
return $self->{'statement_count'}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item clear( ) |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub clear { |
96
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
97
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
3
|
$self->{'subjects'} = {}; |
99
|
1
|
|
|
|
|
3
|
$self->{'predicates'} = {}; |
100
|
1
|
|
|
|
|
2
|
$self->{'objects'} = {}; |
101
|
|
|
|
|
|
|
|
102
|
1
|
|
|
|
|
2
|
$self->{'statements'} = {}; |
103
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
4
|
$self->{'statement_count'} = 0; |
105
|
|
|
|
|
|
|
|
106
|
1
|
|
|
|
|
3
|
return $self; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item issue_query( $query, \%query_options ) |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub issue_query { |
115
|
130
|
|
|
130
|
1
|
177
|
my ($self, $query, $query_options) = @_; |
116
|
|
|
|
|
|
|
|
117
|
130
|
50
|
|
|
|
629
|
return $self->issue_simple_query($query) |
118
|
|
|
|
|
|
|
if($query->isa('ODO::Query::Simple')); |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
0
|
my $query_lang = 'RDQL'; |
121
|
0
|
0
|
|
|
|
0
|
if(UNIVERSAL::isa($query_options, 'HASH')) { |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
0
|
my $rdql_query = ODO::Query::RDQL::Parser->parse($query); |
125
|
|
|
|
|
|
|
return |
126
|
0
|
0
|
|
|
|
0
|
ODO::Query::Simple::Result->new(source_graph=> $self->parent_graph(), query=> ODO::Query::RDQL->new(), results=> []) |
127
|
|
|
|
|
|
|
unless defined $rdql_query; |
128
|
0
|
|
|
|
|
0
|
my $result_graph = ODO::Query::RDQL::DefaultHandler->new(data => $self->parent_graph(), query_object => $rdql_query)->evaluate_query(); |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
0
|
my $statements = $result_graph->query($ODO::Query::Simple::ALL_STATEMENTS)->results(); |
131
|
0
|
|
|
|
|
0
|
return ODO::Query::Simple::Result->new(source_graph=> $self->parent_graph(), query=> $rdql_query, results=> $statements); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item issue_simple_query( $query ) |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub issue_simple_query { |
140
|
130
|
|
|
130
|
1
|
186
|
my ($self, $query) = @_; |
141
|
|
|
|
|
|
|
|
142
|
130
|
|
|
|
|
165
|
my $statements = []; |
143
|
|
|
|
|
|
|
|
144
|
130
|
|
|
|
|
182
|
foreach my $stmt (values(%{ $self->{'statements'} })) { |
|
130
|
|
|
|
|
395
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
next |
147
|
986
|
100
|
|
|
|
2460
|
unless($query->equal($stmt)); |
148
|
|
|
|
|
|
|
|
149
|
32
|
|
|
|
|
83
|
push @{ $statements }, $stmt |
|
32
|
|
|
|
|
75
|
|
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
130
|
|
|
|
|
434
|
return ODO::Query::Simple::Result->new(source_graph=> $self->parent_graph(), query=> $query, results=> $statements); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub init { |
157
|
8
|
|
|
8
|
1
|
181
|
my ($self, $config) = @_; |
158
|
8
|
|
|
|
|
46
|
$self = $self->SUPER::init($config); |
159
|
|
|
|
|
|
|
|
160
|
8
|
|
|
|
|
22
|
$self->{'statement_count'} = 0; |
161
|
|
|
|
|
|
|
|
162
|
8
|
|
|
|
|
18
|
$self->{'subjects'} = {}; |
163
|
8
|
|
|
|
|
16
|
$self->{'predicates'} = {}; |
164
|
8
|
|
|
|
|
29
|
$self->{'objects'} = {}; |
165
|
|
|
|
|
|
|
|
166
|
8
|
|
|
|
|
17
|
$self->{'statements'} = {}; |
167
|
|
|
|
|
|
|
|
168
|
8
|
|
|
|
|
20
|
return $self; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=back |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 COPYRIGHT |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Copyright (c) 2005-2006 IBM Corporation. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
All rights reserved. This program and the accompanying materials |
179
|
|
|
|
|
|
|
are made available under the terms of the Eclipse Public License v1.0 |
180
|
|
|
|
|
|
|
which accompanies this distribution, and is available at |
181
|
|
|
|
|
|
|
http://www.eclipse.org/legal/epl-v10.html |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=cut |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
1; |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
__END__ |