Skip to content

Commit 2bf311b

Browse files
committed
Re-juggle documentation layout
Inline examples to help demonstrate concepts.
1 parent c65d1ad commit 2bf311b

File tree

12 files changed

+222
-199
lines changed

12 files changed

+222
-199
lines changed

docs/aggregation.rst

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,25 @@
66
Aggregation
77
===========
88

9-
Coherence provides developers with the ability to process some subset of the entries in a map, resulting in an
10-
aggregated result. See the `documentation <https://oracle.github.io/coherence/23.03/api/java/index.html>`_ for aggregators provided by this client.
11-
12-
Assume the same set of keys and values are present from the filtering example:
13-
14-
.. code-block:: python
15-
16-
from coherence import NamedMap, Session, Filters, Aggregators
17-
import asyncio
18-
19-
# ...
20-
21-
await map.aggregate(Aggregators.average("age"))
22-
# 47.3
23-
24-
await map.aggregate(Aggregators.sum("age"))
25-
# 142
26-
27-
await map.aggregate(Filters.greater("age", 40), Aggregators.count())
28-
# 2
9+
Sometimes you don't need the actual data objects that are stored within the
10+
data grid, but the derived, calculated result based on them. This is where
11+
Coherence aggregation features come in handy.
12+
13+
Aggregations can be executed against the whole data set, or they can be
14+
limited to a subset of the data using a query or a key set. See the utility
15+
class `Aggregators <api_reference.html#aggregators>`_ for the aggregators
16+
supported out-of-the-box by this client.
17+
18+
The following example demonstrates various aggregation operations against
19+
a `NamedMap`:
20+
21+
.. literalinclude:: ../examples/aggregators.py
22+
:language: python
23+
:emphasize-lines: 47, 50, 53, 56, 60
24+
:linenos:
25+
26+
* Line 47 - Returns a list of distinct hobbies across all entries
27+
* Line 50 - Returns a count of all Hobbits
28+
* Line 53 - Returns a count of all Hobbits over age 40
29+
* Line 56 - Returns an average of all Hobbits under the age of 40
30+
* Line 60 - For each hobby, list the oldest Hobbit for that interest

docs/api_reference.rst

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,85 @@
66
API Reference
77
=============
88

9+
Aggregators
10+
-----------
11+
.. autoclass:: coherence.Aggregators
12+
:members:
13+
14+
Filters
15+
-------
16+
.. autoclass:: coherence.Filters
17+
:members:
18+
19+
MapEntry
20+
--------
21+
.. autoclass:: coherence.MapEntry
22+
:show-inheritance:
23+
:members:
24+
25+
MapEvent
26+
-----------
27+
.. autoclass:: coherence.event.MapEvent
28+
:show-inheritance:
29+
:members:
30+
31+
MapListener
32+
-----------
33+
.. autoclass:: coherence.event.MapListener
34+
:show-inheritance:
35+
:members:
36+
37+
.. automethod:: __init__
38+
39+
NamedCache
40+
----------
41+
.. autoclass:: coherence.NamedCache
42+
:show-inheritance:
43+
:members:
44+
45+
NamedMap
46+
--------
47+
.. autoclass:: coherence.NamedMap
48+
:show-inheritance:
49+
:members:
50+
51+
Options
52+
-------
53+
.. autoclass:: coherence.Options
54+
:show-inheritance:
55+
:members:
56+
57+
.. automethod:: __init__
58+
59+
Processors
60+
----------
61+
.. autoclass:: coherence.Processors
62+
:members:
63+
64+
Session
65+
-------
66+
.. autoclass:: coherence.Session
67+
:show-inheritance:
68+
:members:
69+
70+
.. automethod:: __init__
71+
72+
TlsOptions
73+
----------
74+
.. autoclass:: coherence.TlsOptions
75+
:show-inheritance:
76+
:members:
77+
78+
.. automethod:: __init__
79+
80+
Modules
81+
-------
982
.. toctree::
1083
:maxdepth: 3
1184
:titlesonly:
1285

13-
api_reference/client.rst
1486
api_reference/processor.rst
1587
api_reference/filter.rst
88+
api_reference/event.rst
1689
api_reference/extractor.rst
1790
api_reference/aggregator.rst

docs/api_reference/aggregator.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,4 @@ ReducerAggregator
144144
Aggregators
145145
-----------
146146
.. autoclass:: coherence.aggregator.Aggregators
147-
:show-inheritance:
148147
:members:

docs/api_reference/client.rst

Lines changed: 0 additions & 52 deletions
This file was deleted.

docs/api_reference/event.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
..
2+
Copyright (c) 2022, 2023, Oracle and/or its affiliates.
3+
Licensed under the Universal Permissive License v 1.0 as shown at
4+
https://oss.oracle.com/licenses/upl.
5+
6+
====================
7+
coherence.event
8+
====================
9+
.. toctree::
10+
:maxdepth: 4
11+
12+
MapEvent
13+
--------
14+
.. autoclass:: coherence.event.MapEvent
15+
:show-inheritance:
16+
:members:
17+
:noindex:
18+
19+
MapLifecycleEvent
20+
-----------------
21+
.. autoclass:: coherence.event.MapLifecycleEvent
22+
:show-inheritance:
23+
:members:
24+
:noindex:
25+
26+
MapEventType
27+
------------
28+
.. autoclass:: coherence.event.MapEventType
29+
:show-inheritance:
30+
:members:
31+
:noindex:
32+
33+
MapListener
34+
-----------
35+
.. autoclass:: coherence.event.MapListener
36+
:show-inheritance:
37+
:members:
38+
:noindex:
39+
40+
.. automethod:: __init__

docs/api_reference/filter.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Filter
1818
Filters
1919
-------
2020
.. autoclass:: coherence.filter.Filters
21-
:show-inheritance:
2221
:members:
2322

