Comments (6)
Can you attach a runnable program exhibiting this?
from gocqlx.
func BenchmarkBatchSet(b *testing.B) {
var batchCols = []string{"id", "first_name", "last_name"}
session := CreateSession(b)
defer session.Close()
msetNum := 2
if err := ExecStmt(session, benchPersonSchema); err != nil {
b.Fatal(err)
}
bt := qb.Batch();
for i := 0; i < msetNum; i++ {
bt.Add(qb.Insert("gocqlx_test.bench_person").Columns(batchCols...))
}
stmt, names := bt.ToCql()
q := gocqlx.Query(session.Query(stmt), names)
for i := 0; i < msetNum; i++ {
q.BindStruct(&benchPerson{
ID: i,
FirstName: strconv.Itoa(i + 1),
LastName: strconv.Itoa(i + 2),
})
}
fmt.Println("query = ", q.Query)
defer q.Release()
b.ResetTimer()
if e1 := q.Exec(); e1 != nil {
b.Fatal(e1)
}
}
from gocqlx.
So let me see if I get this straight. You want to execute the same query several times in a batch with different values for each query in the batch.
Correct?
Since Batch is effectively treats many queries masked as a single query what bind does is that it applies the same bound values for each query in the batch. Every Bind
rebinds the values to the new values and applies them to the entire batch.
This behavior is consistent with how Bind
works for non-batch queries.
I guess arguments could be made for changing the behavior but I have no idea how complicated an implementation would be and changing the API is probably not a good idea so some other method would be needed in that case.
from gocqlx.
So let me see if I get this straight. You want to execute the same query several times in a batch with different values for each query in the batch.
Correct?Since Batch is effectively treats many queries masked as a single query what bind does is that it applies the same bound values for each query in the batch. Every
Bind
rebinds the values to the new values and applies them to the entire batch.
This behavior is consistent with howBind
works for non-batch queries.I guess arguments could be made for changing the behavior but I have no idea how complicated an implementation would be and changing the API is probably not a good idea so some other method would be needed in that case.
Simply, I just want to test the batch command like mget or mset in redis.
Could you please give me some example?
from gocqlx.
from gocqlx.
Duplicate of #110
from gocqlx.
Related Issues (20)
- Upgrade to Go 1.18 HOT 7
- Fix linter in GH action HOT 4
- Fix linter errors HOT 1
- Select query with IN and Boolean List does not return row HOT 4
- migrate: detach context from parent context cancelation HOT 1
- expected 1 column in result while scanning scannable type ptr but got 9 when using GetRelease with BindMap HOT 3
- Migrate cql files from different directories
- [ASK]: Prepare Statement With Table Metadata HOT 1
- Help Regarding table `Update`
- Documentation - Get is by Primary Key, not Partition Key? HOT 2
- Query Level Timeout for Select Operation
- fix using timeout order in delete stmt HOT 6
- gocqlxtest: get test server configuration as from flags so from the environment variables
- What is the best way to update list<frozen<address>> in gocqlx?
- How to pass values to a query HOT 6
- Null value cannot be unpacked into *[16]uint8
- Provide example for batches and updates HOT 1
- Canβt update UDT using gocqlx HOT 2
- Weird paging when using IN clause
- Prepared statements HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gocqlx.