/[suikacvs]/webroot/swe/lib/SWE/DB.pm
Suika

Contents of /webroot/swe/lib/SWE/DB.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Sun Mar 15 12:27:37 2009 UTC (17 years ago) by wakaba
Branch: MAIN
Changes since 1.2: +34 -0 lines
++ swe/lib/SWE/ChangeLog	15 Mar 2009 12:26:50 -0000
	* DB.pm: Added graph and global property databases.

2009-03-15  Wakaba  <wakaba@suika.fam.cx>

++ swe/lib/SWE/Object/ChangeLog	15 Mar 2009 12:26:27 -0000
	* Graph.pm: New module.

2009-03-15  Wakaba  <wakaba@suika.fam.cx>

++ swe/lib/suikawiki/ChangeLog	15 Mar 2009 12:27:26 -0000
	* main.pl: Graph generation moved to another module.  Implemented
	graph/document association.

2009-03-15  Wakaba  <wakaba@suika.fam.cx>

1 wakaba 1.1 package SWE::DB;
2     use strict;
3     use warnings;
4    
5     sub new ($) {
6     my $self = bless {}, shift;
7     return $self;
8     } # new
9    
10 wakaba 1.2 sub db_dir_name : lvalue { $_[0]->{db_dir_name} }
11 wakaba 1.1 sub global_lock_dir_name : lvalue { $_[0]->{global_lock_dir_name} }
12     sub id_dir_name : lvalue { $_[0]->{id_dir_name} }
13     sub name_dir_name : lvalue { $_[0]->{name_dir_name} }
14 wakaba 1.2
15 wakaba 1.3 sub graph_dir_name ($) {
16     my $self = shift;
17     return $self->db_dir_name . q[graph/];
18     } # graph_dir_name
19    
20     sub global_dir_name ($) {
21     my $self = shift;
22     return $self->db_dir_name . q[global/];
23     } # global_dir_name
24    
25 wakaba 1.2 sub sw3db_dir_name : lvalue { $_[0]->{sw3db_dir_name} }
26    
27 wakaba 1.3 sub global_prop ($) {
28     my $self = shift;
29    
30     return $self->{global_prop} ||= do {
31     require SWE::DB::NamedText;
32     my $global_prop_db = SWE::DB::NamedText->new;
33     $global_prop_db->{root_directory_name} = $self->global_dir_name;
34     $global_prop_db->{leaf_suffix} = '.dat';
35     $global_prop_db;
36     };
37     } # global_prop
38    
39 wakaba 1.2 sub id ($) {
40     my $self = shift;
41    
42     return $self->{id} ||= do {
43     require SWE::DB::IDGenerator;
44     my $idgen = SWE::DB::IDGenerator->new;
45     $idgen->{file_name} = $self->db_dir_name . 'nextid.dat';
46     $idgen->{lock_file_name} = $self->global_lock_dir_name . 'nextid.lock';
47     $idgen;
48     };
49     } # id
50 wakaba 1.1
51     sub name_inverted_index ($) {
52     my $self = shift;
53    
54     return $self->{name_inverted_index} ||= do {
55     require SWE::DB::HashedIndex;
56     my $names_index_db = SWE::DB::HashedIndex->new;
57     $names_index_db->{root_directory_name} = $self->name_dir_name;
58     $names_index_db;
59     };
60     } # name_inverted_index
61    
62     sub id_tfidf ($) {
63     my $self = shift;
64    
65     return $self->{id_tfidf} ||= do {
66     require SWE::DB::IDText;
67     my $tfidf_db = SWE::DB::IDText->new;
68     $tfidf_db->{root_directory_name} = $self->id_dir_name;
69     $tfidf_db->{leaf_suffix} = '.tfidf';
70     $tfidf_db;
71     };
72     } # id_tfidf
73 wakaba 1.3
74     sub graph_prop ($) {
75     my $self = shift;
76    
77     return $self->{graph_prop} ||= do {
78     require SWE::DB::IDProps;
79     my $graph_prop_db = SWE::DB::IDProps->new;
80     $graph_prop_db->{root_directory_name} = $self->graph_dir_name;
81     $graph_prop_db->{leaf_suffix} = '.node';
82     $graph_prop_db;
83     };
84     } # graph_prop
85 wakaba 1.1
86     1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24