nose 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/nose/cost.rb +7 -7
- data/lib/nose/model/entity.rb +1 -1
- data/lib/nose/model/fields.rb +19 -8
- data/lib/nose/plans.rb +1 -1
- data/lib/nose/plans/execution_plan.rb +1 -1
- data/lib/nose/plans/query_planner.rb +1 -1
- data/lib/nose/plans/update_planner.rb +3 -3
- data/lib/nose/random.rb +2 -2
- data/lib/nose/serialize.rb +2 -2
- data/lib/nose/util.rb +1 -1
- data/models/eac.rb +3 -3
- data/models/ebay.rb +2 -2
- data/models/rubis.rb +10 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4104b913e3d80c2b02480929ab4689cf58fa16801214e064c8e6fb5562507997
|
4
|
+
data.tar.gz: 65da94fc536524e82c9d0b6c5f0b21dbb09ec9ce54a8735b8368c1afde0e2df3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b763ec409386c46522e090e8e9466dbb5e32b9b01f5bea23e20b6c6a739dd0a89ff91fa5b2cbae1d3719a5a90eba1b7975517e5851106eb1891ec8a722d5dce9
|
7
|
+
data.tar.gz: 39a4647647c7df4cd5db4f58a74e3aa1ba5691ae069d1788844b419d20c6c7276448408c89902203ebaf2c0ddb4ca73303153c3c041dd4375f58b0d8c63b26fb
|
data/lib/nose/cost.rb
CHANGED
@@ -13,7 +13,7 @@ module NoSE
|
|
13
13
|
end
|
14
14
|
|
15
15
|
# The cost of filtering intermediate results
|
16
|
-
# @return [
|
16
|
+
# @return [Integer]
|
17
17
|
def filter_cost(_step)
|
18
18
|
# Assume this has no cost and the cost is captured in the fact that we
|
19
19
|
# have to retrieve more data earlier. All this does is skip records.
|
@@ -21,14 +21,14 @@ module NoSE
|
|
21
21
|
end
|
22
22
|
|
23
23
|
# The cost of limiting a result set
|
24
|
-
# @return [
|
24
|
+
# @return [Integer]
|
25
25
|
def limit_cost(_step)
|
26
26
|
# This is basically free since we just discard data
|
27
27
|
0
|
28
28
|
end
|
29
29
|
|
30
30
|
# The cost of sorting a set of results
|
31
|
-
# @return [
|
31
|
+
# @return [Integer]
|
32
32
|
def sort_cost(_step)
|
33
33
|
# TODO: Find some estimate of sort cost
|
34
34
|
# This could be partially captured by the fact that sort + limit
|
@@ -37,25 +37,25 @@ module NoSE
|
|
37
37
|
end
|
38
38
|
|
39
39
|
# The cost of performing a lookup via an index
|
40
|
-
# @return [
|
40
|
+
# @return [Integer]
|
41
41
|
def index_lookup_cost(_step)
|
42
42
|
fail NotImplementedError, 'Must be implemented in a subclass'
|
43
43
|
end
|
44
44
|
|
45
45
|
# The cost of performing a deletion from an index
|
46
|
-
# @return [
|
46
|
+
# @return [Integer]
|
47
47
|
def delete_cost(_step)
|
48
48
|
fail NotImplementedError, 'Must be implemented in a subclass'
|
49
49
|
end
|
50
50
|
|
51
51
|
# The cost of performing an insert into an index
|
52
|
-
# @return [
|
52
|
+
# @return [Integer]
|
53
53
|
def insert_cost(_step)
|
54
54
|
fail NotImplementedError, 'Must be implemented in a subclass'
|
55
55
|
end
|
56
56
|
|
57
57
|
# This is here for debugging purposes because we need a cost
|
58
|
-
# @return [
|
58
|
+
# @return [Integer]
|
59
59
|
def pruned_cost(_step)
|
60
60
|
0
|
61
61
|
end
|
data/lib/nose/model/entity.rb
CHANGED
data/lib/nose/model/fields.rb
CHANGED
@@ -34,7 +34,7 @@ module NoSE
|
|
34
34
|
alias eql? ==
|
35
35
|
|
36
36
|
# Hash by entity and name
|
37
|
-
# @return [
|
37
|
+
# @return [Integer]
|
38
38
|
def hash
|
39
39
|
@hash ||= id.hash
|
40
40
|
end
|
@@ -104,8 +104,20 @@ module NoSE
|
|
104
104
|
method_name = child_class.name.sub(method_regex, '\1')
|
105
105
|
EntityDSL.send :define_method, method_name,
|
106
106
|
(proc do |*args|
|
107
|
-
send
|
108
|
-
|
107
|
+
entity = send :instance_variable_get, :@entity
|
108
|
+
|
109
|
+
# XXX This is necessary since passing a hash of
|
110
|
+
# keyword arguments as the last argument is
|
111
|
+
# now deprecated
|
112
|
+
if args.last.is_a? Hash
|
113
|
+
hash_args = args.last
|
114
|
+
args.pop
|
115
|
+
else
|
116
|
+
hash_args = {}
|
117
|
+
end
|
118
|
+
|
119
|
+
field = child_class.new(*args, **hash_args)
|
120
|
+
entity.send :<<, field
|
109
121
|
end)
|
110
122
|
end
|
111
123
|
private_class_method :add_field_method
|
@@ -122,13 +134,13 @@ module NoSE
|
|
122
134
|
end
|
123
135
|
|
124
136
|
# Parse an Integer from the provided parameter
|
125
|
-
# @return [
|
137
|
+
# @return [Integer]
|
126
138
|
def self.value_from_string(string)
|
127
139
|
string.to_i
|
128
140
|
end
|
129
141
|
|
130
142
|
# Random numbers up to the given size
|
131
|
-
# @return [
|
143
|
+
# @return [Integer]
|
132
144
|
def random_value
|
133
145
|
rand(@cardinality)
|
134
146
|
end
|
@@ -167,8 +179,7 @@ module NoSE
|
|
167
179
|
|
168
180
|
# Field holding a float
|
169
181
|
class FloatField < Field
|
170
|
-
|
171
|
-
TYPE = Fixnum
|
182
|
+
TYPE = Float
|
172
183
|
|
173
184
|
def initialize(name, **options)
|
174
185
|
super(name, 8, **options)
|
@@ -284,7 +295,7 @@ module NoSE
|
|
284
295
|
|
285
296
|
# The number of entities associated with the foreign key,
|
286
297
|
# or a manually set cardinality
|
287
|
-
# @return [
|
298
|
+
# @return [Integer]
|
288
299
|
def cardinality
|
289
300
|
@entity.count || super
|
290
301
|
end
|
data/lib/nose/plans.rb
CHANGED
@@ -50,7 +50,7 @@ module NoSE
|
|
50
50
|
end
|
51
51
|
|
52
52
|
# The weight of this query for a given workload
|
53
|
-
# @return [
|
53
|
+
# @return [Integer]
|
54
54
|
def weight
|
55
55
|
return 1 if @workload.nil?
|
56
56
|
|
@@ -145,13 +145,13 @@ module NoSE
|
|
145
145
|
end
|
146
146
|
|
147
147
|
# The cost of performing the update on this index
|
148
|
-
# @return [
|
148
|
+
# @return [Integer]
|
149
149
|
def update_cost
|
150
150
|
@update_steps.sum_by(&:cost)
|
151
151
|
end
|
152
152
|
|
153
153
|
# The cost is the sum of all the query costs plus the update costs
|
154
|
-
# @return [
|
154
|
+
# @return [Integer]
|
155
155
|
def cost
|
156
156
|
@query_plans.sum_by(&:cost) + update_cost
|
157
157
|
end
|
data/lib/nose/random.rb
CHANGED
@@ -353,7 +353,7 @@ module NoSE
|
|
353
353
|
end
|
354
354
|
|
355
355
|
# Return the next valid random number
|
356
|
-
# @return [
|
356
|
+
# @return [Integer]
|
357
357
|
def rand
|
358
358
|
if @valid
|
359
359
|
@valid = false
|
@@ -367,7 +367,7 @@ module NoSE
|
|
367
367
|
end
|
368
368
|
|
369
369
|
# Return a random number for the given distribution
|
370
|
-
# @return [Array<
|
370
|
+
# @return [Array<Integer>]
|
371
371
|
def self.gaussian(mean, stddev)
|
372
372
|
theta = 2 * Math::PI * rand
|
373
373
|
rho = Math.sqrt(-2 * Math.log(1 - rand))
|
data/lib/nose/serialize.rb
CHANGED
@@ -251,7 +251,7 @@ module NoSE
|
|
251
251
|
property :cardinality, exec_context: :decorator
|
252
252
|
|
253
253
|
# The estimated hash cardinality at this step in the plan
|
254
|
-
# @return [
|
254
|
+
# @return [Integer]
|
255
255
|
def hash_cardinality
|
256
256
|
state = represented.instance_variable_get(:@state)
|
257
257
|
state.hash_cardinality if state.is_a?(Plans::QueryState)
|
@@ -326,7 +326,7 @@ module NoSE
|
|
326
326
|
property :type, exec_context: :decorator
|
327
327
|
|
328
328
|
# The estimated cardinality of entities being updated
|
329
|
-
# @return [
|
329
|
+
# @return [Integer]
|
330
330
|
def cardinality
|
331
331
|
state = represented.instance_variable_get(:@state)
|
332
332
|
state.cardinality unless state.nil?
|
data/lib/nose/util.rb
CHANGED
@@ -166,7 +166,7 @@ end
|
|
166
166
|
# Simple helper class to facilitate cardinality estimates
|
167
167
|
class Cardinality
|
168
168
|
# Update the cardinality based on filtering implicit to the index
|
169
|
-
# @return [
|
169
|
+
# @return [Integer]
|
170
170
|
def self.filter(cardinality, eq_filter, range_filter)
|
171
171
|
filtered = (range_filter.nil? ? 1.0 : 0.1) * cardinality
|
172
172
|
filtered *= eq_filter.map do |field|
|
data/models/eac.rb
CHANGED
@@ -34,11 +34,11 @@ NoSE::Model.new do
|
|
34
34
|
end) * 5_000
|
35
35
|
|
36
36
|
HasOne 'player', 'sessions',
|
37
|
-
'Session' => 'Player'
|
37
|
+
{'Session' => 'Player'}
|
38
38
|
|
39
39
|
HasOne 'server', 'sessions',
|
40
|
-
'Session' => 'Server'
|
40
|
+
{'Session' => 'Server'}
|
41
41
|
|
42
42
|
HasOne 'session', 'states',
|
43
|
-
'PlayerState' => 'Session'
|
43
|
+
{'PlayerState' => 'Session'}
|
44
44
|
end
|
data/models/ebay.rb
CHANGED
data/models/rubis.rb
CHANGED
@@ -64,34 +64,34 @@ NoSE::Model.new do
|
|
64
64
|
end) * 40_000
|
65
65
|
|
66
66
|
HasOne 'region', 'users',
|
67
|
-
'users' => 'regions'
|
67
|
+
{'users' => 'regions'}
|
68
68
|
|
69
69
|
HasOne 'seller', 'items_sold',
|
70
|
-
'items' => 'users'
|
70
|
+
{'items' => 'users'}
|
71
71
|
|
72
72
|
HasOne 'category', 'items',
|
73
|
-
'items' => 'categories'
|
73
|
+
{'items' => 'categories'}
|
74
74
|
|
75
75
|
HasOne 'user', 'bids',
|
76
|
-
'bids' => 'users'
|
76
|
+
{'bids' => 'users'}
|
77
77
|
|
78
78
|
HasOne 'item', 'bids',
|
79
|
-
'bids' => 'items'
|
79
|
+
{'bids' => 'items'}
|
80
80
|
|
81
81
|
HasOne 'from_user', 'comments_sent',
|
82
|
-
'comments' => 'users'
|
82
|
+
{'comments' => 'users'}
|
83
83
|
|
84
84
|
HasOne 'to_user', 'comments_received',
|
85
|
-
'comments' => 'users'
|
85
|
+
{'comments' => 'users'}
|
86
86
|
|
87
87
|
HasOne 'item', 'comments',
|
88
|
-
'comments' => 'items'
|
88
|
+
{'comments' => 'items'}
|
89
89
|
|
90
90
|
HasOne 'buyer', 'bought_now',
|
91
|
-
'buynow' => 'users'
|
91
|
+
{'buynow' => 'users'}
|
92
92
|
|
93
93
|
HasOne 'item', 'bought_now',
|
94
|
-
'buynow' => 'items'
|
94
|
+
{'buynow' => 'items'}
|
95
95
|
end
|
96
96
|
|
97
97
|
# rubocop:enable all
|