This is an automated email from the ASF dual-hosted git repository. placave pushed a commit to branch go-characterization in repository https://gitbox.apache.org/repos/asf/datasketches-characterization.git
commit fbfe02c140e796d96a348613fc85cc613325be61 Author: Pierre Lacave <[email protected]> AuthorDate: Wed Mar 20 22:04:17 2024 +0100 [Go] Add first characterization job for Go --- README.md | 27 ++++++++++++++++++++++++++- go/datasketches-characterization-go | Bin 0 -> 2392162 bytes go/go.mod | 2 +- go/main.go | 30 ++++++++++++++++++++++++++---- 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 11a27d3..a230a15 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ under the License. --> -# Characterization Java & C++ Component +# Characterization Java, C++ & Go Component Please visit the main [DataSketches website](https://datasketches.apache.org) for more information. @@ -110,3 +110,28 @@ After your project is created, open *Project Properties* #### **Build Project** After this setup you should be able to *Build Project* from the top-level *Eclipse / Project* Menu. You may need to unselect the *Build Automatically* option. +## Build Instructions (Go) + +### Dependencies +* Go 1.21 or later is required to compile the Go code. + +### Build +* The project use Go modules, so you can build the project by running the following command: + ``` + go build + ``` + +### Run +* The project has a main function that runs the characterization tests. You can run the tests by running the following command: + ``` + ./datasketches-characterization <job name> + ``` + or alternatively: + ``` + go run . <job name> + ``` + + The list of available jobs can be found in the usage of the program: + ``` + ./datasketches-characterization + ``` \ No newline at end of file diff --git a/go/datasketches-characterization-go b/go/datasketches-characterization-go new file mode 100755 index 0000000..f326791 Binary files /dev/null and b/go/datasketches-characterization-go differ diff --git a/go/go.mod b/go/go.mod index 85db448..10e6b51 100644 --- a/go/go.mod +++ b/go/go.mod @@ -14,7 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -module github.com/apache/datasketches-characterization/go +module github.com/apache/datasketches-characterization/datasketches-characterization-go go 1.21.1 diff --git a/go/main.go b/go/main.go index 383b915..1ac185f 100644 --- a/go/main.go +++ b/go/main.go @@ -17,13 +17,35 @@ package main -func main() { +import ( + "fmt" + "os" +) - jobs := map[string]JobProfile{ +var ( + jobs = map[string]JobProfile{ "distinct_count_accuracy_profile": NewDistinctCountAccuracyProfile(distinctCountJobConfig), } +) + +func usage() { + fmt.Println("Usage: go run main.go <job>") + fmt.Println("Available jobs:") + for job := range jobs { + fmt.Println(job) + } + os.Exit(1) +} + +func main() { + if len(os.Args) < 2 || os.Args[1] == "-h" || os.Args[1] == "--help" { + usage() + } - for _, job := range jobs { - job.run() + job, ok := jobs[os.Args[1]] + if !ok { + usage() } + + job.run() } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
