Curious about examples/client/aggregate.py

Hello World,

I’m curious about the Python Client examples on Github.

I installed Aerospike on my Linux box.

And started it up so it listens at

127.0.0.1:3000

Then I installed the Python Client using

pip install aerospike

Then I git-cloned the examples:

cd ~
git clone git@github.com:aerospike/aerospike-client-python.git

I ran this example:

python examples/client/kvs.py

It worked well.

Now I’m looking at this script:

examples/client/aggregate.py

I’m not sure what it is supposed to teach me.

I tried this:

$ python examples/client/aggregate.py
Usage: aggregate.py [options] where module function [args...]

Options:
  -h <ADDRESS>, --host=<ADDRESS>
                        Address of Aerospike server.
  -p <PORT>, --port=<PORT>
                        Port of the Aerospike server.
  --help                Displays this message.
  -n <NS>, --namespace=<NS>
                        Port of the Aerospike server.
  -s <SET>, --set=<SET>
                        Port of the Aerospike server.
  -b BINS, --bins=BINS  Bins to select from each record.

I understand that I can pass in a set and bins so that seems easy.

I dont understand this part of the command line signature:

where module function [args...]

Where do I learn about this?

I sense this example assumes a level of knowledge about Aerospike which I don’t have yet.

I looked at

examples/client/aggregate.py

with my editor.

The script seemed to assume that my set and bins had a structure known to the script.

Aside from that I did not find anything useful for learning.

The name aggregate.py suggests to me that I’d learn how to aggregate.

I want to learn how to do the SQL equivalent of something like this:

SELECT AVG(weight) FROM persons WHERE location = 'NY';

Or maybe something like this:

SELECT gender, MAX(age) FROM persons GROUP BY gender;

Hi. I agree that we definitely can clarify the examples, and we plan on doing that.

The where is the query predicate, for example “age between 20 and 29” or “age=26”.

The module is the name of the UDF module you want to use for the aggregation and the function is the name of the function inside that Lua module. We use Lua to extend the functionality of the server.

This is described in the Quick Guide to the Python client on our site: http://www.aerospike.com/docs/client/python/usage/udf/aggregate.html

More details about using Lua for aggregations is in the article Developing Stream UDFs

This is good info!

I suggest that eventually we have examples of calling the examples.

In my work I call a lot of different APIs.

I usually care more about how they behave than what they look like under the hood.

The docs here are well written:

http://www.aerospike.com/docs/client/python/

I like them.

1 Like

Thank you for the input. We will continue to improve the Python client’s documentation (including a more standard looking API reference) in the next few weeks.

The documentation was changed with release 1.0.37. Aggregate has been merged into the query documentation, as it’s a function of the Query class. The documentation for the key-value and scan operations was cleaned up as well.