diff --git a/.github/workflows/build-compatability-1412.yaml b/.github/workflows/build-compatability-1412.yaml index 2e332d4..efa3351 100644 --- a/.github/workflows/build-compatability-1412.yaml +++ b/.github/workflows/build-compatability-1412.yaml @@ -23,7 +23,6 @@ jobs: fail-fast: false matrix: coherenceVersion: - - 14.1.2-0-0 - 14.1.2-0-1 - 14.1.2-0-2-SNAPSHOT go-version: diff --git a/.github/workflows/build-compatability-2206.yaml b/.github/workflows/build-compatability-2206.yaml index c95ff79..ab60020 100644 --- a/.github/workflows/build-compatability-2206.yaml +++ b/.github/workflows/build-compatability-2206.yaml @@ -23,7 +23,6 @@ jobs: fail-fast: false matrix: coherenceVersion: - - 22.06.10 - 22.06.11 - 22.06.12-SNAPSHOT go-version: diff --git a/.github/workflows/build-compatability-v1-1412.yaml b/.github/workflows/build-compatability-v1-1412.yaml index bd5d4da..faa1adc 100644 --- a/.github/workflows/build-compatability-v1-1412.yaml +++ b/.github/workflows/build-compatability-v1-1412.yaml @@ -23,7 +23,6 @@ jobs: fail-fast: false matrix: coherenceVersion: - - 14.1.2-0-0 - 14.1.2-0-1 - 14.1.2-0-2-SNAPSHOT go-version: diff --git a/.github/workflows/build-compatability-v1.yaml b/.github/workflows/build-compatability-v1.yaml index fd29ac3..ad14dd3 100644 --- a/.github/workflows/build-compatability-v1.yaml +++ b/.github/workflows/build-compatability-v1.yaml @@ -23,7 +23,6 @@ jobs: fail-fast: false matrix: coherenceVersion: - - 24.09 - 24.09.2 - 24.09.4-SNAPSHOT go-version: diff --git a/.github/workflows/build-compatability.yaml b/.github/workflows/build-compatability.yaml index ba7c108..8736853 100644 --- a/.github/workflows/build-compatability.yaml +++ b/.github/workflows/build-compatability.yaml @@ -23,7 +23,6 @@ jobs: fail-fast: false matrix: coherenceVersion: - - 24.09 - 24.09.3 go-version: - 1.19.x diff --git a/.github/workflows/build-queues-1412.yaml b/.github/workflows/build-queues-1412.yaml index 0e10067..49e9942 100644 --- a/.github/workflows/build-queues-1412.yaml +++ b/.github/workflows/build-queues-1412.yaml @@ -23,7 +23,6 @@ jobs: fail-fast: false matrix: coherenceVersion: - - 14.1.2-0-0 - 14.1.2-0-1 - 14.1.2-0-2-SNAPSHOT go-version: diff --git a/.github/workflows/build-queues.yaml b/.github/workflows/build-queues.yaml index 6a3f3ce..de7dac4 100644 --- a/.github/workflows/build-queues.yaml +++ b/.github/workflows/build-queues.yaml @@ -23,7 +23,6 @@ jobs: fail-fast: false matrix: coherenceVersion: - - 24.09 - 24.09.3 - 24.09.4-SNAPSHOT go-version: diff --git a/.github/workflows/examples-v1.2.2.yaml b/.github/workflows/examples-v1.2.2.yaml index ae47b19..c4310a4 100644 --- a/.github/workflows/examples-v1.2.2.yaml +++ b/.github/workflows/examples-v1.2.2.yaml @@ -22,7 +22,6 @@ jobs: matrix: coherenceVersion: - 22.06.12-SNAPSHOT - - 22.06.10 - 22.06.11 go-version: - 1.19.x diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml index 348465c..ad7e1af 100644 --- a/.github/workflows/examples.yaml +++ b/.github/workflows/examples.yaml @@ -21,9 +21,7 @@ jobs: matrix: coherenceVersion: - 22.06.12-SNAPSHOT - - 22.06.10 - 22.06.11 - - 14.1.2-0-0 - 14.1.2-0-1 - 14.1.2-0-2-SNAPSHOT go-version: diff --git a/.github/workflows/resolver-clusters-compatability-tests.yaml b/.github/workflows/resolver-clusters-compatability-tests.yaml index e50689d..07c5ef4 100644 --- a/.github/workflows/resolver-clusters-compatability-tests.yaml +++ b/.github/workflows/resolver-clusters-compatability-tests.yaml @@ -20,11 +20,8 @@ jobs: fail-fast: false matrix: coherenceVersion: - - 22.06.10 - 22.06.11 - - 24.09 - 24.09.2 - - 14.1.2-0-0 - 14.1.2-0-1 go-version: - 1.19.x diff --git a/.github/workflows/resolver-compatability-tests.yaml b/.github/workflows/resolver-compatability-tests.yaml index c9be88d..3812bf1 100644 --- a/.github/workflows/resolver-compatability-tests.yaml +++ b/.github/workflows/resolver-compatability-tests.yaml @@ -20,11 +20,8 @@ jobs: fail-fast: false matrix: coherenceVersion: - - 22.06.10 - 22.06.11 - - 24.09 - - 24.09.2 - - 14.1.2-0-0 + - 24.09.3 - 14.1.2-0-1 go-version: - 1.19.x diff --git a/Makefile b/Makefile index d0d4c08..945e8ba 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ # ---------------------------------------------------------------------------------------------------------------------- # This is the version of the coherence-go-client -VERSION ?=2.0.0-rc1 +VERSION ?=2.0.1 CURRDIR := $(shell pwd) USER_ID := $(shell echo "`id -u`:`id -g`") diff --git a/examples/README.md b/examples/README.md index 71e04b6..a5d8fb3 100644 --- a/examples/README.md +++ b/examples/README.md @@ -165,10 +165,18 @@ go run querying/main.go This example shows how to carry out various aggregations against a NamedMap or NamedCache. -Source code: [aggregators/main.go](aggregators/main.go) +Source code: [aggregators/basic/main.go](aggregators/basic/main.go) ```go -go run aggregators/main.go +go run aggregators/basic/main.go +``` + +This example shows how to carry out an explain plan against a NamedMap or NamedCache. + +Source code: [aggregators/explain/main.go](aggregators/explain/main.go) + +```go +go run aggregators/explain/main.go ``` ### Running processors diff --git a/examples/aggregators/main.go b/examples/aggregators/basic/main.go similarity index 97% rename from examples/aggregators/main.go rename to examples/aggregators/basic/main.go index eb117f5..57856c3 100644 --- a/examples/aggregators/main.go +++ b/examples/aggregators/basic/main.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024 Oracle and/or its affiliates. + * Copyright (c) 2022, 2025 Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * https://oss.oracle.com/licenses/upl. */ diff --git a/examples/aggregators/explain/main.go b/examples/aggregators/explain/main.go new file mode 100644 index 0000000..335acf7 --- /dev/null +++ b/examples/aggregators/explain/main.go @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2022, 2025 Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * https://oss.oracle.com/licenses/upl. + */ + +/* +Package main shows how to run an explain plan using a NamedMap with key of int and value of Person struct. +*/ +package main + +import ( + "context" + "encoding/json" + "fmt" + "github.com/oracle/coherence-go-client/v2/coherence" + "github.com/oracle/coherence-go-client/v2/coherence/aggregators" + "github.com/oracle/coherence-go-client/v2/coherence/extractors" + "github.com/oracle/coherence-go-client/v2/coherence/filters" +) + +type Person struct { + ID int `json:"id"` + Name string `json:"name"` + Age int `json:"age"` + Department string `json:"department"` +} + +func main() { + var ( + personData = map[int]Person{ + 1: {ID: 1, Name: "Tim", Age: 19, Department: "IT"}, + 2: {ID: 2, Name: "Andrew", Age: 20, Department: "IT"}, + 3: {ID: 3, Name: "John", Age: 30, Department: "HR"}, + 4: {ID: 4, Name: "Steve", Age: 40, Department: "Finance"}, + } + ctx = context.Background() + ) + + // create a new Session to the default gRPC port of 1408 using plain text + session, err := coherence.NewSession(ctx, coherence.WithPlainText()) + + if err != nil { + panic(err) + } + + defer session.Close() + + // create a new NamedMap of Person with key int + namedMap, err := coherence.GetNamedMap[int, Person](session, "explain-test") + if err != nil { + panic(err) + } + + // Add an index on department + department := extractors.Extract[string]("department") + + err = coherence.AddIndex(ctx, namedMap, department, true) + if err != nil { + panic(err) + } + + // clear and populate the Map + _ = namedMap.Clear(ctx) + + if err = namedMap.PutAll(ctx, personData); err != nil { + panic(err) + } + + jsonResult, err := coherence.AggregateFilter[int, Person, map[string]interface{}](ctx, namedMap, + filters.Equal(department, "IT"), + aggregators.QueryRecorder(aggregators.Explain)) + if err != nil { + panic(err) + } + + var results string + + if results, err = getResults(jsonResult); err != nil { + panic(err) + } + + fmt.Println(aggregators.Explain) + fmt.Println(results) + + jsonResult, err = coherence.AggregateFilter[int, Person, map[string]interface{}](ctx, namedMap, + filters.Equal(department, "IT"), + aggregators.QueryRecorder(aggregators.Trace)) + if err != nil { + panic(err) + } + + if results, err = getResults(jsonResult); err != nil { + panic(err) + } + fmt.Println(aggregators.Trace) + fmt.Println(results) +} + +func getResults(results *map[string]interface{}) (string, error) { + prettyJSON, err := json.MarshalIndent(results, "", " ") + if err != nil { + return "", fmt.Errorf("error marshalling: %v", err) + } + + return string(prettyJSON), nil +}