public
Description: StrokeDB is an embeddable distributed document database written in Ruby
Homepage: http://strokedb.com/
Clone URL: git://github.com/yrashk/strokedb.git
Minor master head naming improvement
yrashk (author)
Mon May 26 12:46:47 -0700 2008
commit  9894d45f5407283ecb19871d8fd56cdc305413df
tree    af808244a05de70c465c3a2f2d66513aa1657e29
parent  6593374d1e4c1d19d6082565a102d60e6e129f28
...
1
2
 
 
 
 
 
 
3
4
5
...
14
15
16
17
 
18
19
20
...
28
29
30
31
 
32
33
34
...
47
48
49
50
 
51
52
53
...
59
60
61
62
 
63
64
65
...
1
 
2
3
4
5
6
7
8
9
10
...
19
20
21
 
22
23
24
25
...
33
34
35
 
36
37
38
39
...
52
53
54
 
55
56
57
58
...
64
65
66
 
67
68
69
70
0
@@ -1,5 +1,10 @@
0
 module StrokeDB
0
-  RAW_HEAD_VERSION_UUID         = Util.sha1_uuid("strokedb-internal:head-version").to_raw_uuid
0
+  
0
+  def self.head(branch="master")
0
+    Util.sha1_uuid(branch).to_raw_uuid
0
+  end
0
+  
0
+  RAW_MASTER_HEAD_VERSION_UUID         = head()
0
 
0
   class FileStorage < Storage
0
 
0
@@ -14,7 +19,7 @@ module StrokeDB
0
 
0
     def find(uuid, version=nil, opts = {}, &block)
0
       uuid_version = uuid + (version ? ".#{version}" : "")
0
-      key = uuid.to_raw_uuid + (version ? version.to_raw_uuid : RAW_HEAD_VERSION_UUID)
0
+      key = uuid.to_raw_uuid + (version ? version.to_raw_uuid : RAW_MASTER_HEAD_VERSION_UUID)
0
       if (ptr = @uindex.find(key)) && (ptr[0,20] != "\x00" * 20) # no way ptr will be zero
0
         raw_doc = StrokeDB::deserialize(read_at_ptr(ptr[0,20]))
0
         unless opts[:no_instantiation]
0
@@ -28,7 +33,7 @@ module StrokeDB
0
     end
0
 
0
     def include?(uuid,version=nil)
0
-      key = uuid.to_raw_uuid + (version ? version.to_raw_uuid : RAW_HEAD_VERSION_UUID)
0
+      key = uuid.to_raw_uuid + (version ? version.to_raw_uuid : RAW_MASTER_HEAD_VERSION_UUID)
0
       !@uindex.find(key).nil?
0
     end
0
     
0
@@ -47,7 +52,7 @@ module StrokeDB
0
       @uindex.each do |key, value|
0
         timestamp = StrokeDB.deserialize(read_at_ptr(value[20,20]))
0
         next if after && (timestamp <= after)
0
-        if key[16,16] == RAW_HEAD_VERSION_UUID || include_versions
0
+        if key[16,16] == RAW_MASTER_HEAD_VERSION_UUID || include_versions
0
           yield Document.from_raw(options[:store],StrokeDB.deserialize(read_at_ptr(value[0,20])))
0
         end
0
       end
0
@@ -59,7 +64,7 @@ module StrokeDB
0
       ts_ptr = DistributedPointer.pack(@archive.raw_uuid,ts_position)
0
       ptr = DistributedPointer.pack(@archive.raw_uuid,position)
0
       uuid = document.raw_uuid
0
-      @uindex.insert(uuid + RAW_HEAD_VERSION_UUID, ptr + ts_ptr) if options[:head] || !document.is_a?(VersionedDocument)
0
+      @uindex.insert(uuid + RAW_MASTER_HEAD_VERSION_UUID, ptr + ts_ptr) if options[:head] || !document.is_a?(VersionedDocument)
0
       @uindex.insert(uuid + document.version.to_raw_uuid, ptr + ts_ptr) unless options[:head]
0
     rescue ArchiveVolume::VolumeCapacityExceeded   
0
       create_new_archive!

Comments