Skip to content

Commit 0bd0fa1

Browse files
author
RobHam99
committed
Added further documentation for aggregate method
1 parent eee0e78 commit 0bd0fa1

File tree

3 files changed

+23
-29
lines changed

3 files changed

+23
-29
lines changed

hazelcast/aggregator.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# Marker class, no implementation. Document it.
88
class Aggregator(object):
99
"""Add documentation."""
10+
1011
pass
1112

1213

@@ -140,7 +141,6 @@ def get_class_id(self):
140141
return 13
141142

142143

143-
144144
def count_(attribute_path=None):
145145
"""Creates count aggregator.
146146
@@ -212,14 +212,14 @@ def floating_point_sum(attribute_path=None):
212212
attribute_path: extracts values from this path if given
213213
214214
Returns:
215-
_DoubleSumAggregator: an aggregator that calculates the sum of the
215+
_FloatingPointSumAggregator: an aggregator that calculates the sum of the
216216
input values
217217
"""
218218
return _FloatingPointSumAggregator(attribute_path)
219219

220220

221221
def max_(attribute_path=None):
222-
"""Creates max aggregator
222+
"""Creates max aggregator.
223223
224224
Args:
225225
attribute_path: extracts values from this path if given
@@ -232,65 +232,65 @@ def max_(attribute_path=None):
232232

233233

234234
def min_(attribute_path=None):
235-
"""Creates double sum aggregator
235+
"""Creates min aggregator.
236236
237237
Args:
238238
attribute_path: extracts values from this path if given
239239
240240
Returns:
241-
_DoubleSumAggregator: an aggregator that calculates the min of the
241+
_Min: an aggregator that calculates the min of the
242242
input values
243243
"""
244244
return _MinAggregator(attribute_path)
245245

246246

247247
def int_avg(attribute_path=None):
248-
"""Creates double sum aggregator
248+
"""Creates int average aggregator.
249249
250250
Args:
251251
attribute_path: extracts values from this path if given
252252
253253
Returns:
254-
_DoubleSumAggregator: an aggregator that calculates the average of the
254+
_IntegerAverage: an aggregator that calculates the average of the
255255
input values
256256
"""
257257
return _IntegerAverageAggregator(attribute_path)
258258

259259

260260
def int_sum(attribute_path=None):
261-
"""Creates double sum aggregator
261+
"""Creates int sum aggregator.
262262
263263
Args:
264264
attribute_path: extracts values from this path if given
265265
266266
Returns:
267-
_DoubleSumAggregator: an aggregator that calculates the sum of the
267+
_IntegerSumAggregator: an aggregator that calculates the sum of the
268268
input values
269269
"""
270270
return _IntegerSumAggregator(attribute_path)
271271

272272

273273
def long_avg(attribute_path=None):
274-
"""Creates double sum aggregator
274+
"""Creates long average aggregator.
275275
276276
Args:
277277
attribute_path: extracts values from this path if given
278278
279279
Returns:
280-
_DoubleSumAggregator: an aggregator that calculates the average of the
280+
_LongAverageAggregator: an aggregator that calculates the average of the
281281
input values
282282
"""
283283
return _LongAverageAggregator(attribute_path)
284284

285285

286286
def long_sum(attribute_path=None):
287-
"""Creates double sum aggregator
287+
"""Creates long sum aggregator.
288288
289289
Args:
290290
attribute_path: extracts values from this path if given
291291
292292
Returns:
293-
_DoubleSumAggregator: an aggregator that calculates the sum of the
293+
_LongSumAggregator: an aggregator that calculates the sum of the
294294
input values
295295
"""
296296
return _LongSumAggregator(attribute_path)

hazelcast/proxy/map.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,20 +319,22 @@ def aggregate(self, aggregator, predicate=None):
319319
predicate (hazelcast.predicate.Predicate): Predicate for the map to filter entries.
320320
321321
Returns:
322-
hazelcast.future.Future[]:
322+
hazelcast.future.Future: The result of the aggregation.
323323
324324
"""
325325
check_not_none(aggregator, "aggregator can't be none")
326326
aggregator_data = self._to_data(aggregator)
327327
if predicate:
328328
if isinstance(predicate, PagingPredicate):
329-
raise AssertionError('Paging predicate is not supported.')
329+
raise AssertionError("Paging predicate is not supported.")
330330

331331
def handler(message):
332332
return self._to_object(map_aggregate_with_predicate_codec.decode_response(message))
333333

334334
predicate_data = self._to_data(predicate)
335-
request = map_aggregate_with_predicate_codec.encode_request(self.name, aggregator_data, predicate_data)
335+
request = map_aggregate_with_predicate_codec.encode_request(
336+
self.name, aggregator_data, predicate_data
337+
)
336338
return self._invoke(request, handler)
337339

338340
def handler(message):

tests/integration/backward_compatible/proxy/map_test.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import unittest
3131
from hazelcast.aggregator import *
3232

33+
3334
class EntryProcessor(IdentifiedDataSerializable):
3435
FACTORY_ID = 66
3536
CLASS_ID = 1
@@ -760,10 +761,7 @@ def configure_client(cls, config):
760761

761762
def setUp(self):
762763
self.map = self.client.get_map(random_string()).blocking()
763-
self.map.put_all({
764-
"key-%d" % i: i
765-
for i in range(50)
766-
})
764+
self.map.put_all({"key-%d" % i: i for i in range(50)})
767765

768766
def tearDown(self):
769767
self.map.destroy()
@@ -804,6 +802,7 @@ def test_fixed_point_sum_with_predicate(self):
804802
sum = self.map.aggregate(fixed_point_sum(), predicate=greater_or_equal("this", 47))
805803
self.assertEqual(144, sum)
806804

805+
807806
@unittest.skipIf(
808807
is_client_version_older_than("4.2.1"), "Tests the features added in 4.2.1 version of the client"
809808
)
@@ -816,10 +815,7 @@ def configure_client(cls, config):
816815

817816
def setUp(self):
818817
self.map = self.client.get_map(random_string()).blocking()
819-
self.map.put_all({
820-
"key-%d" % i: i
821-
for i in range(50)
822-
})
818+
self.map.put_all({"key-%d" % i: i for i in range(50)})
823819

824820
def tearDown(self):
825821
self.map.destroy()
@@ -849,7 +845,6 @@ def test_long_sum_with_predicate(self):
849845
self.assertEqual(144, sum)
850846

851847

852-
853848
@unittest.skipIf(
854849
is_client_version_older_than("4.2.1"), "Tests the features added in 4.2.1 version of the client"
855850
)
@@ -861,10 +856,7 @@ def configure_client(cls, config):
861856

862857
def setUp(self):
863858
self.map = self.client.get_map(random_string()).blocking()
864-
self.map.put_all({
865-
"key-%d" % i: float(i)
866-
for i in range(50)
867-
})
859+
self.map.put_all({"key-%d" % i: float(i) for i in range(50)})
868860

869861
def tearDown(self):
870862
self.map.destroy()

0 commit comments

Comments
 (0)