Skip to content

Commit

Permalink
Add option for adding more words to the list.
Browse files Browse the repository at this point in the history
  • Loading branch information
neunhoef committed Feb 16, 2024
1 parent 108a9a1 commit 235bb8a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 0.9.2

- Add "more words" option.

Version 0.9.1

- Add 'nastyview' subcommand for 'normal'.
2 changes: 1 addition & 1 deletion feeds/nastyview.feed
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
normal create collection=c numberOfShards=3 replicationFactor=2 drop=true
normal nastyViewData collection=c size=10G numberFields=10 parallelism=40 keySize=32
normal nastyViewData collection=c size=10M numberFields=10 parallelism=1 keySize=32
normal createView viewDefFile=feeds/nastyview.json view=v drop=true
]
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strconv"

"github.com/arangodb/feed/pkg/config"
"github.com/arangodb/feed/pkg/datagen"
"github.com/arangodb/feed/pkg/feedlang"
"github.com/arangodb/feed/pkg/operations"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand All @@ -25,7 +26,8 @@ var (
Short: "The 'feed' tool feeds ArangoDB with generated data, quickly.",
RunE: mainExecute,
}
ProgName string
ProgName string
MoreWords int
)

func init() {
Expand All @@ -39,6 +41,7 @@ func init() {
flags.StringVar(&config.Protocol, "protocol", "vst", "Protocol (http1, http2, vst)")
flags.StringVar(&config.JSONOutput, "jsonOutputFile", "feed.json", "Filename for JSON result output.")
flags.IntVar(&config.MetricsPort, "metricsPort", 8888, "Metrics port (0 for no metrics)")
flags.IntVar(&MoreWords, "moreWords", 0, "Number of additional random terms in long word list")
}

func produceJSONResult(prog feedlang.Program, fileName string) {
Expand Down Expand Up @@ -70,6 +73,8 @@ func mainExecute(cmd *cobra.Command, _ []string) error {

fmt.Printf("Hello world, this is 'feed' version %s !\n\n", Version)

datagen.ExtendLongWordList(MoreWords)

// Expose metrics:
if config.MetricsPort != 0 {
fmt.Printf("Exposing Prometheus metrics on port %d under /metrics...\n\n",
Expand Down Expand Up @@ -105,7 +110,9 @@ func mainExecute(cmd *cobra.Command, _ []string) error {
fmt.Printf("Error in parse: %v\n", err)
os.Exit(3)
}

err = prog.Execute()

if err != nil {
fmt.Printf("Error in execution: %v\n", err)
os.Exit(4)
Expand Down
11 changes: 11 additions & 0 deletions pkg/datagen/longwordlist.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package datagen

import (
"math/rand"
)

var LongWordList = []string{
"Abbott",
"AbbVie",
Expand Down Expand Up @@ -670,3 +674,10 @@ var LongWordList = []string{
"Zions",
"Zoetis",
}

func ExtendLongWordList(nr int) {
source := rand.New(rand.NewSource(int64(12345) + rand.Int63()))
for i := 0; i < nr; i++ {
LongWordList = append(LongWordList, MakeRandomString(rand.Intn(10)+5, source))
}
}

0 comments on commit 235bb8a

Please sign in to comment.