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

Added uint32 flags for QUERY and BATCH operations for native protocol v5 #1783

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 23 additions & 33 deletions frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ const (
flagNoMetaData int = 0x04

// query flags
flagValues byte = 0x01
flagSkipMetaData byte = 0x02
flagPageSize byte = 0x04
flagWithPagingState byte = 0x08
flagWithSerialConsistency byte = 0x10
flagDefaultTimestamp byte = 0x20
flagWithNameValues byte = 0x40
flagWithKeyspace byte = 0x80
flagValues uint32 = 0x01
flagSkipMetaData = 0x02
flagPageSize = 0x04
flagWithPagingState = 0x08
flagWithSerialConsistency = 0x10
flagDefaultTimestamp = 0x20
flagWithNameValues = 0x40
flagWithKeyspace = 0x80

// prepare flags
flagWithPreparedKeyspace uint32 = 0x01
Expand Down Expand Up @@ -1452,7 +1452,9 @@ func (f *framer) writeQueryParams(opts *queryParams) {
return
}

var flags byte
var flags uint32
names := false

if len(opts.values) > 0 {
flags |= flagValues
}
Expand All @@ -1468,33 +1470,21 @@ func (f *framer) writeQueryParams(opts *queryParams) {
if opts.serialConsistency > 0 {
flags |= flagWithSerialConsistency
}

names := false

// protoV3 specific things
if f.proto > protoVersion2 {
if opts.defaultTimestamp {
flags |= flagDefaultTimestamp
}

if len(opts.values) > 0 && opts.values[0].name != "" {
flags |= flagWithNameValues
names = true
}
if opts.defaultTimestamp {
flags |= flagDefaultTimestamp
}

if opts.keyspace != "" {
if f.proto > protoVersion4 {
flags |= flagWithKeyspace
} else {
panic(fmt.Errorf("the keyspace can only be set with protocol 5 or higher"))
}
if len(opts.values) > 0 && opts.values[0].name != "" {
flags |= flagWithNameValues
names = true
}
if opts.keyspace != "" && f.proto >= protoVersion5 {
flags |= flagWithKeyspace
}

if f.proto > protoVersion4 {
f.writeUint(uint32(flags))
if f.proto < protoVersion5 {
f.writeByte(byte(flags))
} else {
f.writeByte(flags)
f.writeUint(flags)
}

if n := len(opts.values); n > 0 {
Expand Down Expand Up @@ -1535,7 +1525,7 @@ func (f *framer) writeQueryParams(opts *queryParams) {
f.writeLong(ts)
}

if opts.keyspace != "" {
if opts.keyspace != "" && f.proto >= protoVersion5 {
f.writeString(opts.keyspace)
}
}
Expand Down