dbd 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4df1f0e326b407d9c2f0391a7ae7b0980a2deae
4
- data.tar.gz: a9724f1c990e1fdeaa3c3159ae059b26de4ddc4c
3
+ metadata.gz: a631ac1b673b24327126207b5898c6132a08f41f
4
+ data.tar.gz: 2abdda7d7da624dace39c486381130a813c28e92
5
5
  SHA512:
6
- metadata.gz: 391388832659492f0c00259140f97c1626820a0473373d5491ef9fb7e1fca6f1dd0badc3be4fca3bbbb2c567b52bdfa37bfef14bc1efe60f40beaa22813bc0ca
7
- data.tar.gz: ca0facecd89bca3dfffb24865b8cf14e4676582d8254fed22e26ca268738c61ffc35f4f3fc7b755c8b4e728779e14579a8ae99a91be6f17f306f3c10f2cf490e
6
+ metadata.gz: 03eac42ce2d9216371065f46a2ab8ab0dc19a88b9270f59cdcd50496d771dc4852fd30f471514028b00da6ed1de71787c8767388c697158e21b73e0e625b636a
7
+ data.tar.gz: 4baa8c0d598d1982442ee8c31a1e612939b5ae39c0167eb32eab25ebfa919c3a37523bb3a249a35f504d4bd67a08cdd65bdc76a2d9010846420ba7a3ab1fc265
@@ -90,4 +90,9 @@
90
90
  ======
91
91
 
92
92
  * in to_CSV the time_stamp now comes first (swapped with id)
93
- * this will allow file level 'sort' on the ISO dates
93
+ * this will allow file level 'sort' on the ISO dates
94
+
95
+ 0.0.15 (25 Aug 2013)
96
+ ======
97
+
98
+ * better exception message for an OutOfOrder exception
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Dbd: A data store that (almost) never forgets
2
2
 
3
- This is facts based data store, inspired by [RDF] concepts, but adding a log based structure and fine-grained provenance.
3
+ This is facts based data store, inspired by [RDF] concepts, but adding a
4
+ log based structure and fine-grained context (with provenance) for each fact.
5
+ I am building a simple demo application in [DbdDemo].
4
6
 
5
7
  * [Why?][Rationale]
6
8
  * <https://github.com/petervandenabeele/dbd>
@@ -150,7 +152,7 @@ This version also has input validation on the strings in the CSV. The time neede
150
152
  and memory size (RSS) for reading the file (and populating the in-memory dataset
151
153
  was):
152
154
 
153
- Read from CSV (to_CSV) 10 M facts (of 250 Bytes; 2.5 GB netto data):
155
+ Read from CSV (from_CSV) 10 M facts (of 250 Bytes; 2.5 GB netto data):
154
156
 
155
157
  | ruby | time | memory (RSS) |
156
158
  |------------|---------------|--------------:|
@@ -169,3 +171,4 @@ gsub with a regexp).
169
171
  [RDF]: http://www.w3.org/RDF/
170
172
  [Rationale]: http://github.com/petervandenabeele/dbd/blob/master/docs/rationale.md
171
173
  [MIT]: https://github.com/petervandenabeele/dbd/blob/master/LICENSE.txt
174
+ [DbdDemo]: https://github.com/petervandenabeele/dbd_demo#readme
@@ -32,15 +32,6 @@ module Dbd
32
32
  super
33
33
  end
34
34
 
35
- ##
36
- # Executes the required update in used_context_subjects.
37
- #
38
- # For a ContextFact, there is no context_subject, so
39
- # pointless to mark it in used_context_subjects hash.
40
- def update_used_context_subjects(h)
41
- # Do nothing (override the behaviour from super).
42
- end
43
-
44
35
  ##
45
36
  # Validates the presence or absence of context_subject.
46
37
  #
@@ -177,22 +177,6 @@ module Dbd
177
177
  "#{object.to_s.truncate_utf8(80).gsub(/\n/, '_')}"
178
178
  end
179
179
 
180
- ##
181
- # Executes the required update in used_context_subjects.
182
- #
183
- # For a Fact, pointing to a Context in it's context_subject,
184
- # marks this context_subject in the "used_context_subjects" hash that
185
- # is passed in as an argument (DCI). This will avoid further changes to the
186
- # Context with this context_subject.
187
- #
188
- # This is overridden in the ContextFact, since only relevant for a Fact.
189
- #
190
- # @param[Hash] :h the hash that contains the context_subject index
191
- def update_used_context_subjects(h)
192
- # using a context_subject sets the key
193
- h[context_subject] = true
194
- end
195
-
196
180
  ##
197
181
  # Checks if a fact has errors for storing in the graph.
198
182
  #
@@ -9,7 +9,6 @@ module Dbd
9
9
  def initialize
10
10
  super
11
11
  @hash_by_subject = Hash.new { |h, k| h[k] = [] }
12
- @used_context_subjects = {}
13
12
  end
14
13
 
15
14
  def newest_time_stamp
@@ -33,20 +32,14 @@ module Dbd
33
32
  #
34
33
  # Validates that added fact is newer.
35
34
  #
36
- # Validates that subject was never used as context_subject [A].
37
- #
38
35
  # Adds the fact and return the index in the collection.
39
36
  #
40
37
  # Store this index in the hash_by_subject.
41
- #
42
- # Mark the fact in the list of used context_subjects (for [A]).
43
38
  def <<(fact)