2423
ExtractorFilter

docs/api_reference/processor.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ coherence.processor
1212
Processors
1313
---------------
1414
.. autoclass:: coherence.processor.Processors
15-
:show-inheritance:
1615
:members:
1716

1817
EntryProcessor

docs/basics.rst

Lines changed: 11 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,17 @@
66
The Basics
77
==========
88

9-
he map (`NamedMap`) and cache (`NamedCache`) implementations provide the same basic features as the Map provided
10-
by Python except for the following differences:
9+
`NamedMap <api_reference.html#namedmap>`_ and `NamedCache <api_reference.html#namedcache>`_ are `dict`-like structures allowing users
10+
to store data within a remote `Coherence <https://coherence.community/>`_ cluster.
1111

12-
* key equality isn't restricted to reference equality
13-
* insertion order is not maintained
14-
* `set()` calls cannot be chained because of the asynchronous nature of the API
12+
The following is an example of using a `NamedMap` to `store`, `get`, and
13+
`remove` simple keys and values:
1514

16-
.. note::
17-
The only difference between `NamedCache` and `NamedMap` is that the `NamedCache` allows associating a `time-to-live` on the cache entry, while `NamedMap` does not
15+
.. literalinclude:: ../examples/basics.py
16+
:language: python
17+
:emphasize-lines: 17, 19, 21-34
18+
:linenos:
1819

19-
For the following examples, let's assume that we have a Map defined in Coherence named `Test`.
20-
To get access to the map from the client:
21-
22-
.. code-block:: python
23-
24-
from coherence import NamedMap, Session
25-
import asyncio
26-
27-
# create a new Session to the Coherence server
28-
session: Session = Session(None)
29-
# create or get a map named Test from the session
30-
map: NamedMap = session.get_map("Test")
31-
32-
Once we have a handle to our map, we can invoke the same basic operations in Python:
33-
34-
.. code-block:: python
35-
36-
await map.size()
37-
# returns 0
38-
39-
await map.put("key1", "value1")
40-
await map.put("key2", "value2")
41-
42-
await map.size()
43-
# returns 2
44-
45-
await map.get("key1")
46-
# returns "value1"
47-
48-
await map.get("key2")
49-
# returns "value2"
50-
51-
await map.contains_key("key2")
52-
# returns true
53-
54-
await map.contains_key("key3")
55-
# returns false
56-
57-
await map.keys()
58-
# ["key1", "key2"]
59-
60-
await map.values()
61-
# ["value1", "value2"]
62-
63-
await map.entries()
64-
# [{key: "key1", value: "value1"}, {key: "key2", value: "value2"}]
20+
* Line 17 - Create a new `Session` that will connect to `localhost:1408`. See the :doc:`Sessions <sessions>` documentation for more details.
21+
* Line 50 - Obtain a `NamedMap` identified by `my-map` from the Session
22+
* Lines 21-34 - Various CRUD operations against the NamedMap such as `get() <api_reference.html#coherence.NamedMap.get>`_, `put() <api_reference.html#coherence.NamedMap.put>`_, and `remote() <api_reference.html#coherence.NamedMap.remove>`_

docs/entryprocessing.rst

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,26 @@
66
Entry Processing
77
================
88

9-
An entry processor allows mutation of map entries in-place within the cluster instead of bringing the entire object
10-
to the client, updating, and pushing the value back. See the `documentation <https://oracle.github.io/coherence/23.03/api/java/index.html>`_ for the processors provided by this client.
11-
12-
Assume the same set of keys and values are present from the filtering and aggregation examples:
13-
14-
.. code-block:: python
15-
16-
from coherence import NamedMap, Session, Filters, Aggregators, Processors
17-
import asyncio
18-
19-
# ...
20-
21-
# targeting a specific entry
22-
await map.invoke("0001", Processors.extract("age"))
23-
# returns: 38
24-
25-
# targeting all entries
26-
await map.invoke_all(Processors.extract("age"))
27-
# returns: [["0001", 38], ["0002", 56], ["0003", 48]]
28-
29-
# incrementing a number 'in-place'
30-
await map.invoke_all(Filters.greater("age", 40), Processors.increment("age", 1))
31-
# returns [["0002", 57], ["0003", 49]]
32-
33-
# update a value 'in-place'
34-
await map.invoke("0001", Processors.update("age", 100))
35-
# returns true meaning the value was updated
36-
await map.get("0001")
37-
# the value will reflect the new age value
9+
Entry processors are a defining feature of Coherence and provide the ability
10+
to send the data modification code into the grid and execute it where
11+
the data is, against one or more entries. This can not only significantly
12+
impact how much data needs to be moved over the wire, but it also takes care
13+
of cluster-wide concurrency control — each entry processor has the exclusive
14+
access to the entry it is processing for the duration of its execution.
15+
16+
See the utility class `Processors <api_reference.html#processors>`_ for the
17+
entry processors supported out-of-the-box by this client.
18+
19+
The following example demonstrates various entry processing operations
20+
against a `NamedMap`:
21+
22+
.. literalinclude:: ../examples/processors.py
23+
:language: python
24+
:emphasize-lines: 37, 44, 51, 57-58, 62
25+
:linenos:
26+
27+
* Line 37 - insert a new Hobbit into the `NamedMap`
28+
* Line 44 - invoke an entry processor to update the age of the inserted Hobbit
29+
* Line 51 - insert a second Hobbit into the `NamedMap`
30+
* Lines 57 - 58 - Increment the ages of all Hobbits in the `NamedMap` by 10. Store the keys of the updated Hobbits
31+
* Line 62 - get all of the updated Hobbits to display

0 commit comments

Comments
 (0)