Skip to content

Commit

Permalink
support read requests that provide lower and upper bound
Browse files Browse the repository at this point in the history
  • Loading branch information
pdziepak committed May 22, 2017
1 parent 87a3e6b commit 3b9342d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var clusteringRowCount int
var clusteringRowSize int

var rowsPerRequest int
var provideUpperBound bool

var timeout time.Duration

Expand Down Expand Up @@ -115,6 +116,7 @@ func main() {
flag.IntVar(&clusteringRowSize, "clustering-row-size", 4, "size of a single clustering row")

flag.IntVar(&rowsPerRequest, "rows-per-request", 1, "clustering rows per single request")
flag.BoolVar(&provideUpperBound, "provide-upper-bound", false, "whether read requests should provide an upper bound")
flag.DurationVar(&testDuration, "duration", 0, "duration of the test in seconds (0 for unlimited)")

flag.IntVar(&partitionOffset, "partition-offset", 0, "start of the partition range (only for sequential workload)")
Expand Down Expand Up @@ -214,6 +216,9 @@ func main() {
fmt.Println("Clustering rows:\t", clusteringRowCount)
fmt.Println("Clustering row size:\t", clusteringRowSize)
fmt.Println("Rows per request:\t", rowsPerRequest)
if mode == "read" {
fmt.Println("Provide upper bound:\t", provideUpperBound)
}
fmt.Println("Page size:\t\t", pageSize)
fmt.Println("Concurrency:\t\t", concurrency)
fmt.Println("Connections:\t\t", connectionCount)
Expand Down
15 changes: 13 additions & 2 deletions modes.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,12 @@ func DoCounterUpdates(session *gocql.Session, workload WorkloadGenerator) Result
}

func DoReads(session *gocql.Session, workload WorkloadGenerator) Result {
request := fmt.Sprintf("SELECT * FROM %s.%s WHERE pk = ? AND ck >= ? LIMIT %d", keyspaceName, tableName, rowsPerRequest)
var request string
if provideUpperBound {
request = fmt.Sprintf("SELECT * FROM %s.%s WHERE pk = ? AND ck >= ? AND ck < ?", keyspaceName, tableName)
} else {
request = fmt.Sprintf("SELECT * FROM %s.%s WHERE pk = ? AND ck >= ? LIMIT %d", keyspaceName, tableName, rowsPerRequest)
}
query := session.Query(request)

var result Result
Expand All @@ -194,7 +199,13 @@ func DoReads(session *gocql.Session, workload WorkloadGenerator) Result {
result.Operations++
pk := workload.NextPartitionKey()
ck := workload.NextClusteringKey()
bound := query.Bind(pk, ck)

var bound *gocql.Query
if provideUpperBound {
bound = query.Bind(pk, ck, ck+rowsPerRequest)
} else {
bound = query.Bind(pk, ck)
}

requestStart := time.Now()
iter := bound.Iter()
Expand Down

0 comments on commit 3b9342d

Please sign in to comment.