Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cassandra data source part 1 #21

Merged
merged 12 commits into from
Aug 14, 2016
Prev Previous commit
Next Next commit
Cassandra using dialectwriter
  • Loading branch information
araddon committed Jul 29, 2016
commit 509b28f9188d095af462ac154fcaf7ed32de1619
9 changes: 6 additions & 3 deletions backends/cassandra/cass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,10 @@ func TestMutationDeleteSimple(t *testing.T) {
RowData: &data,
})
validateQuerySpec(t, tu.QuerySpec{
Exec: `INSERT INTO user (id, name, deleted, created, updated) VALUES ("user817", "test_name",false, now(), now());`,
Exec: `
INSERT INTO user (id, name, deleted, created, updated)
VALUES
("deleteuser123", "test_name",false, now(), now());`,
ValidateRowData: func() {},
ExpectRowCt: 1,
})
Expand All @@ -516,12 +519,12 @@ func TestMutationDeleteSimple(t *testing.T) {
ValidateRowData: func() {},
})
validateQuerySpec(t, tu.QuerySpec{
Exec: `DELETE FROM user WHERE id = "user817"`,
Exec: `DELETE FROM user WHERE id = "deleteuser123"`,
ValidateRowData: func() {},
ExpectRowCt: 1,
})
validateQuerySpec(t, tu.QuerySpec{
Exec: `SELECT * FROM user WHERE id = "user817"`,
Exec: `SELECT * FROM user WHERE id = "deleteuser123"`,
ExpectRowCt: 0,
})
validateQuerySpec(t, tu.QuerySpec{
Expand Down
8 changes: 5 additions & 3 deletions backends/cassandra/resultreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,15 @@ func (m *ResultReader) Run() error {
limit = m.Req.sel.Limit
}

sel := m.Req.Sel
sel := m.Req.sel

u.Debugf("%p cass limit: %d sel:%s", m.Req.sel, limit, sel)
queryStart := time.Now()

cqlQuery := sel.WriteDialect(NewCassDialect())
cassQry := m.Req.s.session.Query().PageSize(limit)
cassWriter := NewCassDialect()
sel.WriteDialect(cassWriter)
cqlQuery := cassWriter.String()
cassQry := m.Req.s.session.Query(cqlQuery).PageSize(limit)
iter := cassQry.Iter()

for {
Expand Down