nose 0.1.3 → 0.1.4

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
  SHA256:
3
- metadata.gz: fdab6ac0cd36aff76527e1581daa256c7078b99aca5221d0744b9c0d8ab0fd7e
4
- data.tar.gz: 3972ad33202958c29b58fd26863f485a25526fe5369c82e47f8555b89d638cc6
3
+ metadata.gz: 4104b913e3d80c2b02480929ab4689cf58fa16801214e064c8e6fb5562507997
4
+ data.tar.gz: 65da94fc536524e82c9d0b6c5f0b21dbb09ec9ce54a8735b8368c1afde0e2df3
5
5
  SHA512:
6
- metadata.gz: 9d21c1fbf046dfc271d232213b1d870b714182ccbd251976587d54f6024da5e88aba65ef7a891d6ab0b6e01af33d82f0e30da0d41fdae9ee3c126da4c54d5824
7
- data.tar.gz: 416fdc8224f4446a14491806a8907c8a8381009b4315f615d994d87dd4b1f28bd8e9f60d1b04e5c6b72e53518b9c217d8c9596be99337e4082b05d5a142c24c8
6
+ metadata.gz: b763ec409386c46522e090e8e9466dbb5e32b9b01f5bea23e20b6c6a739dd0a89ff91fa5b2cbae1d3719a5a90eba1b7975517e5851106eb1891ec8a722d5dce9
7
+ data.tar.gz: 39a4647647c7df4cd5db4f58a74e3aa1ba5691ae069d1788844b419d20c6c7276448408c89902203ebaf2c0ddb4ca73303153c3c041dd4375f58b0d8c63b26fb
@@ -13,7 +13,7 @@ module NoSE
13
13
  end
14
14
 
15
15
  # The cost of filtering intermediate results
16
- # @return [Fixnum]
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 [Fixnum]
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 [Fixnum]
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 [Fixnum]
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 [Fixnum]
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 [Fixnum]
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 [Fixnum]
58
+ # @return [Integer]
59
59
  def pruned_cost(_step)
60
60
  0
61
61
  end
@@ -35,7 +35,7 @@ module NoSE
35
35
  alias eql? ==
36
36
 
37
37
  # The hash is based on the name of the entity and its fields
38
- # @return [Fixnum]
38
+ # @return [Integer]
39
39
  def hash
40
40
  @hash ||= @name.hash
41
41
  end
@@ -34,7 +34,7 @@ module NoSE
34
34
  alias eql? ==
35
35
 
36
36
  # Hash by entity and name
37
- # @return [Fixnum]
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(:instance_variable_get, :@entity).send \
108
- :<<, child_class.new(*args)
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 [Fixnum]
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 [Fixnum]
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
- # Any Fixnum is a valid float
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 [Fixnum]
298
+ # @return [Integer]
288
299
  def cardinality
289
300
  @entity.count || super
290
301
  end
@@ -72,7 +72,7 @@ module NoSE
72
72
  end
73
73
 
74
74
  # Calculate the cost of executing this step in the plan
75
- # @return [Fixnum]
75
+ # @return [Integer]
76
76
  def calculate_cost(cost_model)
77
77
  @cost = cost_model.method((subtype_name + '_cost').to_sym).call self
78
78
  end
@@ -173,7 +173,7 @@ module NoSE
173
173
  end
174
174
 
175
175
  # The estimated cost of executing this plan
176
- # @return [Fixnum]
176
+ # @return [Integer]
177
177
  def cost
178
178
  costs = @steps.map(&:cost) + @update_steps.map(&:cost)
179
179
  costs += @query_plans.map(&:steps).flatten.map(&:cost)
@@ -171,7 +171,7 @@ module NoSE
171
171
  end
172
172
 
173
173
  # The weight of this query for a given workload
174
- # @return [Fixnum]
174
+ # @return [Integer]
175
175
  def weight
176
176
  return 1 if @workload.nil?
177
177
 
@@ -50,7 +50,7 @@ module NoSE
50
50
  end
51
51
 
52
52
  # The weight of this query for a given workload
53
- # @return [Fixnum]
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 [Fixnum]
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 [Fixnum]
154
+ # @return [Integer]
155
155
  def cost
156
156
  @query_plans.sum_by(&:cost) + update_cost
157
157
  end
@@ -353,7 +353,7 @@ module NoSE
353
353
  end
354
354
 
355
355
  # Return the next valid random number
356
- # @return [Fixnum]
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<Fixnum>]
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))
@@ -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 [Fixnum]
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 [Fixnum]
329
+ # @return [Integer]
330
330
  def cardinality
331
331
  state = represented.instance_variable_get(:@state)
332
332
  state.cardinality unless state.nil?
@@ -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 [Fixnum]
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|
@@ -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
@@ -26,7 +26,7 @@ NoSE::Model.new do
26
26
  end) * 10_000
27
27
 
28
28
  HasOne 'user', 'likes',
29
- 'likes' => 'users'
29
+ {'likes' => 'users'}
30
30
  HasOne 'item', 'likes',
31
- 'likes' => 'items'
31
+ {'likes' => 'items'}
32
32
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Mior