Skip to content

Commit

Permalink
kaizen: prepare for v1.0.0
Browse files Browse the repository at this point in the history
fixes: #144

fixes: #121

fixes: #81
Signed-off-by: Tim Bray <tbray@textuality.com>
  • Loading branch information
timbray committed Jan 3, 2023
1 parent 66f4f48 commit 37032a7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
24 changes: 12 additions & 12 deletions PATTERNS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Patterns in Quamina

**Patterns** are added to Quamina instances using the
`AddPattern` API. This document specifies the syntax and
`AddPattern` API. This document specifies the syntax and
semantics of Patterns.

The discussion of JSON constructs in this document uses
Expand All @@ -18,7 +18,7 @@ Unicode characters.

As in JSON, the allowed member values may be strings,
numbers, the literals `true`, `false`, and `null`, arrays,
and objects. We refer to values which are neither arrays
and objects. We refer to values which are neither arrays
nor objects as **Leaf** values.

A **Field** is the combination of a Leaf value and a
Expand All @@ -27,14 +27,14 @@ that must be traversed to reach it from the Event root.

For example, in the Event
```json
{"alpha": {"beta": 1}}
{"alpha": {"beta": 1}}
```
There is only one Field whose Leaf value is `1`
and whose Path is `"alpha","beta"`.

Paths omit arrays. So in the Event
Paths omit arrays. So in the Event
```json
{"alpha": [ {"beta": [1, 2]}, {"beta": [3, 4]} ] }
{"alpha": [ {"beta": [1, 2]}, {"beta": [3, 4]} ] }
```
The Path for the Leaf value `1` is still `"alpha","beta"`

Expand All @@ -53,7 +53,7 @@ value.

Thus, the following Pattern would match both JSON events above:
```json
{"alpha": {"beta": [1]}}
{"alpha": {"beta": [1]}}
```

## Extended Patterns
Expand All @@ -63,7 +63,7 @@ a single field whose name is called the **Pattern Type**.
### Exists Pattern

The Pattern Type of an Exists Pattern is `exists` and its
value **MUST** be `true` or `false`. Here
value **MUST** be `true` or `false`. Here
are two Exists Patterns that would match the Events above:
```json
{"alpha": {"beta": [ {"exists": true} ]}}
Expand All @@ -77,7 +77,7 @@ Exists Patterns currently only work on leaf nodes. That is to
say, given this event:

```json
{ "a": { "b": 1 } }
{ "a": { "b": 1 } }
```

The following pattern will not match:
Expand All @@ -98,10 +98,10 @@ Then `"exists": true` does not match but `"exists": false` does.
I.e., only the first of the two sample patterns below matches.

```json
{ "a": [ { "exists": false } ] }
{ "a": [ { "exists": false } ] }
```
```json
{ "a": [ { "exists": true } ] }
{ "a": [ { "exists": true } ] }
```
This makes sense in the context of the leaf-node semantics; there
really is no value for the `"a"` field.
Expand All @@ -111,7 +111,7 @@ really is no value for the `"a"` field.

The Pattern Type of an Anything-But Pattern is
`anything-but` and its value **MUST** be an array
of strings. It will match a string value which
of strings. It will match a string value which
is not equal to any of the strings in the array.

If a Field in a Pattern contains an Anything-But Pattern,
Expand Down Expand Up @@ -144,7 +144,7 @@ the AWS EventBridge service, as documented in

As of release 1.0, Quamina supports Exists and
Anything-But Patterns, but does not yet support any other
EventBridge patterns. Note that a
EventBridge patterns. Note that a
Shellstyle Pattern with a trailing `*` is equivalent
to a `prefix` pattern.

12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,8 @@ to improve this.)

`WithPatternStorage`: If you provide an argument that
supports the `LivePatternStorage` API, Quamina will
use it to
maintain a list of which Patterns have currently been
added but not deleted. This could be useful if you
use it tomaintain a list of which Patterns have currently
been added but not deleted. This could be useful if you
wanted to rebuild Quamina instances for sharded
processing or after a system failure. ***Note: Not
yet implemented.***
Expand Down Expand Up @@ -348,10 +347,9 @@ Once the list of fields which might match a Pattern is
extracted, the cost of traversing the automaton
is at most N, the number of fields left after discarding.

So, adding a new Pattern that only
mentions fields which are already mentioned in previous
Patterns is effectively free i.e. O(1) in terms of run-time
performance.
So, adding a new Pattern that only mentions fields which are
already mentioned in previous Patterns is effectively free
i.e. O(1) in terms of run-time performance.

### Further documentation

Expand Down
4 changes: 2 additions & 2 deletions cl2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ func getCL2Lines(t *testing.T) [][]byte {
}
file, err := os.Open("testdata/citylots2.json.gz")
if err != nil {
t.Error("Can't open citlots.jlines.gz: " + err.Error())
t.Fatal("Can't open citylots2.json.gz: " + err.Error())
}
defer func(file *os.File) {
_ = file.Close()
}(file)
zr, err := gzip.NewReader(file)
if err != nil {
t.Error("Can't open zip reader: " + err.Error())
t.Fatal("Can't open zip reader: " + err.Error())
}

scanner := bufio.NewScanner(zr)
Expand Down

0 comments on commit 37032a7

Please sign in to comment.