Vendor: grafana-plugin-sdk-go v0.11.0 (#21552)

upgrades https://github.com/grafana/grafana-plugin-sdk-go from v0.6.0 to v0.11.0
This commit is contained in:
Kyle Brandt
2020-01-16 12:53:51 -05:00
committed by GitHub
parent 0cfcc85dec
commit 5a31e48548
33 changed files with 1986 additions and 415 deletions
+1 -1
View File
@@ -99,7 +99,7 @@ func (d *Data) Buffers() []*memory.Buffer { return d.buffers }
// NewSliceData panics if the slice is outside the valid range of the input Data.
// NewSliceData panics if j < i.
func NewSliceData(data *Data, i, j int64) *Data {
if j > int64(data.length) || i > j || data.offset+int(i) > data.length {
if j > int64(data.length) || i > j || data.offset+int(i) > data.offset+data.length {
panic("arrow/array: index out of range")
}
+1 -1
View File
@@ -82,7 +82,7 @@ func NewFileReader(r ReadAtSeeker, opts ...Option) (*FileReader, error) {
}
if cfg.schema != nil && !cfg.schema.Equal(f.schema) {
return nil, errors.Errorf("arrow/ipc: inconsitent schema for reading (got: %v, want: %v)", f.schema, cfg.schema)
return nil, errors.Errorf("arrow/ipc: inconsistent schema for reading (got: %v, want: %v)", f.schema, cfg.schema)
}
return &f, err
+3 -2
View File
@@ -37,8 +37,9 @@ const (
)
var (
paddingBytes [kArrowAlignment]byte
kEOS = [4]byte{0, 0, 0, 0} // end of stream message
paddingBytes [kArrowAlignment]byte
kEOS = [8]byte{0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0} // end of stream message
kIPCContToken uint32 = 0xFFFFFFFF // 32b continuation indicator for FlatBuffers 8b alignment
)
func paddedLength(nbytes int64, alignment int32) int64 {
+23 -4
View File
@@ -181,12 +181,31 @@ func (r *MessageReader) Message() (*Message, error) {
var buf = make([]byte, 4)
_, err := io.ReadFull(r.r, buf)
if err != nil {
return nil, errors.Wrap(err, "arrow/ipc: could not read message length")
return nil, errors.Wrap(err, "arrow/ipc: could not read continuation indicator")
}
msgLen := int32(binary.LittleEndian.Uint32(buf))
if msgLen == 0 {
// optional 0 EOS control message
var (
cid = binary.LittleEndian.Uint32(buf)
msgLen int32
)
switch cid {
case 0:
// EOS message.
return nil, io.EOF // FIXME(sbinet): send nil instead? or a special EOS error?
case kIPCContToken:
_, err = io.ReadFull(r.r, buf)
if err != nil {
return nil, errors.Wrap(err, "arrow/ipc: could not read message length")
}
msgLen = int32(binary.LittleEndian.Uint32(buf))
if msgLen == 0 {
// optional 0 EOS control message
return nil, io.EOF // FIXME(sbinet): send nil instead? or a special EOS error?
}
default:
// ARROW-6314: backwards compatibility for reading old IPC
// messages produced prior to version 0.15.0
msgLen = int32(cid)
}
buf = make([]byte, msgLen)
+25 -6
View File
@@ -88,7 +88,19 @@ func (blk fileBlock) NewMessage() (*Message, error) {
if err != nil {
return nil, errors.Wrap(err, "arrow/ipc: could not read message metadata")
}
meta := memory.NewBufferBytes(buf[4:]) // drop buf-size already known from blk.Meta
prefix := 0
switch binary.LittleEndian.Uint32(buf) {
case 0:
case kIPCContToken:
prefix = 8
default:
// ARROW-6314: backwards compatibility for reading old IPC
// messages produced prior to version 0.15.0
prefix = 4
}
meta := memory.NewBufferBytes(buf[prefix:]) // drop buf-size already known from blk.Meta
buf = make([]byte, blk.Body)
_, err = io.ReadFull(r, buf)
@@ -1002,19 +1014,26 @@ func writeMessage(msg *memory.Buffer, alignment int32, w io.Writer) (int, error)
)
// ARROW-3212: we do not make any assumption on whether the output stream is aligned or not.
paddedMsgLen := int32(msg.Len()) + 4
paddedMsgLen := int32(msg.Len()) + 8
remainder := paddedMsgLen % alignment
if remainder != 0 {
paddedMsgLen += alignment - remainder
}
tmp := make([]byte, 4)
// write continuation indicator, to address 8-byte alignment requirement from FlatBuffers.
binary.LittleEndian.PutUint32(tmp, kIPCContToken)
_, err = w.Write(tmp)
if err != nil {
return 0, errors.Wrap(err, "arrow/ipc: could not write continuation bit indicator")
}
// the returned message size includes the length prefix, the flatbuffer, + padding
n = int(paddedMsgLen)
tmp := make([]byte, 4)
// write the flatbuffer size prefix, including padding
sizeFB := paddedMsgLen - 4
sizeFB := paddedMsgLen - 8
binary.LittleEndian.PutUint32(tmp, uint32(sizeFB))
_, err = w.Write(tmp)
if err != nil {
@@ -1028,7 +1047,7 @@ func writeMessage(msg *memory.Buffer, alignment int32, w io.Writer) (int, error)
}
// write any padding
padding := paddedMsgLen - int32(msg.Len()) - 4
padding := paddedMsgLen - int32(msg.Len()) - 8
if padding > 0 {
_, err = w.Write(paddingBytes[:padding])
if err != nil {