Skip to content

Commit

Permalink
segmentio#339 Fix problem with nil keys (segmentio#340)
Browse files Browse the repository at this point in the history
* [NOTASK-000] Fix problem with nil keys

Fix problem with nil keys. Currently nil keys are writed as empty byte instead of nil

* [NOTASK-000] Update write.go

Implement fix on method writeVarBytes
  • Loading branch information
Zavierazo authored and Achille committed Aug 22, 2019
1 parent 70799bd commit 8724c87
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions write.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,13 @@ func (wb *writeBuffer) writeBytes(b []byte) {
}

func (wb *writeBuffer) writeVarBytes(b []byte) {
wb.writeVarInt(int64(len(b)))
wb.Write(b)
if b != nil {
wb.writeVarInt(int64(len(b)))
wb.Write(b)
} else {
//-1 is used to indicate nil key
wb.writeVarInt(-1)
}
}

func (wb *writeBuffer) writeBool(b bool) {
Expand Down

0 comments on commit 8724c87

Please sign in to comment.