Documentation ¶
Index ¶
- Constants
- Variables
- func CalcVaruintLen(x uint64) int
- func DecodeVarint(buf []byte) int64
- func DecodeVaruint(buf []byte) uint64
- func EncodeVaruint(buf []byte, x uint64) int
- func GetFileSize(s string) int64
- func NewV1BlockFile(path string, opts ...BlocksV1Opt) *blockV1
- func NewV1Blocks(opts ...BlocksV1Opt) *blockV1
- func NewV2BlockFile(path string, opts ...BlocksV2Opt) *blockV2
- func NewV2Blocks(opts ...BlocksV2Opt) *blockV2
- func WriteFileHeader(h FileHeader, w io.Writer) error
- type BlkFile
- func (bf *BlkFile) Close() error
- func (bf *BlkFile) Flush() error
- func (bf *BlkFile) Open(flag flags.OpenFlag) error
- func (bf *BlkFile) ReadBlock(w io.Writer) (*BlkHeader, error)
- func (bf *BlkFile) ReadFile(path string) (*BlkHeader, error)
- func (bf *BlkFile) WriteBlock(header *BlkHeader, reader io.Reader) (int64, error)
- func (bf *BlkFile) WriteFile(path string) (int64, error)
- type BlkFileV2
- func (bf *BlkFileV2) Close() error
- func (bf *BlkFileV2) Flush() error
- func (bf *BlkFileV2) Open(flag flags.OpenFlag) error
- func (bf *BlkFileV2) ReadBlock(w io.Writer) (*BlkHeader, error)
- func (bf *BlkFileV2) ReadFile(path string) (*BlkHeader, error)
- func (bf *BlkFileV2) WithCompressor(compressor compressor.Compressor) *BlkFileV2
- func (bf *BlkFileV2) WriteBlock(key string, reader io.Reader) (int64, error)
- func (bf *BlkFileV2) WriteFile(path string) (int64, error)
- type BlkHeader
- type BlkMeta
- type BlockReadWriter
- type BlocksV1Opt
- type BlocksV2Opt
- type FileHeader
- type GetSizeFunc
- type JengaBlocks
- type KeyFilter
- type KeySize
- type Opener
- type VarInt
- func (v *VarInt) Bytes() []byte
- func (v *VarInt) InitFromUInt64(x uint64)
- func (v *VarInt) Length() int
- func (v *VarInt) Load(d []byte) bool
- func (v *VarInt) LoadByte(d byte) bool
- func (v *VarInt) LoadFromReader(r io.Reader) (bool, int, error)
- func (v *VarInt) ToInt() int64
- func (v *VarInt) ToUint() uint64
Constants ¶
const ( BlkFileMagicCode uint32 = 0x58466AFB BlkFileHeadSize = 10 BlkFileBufferSize = 32 * 1024 BlkHeaderUnknownOffset = -1 )
const (
BlkFileV2Version uint16 = 0x0002
)
const (
BlkFileVersion uint16 = 0x0001
)
const (
MaxVarUintBufSize = 10
)
Variables ¶
var BlkFileOpeners blkFileOpeners
var BlkFileV2Openers blkFileV2Openers
var BlockV1Opts blockV1Opts
var BlockV2Opts blockV2Opts
Functions ¶
func CalcVaruintLen ¶
func DecodeVarint ¶
func DecodeVaruint ¶
func EncodeVaruint ¶
Base 128 Varint的介绍:https://developers.google.com/protocol-buffers/docs/encoding Base 128 Varint,为什么叫128?其实,就是因为只采用7bit的空间来存储有效数据,7bit当然最大只能存储128了。 常规的一个byte是8个bit位,但在Base 128 Varint编码中,将最高的第8位用来作为一个标志位, 如果这一位是1,就表示这个字节后面还有其他字节,如果这个位是0的话,就表示这是最后一个字节了, 这样一来,就可以准确的知道一个整数的结束位置了。
func GetFileSize ¶
func NewV1BlockFile ¶
func NewV1BlockFile(path string, opts ...BlocksV1Opt) *blockV1
func NewV1Blocks ¶
func NewV1Blocks(opts ...BlocksV1Opt) *blockV1
func NewV2BlockFile ¶
func NewV2BlockFile(path string, opts ...BlocksV2Opt) *blockV2
func NewV2Blocks ¶
func NewV2Blocks(opts ...BlocksV2Opt) *blockV2
func WriteFileHeader ¶
func WriteFileHeader(h FileHeader, w io.Writer) error
Types ¶
type BlkFile ¶
type BlkFile struct {
// contains filtered or unexported fields
}
File format: |MAGIC NUNMBER(2 Bytes)|VERSION(2 Bytes)|DATA FORMAT(2 Bytes)|REVERSE(2 Bytes)|ENTITY_1|ENTITY_2|...|ENTITY_N| Entity format: |VARINT(1-10 Bytes)|STRING(string length)|VARINT(1-10 Bytes)|DATA(data size)|
func NewBlkFile ¶
func NewBlkFileWithOpener ¶
func (*BlkFile) WriteBlock ¶
type BlkFileV2 ¶
type BlkFileV2 struct {
// contains filtered or unexported fields
}
File format: |MAGIC NUNMBER(2 Bytes)|VERSION(2 Bytes)|DATA FORMAT(2 Bytes)|REVERSE(2 Bytes)|ENTITY_1|ENTITY_2|...|ENTITY_N| Entity format: |VARINT(1-10 Bytes)|STRING(string length)|DATA SIZE(8 Bytes)|DATA(data size)|
func NewBlkFileV2 ¶
func NewBlkFileV2WithOpener ¶
func (*BlkFileV2) WithCompressor ¶
func (bf *BlkFileV2) WithCompressor(compressor compressor.Compressor) *BlkFileV2
func (*BlkFileV2) WriteBlock ¶
type BlkHeader ¶
func NewBlkHeader ¶
type BlockReadWriter ¶
type BlocksV1Opt ¶
type BlocksV1Opt func(f *blockV1)
type BlocksV2Opt ¶
type BlocksV2Opt func(f *blockV2)
type FileHeader ¶
func ReadFileHeader ¶
func ReadFileHeader(r io.Reader) (FileHeader, error)
type GetSizeFunc ¶
type JengaBlocks ¶
type VarInt ¶
type VarInt struct {
// contains filtered or unexported fields
}