package pool
import (
)
type Reader interface {
Buffered() int
Bytes() []byte
Read([]byte) (int, error)
ReadByte() (byte, error)
UnreadByte() error
ReadSlice(byte) ([]byte, error)
Discard(int) (int, error)
ReadFull() ([]byte, error)
ReadFullTemp() ([]byte, error)
}
type ColumnInfo struct {
Index int16
DataType int32
Name string
}
type ColumnAlloc struct {
columns []ColumnInfo
}
func () *ColumnAlloc {
return new(ColumnAlloc)
}
func ( *ColumnAlloc) () {
.columns = .columns[:0]
}
func ( *ColumnAlloc) ( int16, []byte) *ColumnInfo {
.columns = append(.columns, ColumnInfo{
Index: ,
Name: string(),
})
return &.columns[len(.columns)-1]
}
func ( *ColumnAlloc) () []ColumnInfo {
return .columns
}
type ReaderContext struct {
*BufReader
ColumnAlloc *ColumnAlloc
}
func () *ReaderContext {
const = 1 << 20
return &ReaderContext{
BufReader: NewBufReader(),
ColumnAlloc: NewColumnAlloc(),
}
}
var readerPool = sync.Pool{
New: func() interface{} {
return NewReaderContext()
},
}
func () *ReaderContext {
:= readerPool.Get().(*ReaderContext)
return
}
func ( *ReaderContext) {
.ColumnAlloc.Reset()
readerPool.Put()
}