[VOL-4663] create voltha event topic (voltha.events) with conifgurable no of partitions and replication factor
Change-Id: Ibaf8681ccdbffcc8a3c68612c49d7822a20e1b14
diff --git a/vendor/github.com/golang/snappy/decode.go b/vendor/github.com/golang/snappy/decode.go
index 72efb03..23c6e26 100644
--- a/vendor/github.com/golang/snappy/decode.go
+++ b/vendor/github.com/golang/snappy/decode.go
@@ -52,6 +52,8 @@
// Otherwise, a newly allocated slice will be returned.
//
// The dst and src must not overlap. It is valid to pass a nil dst.
+//
+// Decode handles the Snappy block format, not the Snappy stream format.
func Decode(dst, src []byte) ([]byte, error) {
dLen, s, err := decodedLen(src)
if err != nil {
@@ -83,6 +85,8 @@
}
// Reader is an io.Reader that can read Snappy-compressed bytes.
+//
+// Reader handles the Snappy stream format, not the Snappy block format.
type Reader struct {
r io.Reader
err error
@@ -114,32 +118,23 @@
return true
}
-// Read satisfies the io.Reader interface.
-func (r *Reader) Read(p []byte) (int, error) {
- if r.err != nil {
- return 0, r.err
- }
- for {
- if r.i < r.j {
- n := copy(p, r.decoded[r.i:r.j])
- r.i += n
- return n, nil
- }
+func (r *Reader) fill() error {
+ for r.i >= r.j {
if !r.readFull(r.buf[:4], true) {
- return 0, r.err
+ return r.err
}
chunkType := r.buf[0]
if !r.readHeader {
if chunkType != chunkTypeStreamIdentifier {
r.err = ErrCorrupt
- return 0, r.err
+ return r.err
}
r.readHeader = true
}
chunkLen := int(r.buf[1]) | int(r.buf[2])<<8 | int(r.buf[3])<<16
if chunkLen > len(r.buf) {
r.err = ErrUnsupported
- return 0, r.err
+ return r.err
}
// The chunk types are specified at
@@ -149,11 +144,11 @@
// Section 4.2. Compressed data (chunk type 0x00).
if chunkLen < checksumSize {
r.err = ErrCorrupt
- return 0, r.err
+ return r.err
}
buf := r.buf[:chunkLen]
if !r.readFull(buf, false) {
- return 0, r.err
+ return r.err
}
checksum := uint32(buf[0]) | uint32(buf[1])<<8 | uint32(buf[2])<<16 | uint32(buf[3])<<24
buf = buf[checksumSize:]
@@ -161,19 +156,19 @@
n, err := DecodedLen(buf)
if err != nil {
r.err = err
- return 0, r.err
+ return r.err
}
if n > len(r.decoded) {
r.err = ErrCorrupt
- return 0, r.err
+ return r.err
}
if _, err := Decode(r.decoded, buf); err != nil {
r.err = err
- return 0, r.err
+ return r.err
}
if crc(r.decoded[:n]) != checksum {
r.err = ErrCorrupt
- return 0, r.err
+ return r.err
}
r.i, r.j = 0, n
continue
@@ -182,25 +177,25 @@
// Section 4.3. Uncompressed data (chunk type 0x01).
if chunkLen < checksumSize {
r.err = ErrCorrupt
- return 0, r.err
+ return r.err
}
buf := r.buf[:checksumSize]
if !r.readFull(buf, false) {
- return 0, r.err
+ return r.err
}
checksum := uint32(buf[0]) | uint32(buf[1])<<8 | uint32(buf[2])<<16 | uint32(buf[3])<<24
// Read directly into r.decoded instead of via r.buf.
n := chunkLen - checksumSize
if n > len(r.decoded) {
r.err = ErrCorrupt
- return 0, r.err
+ return r.err
}
if !r.readFull(r.decoded[:n], false) {
- return 0, r.err
+ return r.err
}
if crc(r.decoded[:n]) != checksum {
r.err = ErrCorrupt
- return 0, r.err
+ return r.err
}
r.i, r.j = 0, n
continue
@@ -209,15 +204,15 @@
// Section 4.1. Stream identifier (chunk type 0xff).
if chunkLen != len(magicBody) {
r.err = ErrCorrupt
- return 0, r.err
+ return r.err
}
if !r.readFull(r.buf[:len(magicBody)], false) {
- return 0, r.err
+ return r.err
}
for i := 0; i < len(magicBody); i++ {
if r.buf[i] != magicBody[i] {
r.err = ErrCorrupt
- return 0, r.err
+ return r.err
}
}
continue
@@ -226,12 +221,44 @@
if chunkType <= 0x7f {
// Section 4.5. Reserved unskippable chunks (chunk types 0x02-0x7f).
r.err = ErrUnsupported
- return 0, r.err
+ return r.err
}
// Section 4.4 Padding (chunk type 0xfe).
// Section 4.6. Reserved skippable chunks (chunk types 0x80-0xfd).
if !r.readFull(r.buf[:chunkLen], false) {
- return 0, r.err
+ return r.err
}
}
+
+ return nil
+}
+
+// Read satisfies the io.Reader interface.
+func (r *Reader) Read(p []byte) (int, error) {
+ if r.err != nil {
+ return 0, r.err
+ }
+
+ if err := r.fill(); err != nil {
+ return 0, err
+ }
+
+ n := copy(p, r.decoded[r.i:r.j])
+ r.i += n
+ return n, nil
+}
+
+// ReadByte satisfies the io.ByteReader interface.
+func (r *Reader) ReadByte() (byte, error) {
+ if r.err != nil {
+ return 0, r.err
+ }
+
+ if err := r.fill(); err != nil {
+ return 0, err
+ }
+
+ c := r.decoded[r.i]
+ r.i++
+ return c, nil
}