44
39
  raise FactError, "#{fact.errors.join(', ')}." unless fact.errors.empty?
45
- raise OutOfOrderError if (self.newest_time_stamp && fact.time_stamp <= self.newest_time_stamp)
46
- raise OutOfOrderError if (@used_context_subjects[fact.subject])
40
+ validate_time_stamp(fact)
47
41
  index = Helpers::OrderedSetCollection.add_and_return_index(fact, @internal_collection)
48
42
  @hash_by_subject[fact.subject] << index
49
- fact.update_used_context_subjects(@used_context_subjects)
50
43
  self
51
44
  end
52
45
 
@@ -54,6 +47,14 @@ module Dbd
54
47
  @hash_by_subject[fact_subject].map{ |index| @internal_collection[index]}
55
48
  end
56
49
 
50
+ private
51
+
52
+ def validate_time_stamp(fact)
53
+ if (newest_time_stamp && fact.time_stamp <= newest_time_stamp)
54
+ raise OutOfOrderError, "time_stamp of fact was too old : #{fact.time_stamp}"
55
+ end
56
+ end
57
+
57
58
  end
58
59
  end
59
60
  end
@@ -1,3 +1,3 @@
1
1
  module Dbd
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.15"
3
3
  end
@@ -52,14 +52,6 @@ module Dbd
52
52
  end
53
53
  end
54
54
 
55
- describe 'update_used_context_subjects' do
56
- it 'does nothing for a context_fact' do
57
- h = {}
58
- context_fact_1.update_used_context_subjects(h)
59
- h.should be_empty
60
- end
61
- end
62
-
63
55
  describe 'attributes and values' do
64
56
  it 'there are 6 attributes' do
65
57
  described_class.attributes.size.should == 6
@@ -110,12 +110,16 @@ module Dbd
110
110
  it 'adding an element with an older time_stamp fails' do
111
111
  fact_2_with_subject # will be older then fact_3_with_subject
112
112
  subject << fact_3_with_subject
113
- lambda { subject << fact_2_with_subject } . should raise_error OutOfOrderError
113
+ lambda{ subject << fact_2_with_subject }.should raise_error(
114
+ OutOfOrderError,
115
+ "time_stamp of fact was too old : #{fact_2_with_subject.time_stamp}")
114
116
  end
115
117
 
116
118
  it 'adding an element with an equal time_stamp fails' do
117
119
  subject << fact_2_with_subject
118
- lambda { subject << fact_2_with_subject } . should raise_error OutOfOrderError
120
+ lambda{ subject << fact_2_with_subject }.should raise_error(
121
+ OutOfOrderError,
122
+ "time_stamp of fact was too old : #{fact_2_with_subject.time_stamp}")
119
123
  end
120
124
  end
121
125
 
@@ -136,41 +140,6 @@ module Dbd
136
140
  end
137
141
  end
138
142
 
139
- describe 'context_facts must all come before first use by a fact' do
140
- it 'adding a context_fact, depending fact, another context_fact with same subject fail' do
141
- subject << context_fact_visibility
142
- subject << fact_2_with_subject
143
- lambda{ subject << context_fact_created_by }.should raise_error OutOfOrderError
144
- end
145
-
146
- # testing private functionality (kept temporarily as documentation)
147
- # A hash with all the context_subjects that are used by at least one fact.
148
- # Needed for the validation that no context_fact may be added that is
149
- # referred from a fact that is already in the fact stream.
150
- describe 'used_context_subjects' do
151
- # testing an internal variable ...
152
-
153
- let(:used_context_subjects) do
154
- subject.instance_variable_get(:@used_context_subjects)
155
- end
156
-
157
- it 'is empty initially' do
158
- used_context_subjects.should be_empty
159
- end
160
-
161
- it 'adding a context_fact alone does not create an entry' do
162
- subject << context_fact_visibility
163
- used_context_subjects.should be_empty
164
- end
165
-
166
- it 'adding a context_fact and a depending fact create an entry' do
167
- subject << context_fact_visibility
168
- subject << fact_2_with_subject
169
- used_context_subjects[context_subject_1].should == true
170
- end
171
- end
172
- end
173
-
174
143
  describe 'validate that facts do not have errors when loading in the Fact::Collection' do
175
144
  it 'succeeds with a fact from factory' do
176
145
  subject << fact_2_with_subject # should_not raise_error
@@ -74,13 +74,5 @@ module Dbd
74
74
  end
75
75
  end
76
76
  end
77
-
78
- describe 'update_used_context_subjects' do
79
- it 'sets the value for context_subject to true for a fact' do
80
- h = {}
81
- fact_1.update_used_context_subjects(h)
82
- h[fact_1.context_subject].should == true
83
- end
84
- end
85
77
  end
86
78
  end
@@ -89,5 +89,14 @@ module Dbd
89
89
  graph_from_CSV.first.should be_equivalent(graph.first)
90
90
  end
91
91
  end
92
+
93
+ describe 'error handling' do
94
+ it 'gives better description on incorrect fact size' do
95
+ #TODO present a nicer error (check the amount of entries in a CSV input line)
96
+ csv = 'foo, bar'
97
+ lambda { described_class.new.from_CSV(csv) }.should raise_error IndexError
98
+ end
99
+
100
+ end
92
101
  end
93
102
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Vandenabeele
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-09 00:00:00.000000000 Z
11
+ date: 2013-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler