/[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.9 - (show annotations) (download)
Mon Sep 21 09:10:40 2009 UTC (15 years, 7 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +3 -0 lines
Error occurred while calculating annotation data.
++ swe/lib/SWE/DB/ChangeLog	21 Sep 2009 09:05:45 -0000
2009-09-21  Wakaba  <wakaba@suika.fam.cx>

	* Lock.pm (check_lockability): Don't allow the same level of lock
	type being locked twice to avoid deadlocks caused by same level of
	locks.

++ swe/lib/SWE/Object/ChangeLog	21 Sep 2009 09:10:06 -0000
	* Document.pm (repo, prop_untainted, untainted_prop, save_prop,
	locked): New method.  Introduced the concept of "tainted" such
	that we can access to the property in the locked code fragment
	without being afraid to update the property using old values.
	(get_or_create_graph_node): Updated to utilize |prop| family of
	method with locks.

	* Graph.pm (repo, lock, unlock): New methods.
	(add_nodes, create_node, schelling_update): Locks the database
	before the modifications.

	* Repository.pm (graph, get_document_by_id): New methods.

	* Node.pm (repo): New method.

2009-09-21  Wakaba  <wakaba@suika.fam.cx>

++ swe/lib/suikawiki/ChangeLog	21 Sep 2009 09:10:27 -0000
	* main.pl: Made the graph node view to lock the database.

2009-09-21  Wakaba  <wakaba@suika.fam.cx>

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 sub db_dir_name : lvalue { $_[0]->{db_dir_name} }
11 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
15 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 sub sw3db_dir_name : lvalue { $_[0]->{sw3db_dir_name} }
26
27 sub global_prop ($) {
28 my $self = shift;
29
30 ## Lock types:
31 ## - Graph: lastnodeindex, doconnodenumber
32
33 return $self->{global_prop} ||= do {
34 require SWE::DB::NamedText;
35 my $global_prop_db = SWE::DB::NamedText->new;
36 $global_prop_db->{root_directory_name} = $self->global_dir_name;
37 $global_prop_db->{leaf_suffix} = '.dat';
38 $global_prop_db;
39 };
40 } # global_prop
41
42 sub name_inverted_index ($) {
43 my $self = shift;
44
45 return $self->{name_inverted_index} ||= do {
46 require SWE::DB::HashedIndex;
47 my $names_index_db = SWE::DB::HashedIndex->new;
48 $names_index_db->{root_directory_name} = $self->name_dir_name;
49 $names_index_db;
50 };
51 } # name_inverted_index
52
53 sub name_history ($) {
54 my $self = shift;
55
56 return $self->{name_history} ||= do {
57 require SWE::DB::HashedHistory;
58 my $names_history_db = SWE::DB::HashedHistory->new;
59 $names_history_db->{root_directory_name} = $self->name_dir_name;
60 $names_history_db;
61 };
62 } # name_history
63
64 sub id ($) {
65 my $self = shift;
66
67 return $self->{id} ||= do {
68 require SWE::DB::IDGenerator;
69 my $idgen = SWE::DB::IDGenerator->new;
70 $idgen->{file_name} = $self->db_dir_name . 'nextid.dat';
71 $idgen->{lock_file_name} = $self->global_lock_dir_name . 'nextid.lock';
72 $idgen;
73 };
74 } # id
75
76 sub id_lock ($) {
77 my $self = shift;
78
79 return $self->{id_lock} ||= do {
80 require SWE::DB::IDLocks;
81 my $id_locks = SWE::DB::IDLocks->new;
82 $id_locks->{root_directory_name} = $self->id_dir_name;
83 $id_locks->{leaf_suffix} = '.lock';
84 $id_locks;
85 };
86 } # id_lock
87
88 sub id_prop ($) {
89 my $self = shift;
90
91 return $self->{id_prop} ||= do {
92 require SWE::DB::IDProps;
93 my $id_prop_db = SWE::DB::IDProps->new;
94 $id_prop_db->{root_directory_name} = $self->id_dir_name;
95 $id_prop_db->{leaf_suffix} = '.props';
96 $id_prop_db;
97 };
98 } # id_prop
99
100 sub id_tfidf ($) {
101 my $self = shift;
102
103 return $self->{id_tfidf} ||= do {
104 require SWE::DB::IDText;
105 my $tfidf_db = SWE::DB::IDText->new;
106 $tfidf_db->{root_directory_name} = $self->id_dir_name;
107 $tfidf_db->{leaf_suffix} = '.tfidf';
108 $tfidf_db;
109 };
110 } # id_tfidf
111
112 sub id_history ($) {
113 my $self = shift;
114
115 return $self->{id_history} ||= do {
116 require SWE::DB::IDHistory;
117 my $id_history_db = SWE::DB::IDHistory->new;
118 $id_history_db->{root_directory_name} = $self->id_dir_name;
119 $id_history_db;
120 };
121 } # id_history
122
123 sub id_html_cache ($) {
124 my $self = shift;
125
126 return $self->{id_html_cache} ||= do {
127 require SWE::DB::IDDOM;
128 my $html_cache_db = SWE::DB::IDDOM->new;
129 $html_cache_db->{root_directory_name} = $self->id_dir_name;
130 $html_cache_db->{leaf_suffix} = '.htmlcache';
131 $html_cache_db;
132 };
133 } # id_html_cache
134
135 sub graph_prop ($) {
136 my $self = shift;
137
138 return $self->{graph_prop} ||= do {
139 require SWE::DB::IDProps;
140 my $graph_prop_db = SWE::DB::IDProps->new;
141 $graph_prop_db->{root_directory_name} = $self->graph_dir_name;
142 $graph_prop_db->{leaf_suffix} = '.node';
143 $graph_prop_db;
144 };
145 } # graph_prop
146
147 sub vc ($) {
148 my $self = shift;
149
150 require SWE::DB::VersionControl;
151 return SWE::DB::VersionControl->new;
152 } # vc
153
154 1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24