Documentation ¶
Index ¶
- func CreateDirIfMissing(dirPath string) (bool, error)
- func DecodeOrderPreservingVarUint64(bytes []byte) (uint64, int)
- func DirEmpty(dirPath string) (bool, error)
- func EncodeOrderPreservingVarUint64(number uint64) []byte
- func FileExists(filePath string) (bool, int64, error)
- func GetSortedKeys(m interface{}) []string
- func ListSubdirs(dirPath string) ([]string, error)
- type Buffer
- type FilterBitArray
- func (ba *FilterBitArray) Capacity() uint
- func (ba *FilterBitArray) FromBytes(bytes []byte)
- func (ba *FilterBitArray) IsSet(i uint) bool
- func (ba *FilterBitArray) Set(i uint)
- func (ba *FilterBitArray) SetRange(begin uint, end uint)
- func (ba *FilterBitArray) ToBytes() []byte
- func (ba *FilterBitArray) Unset(i uint)
- func (ba *FilterBitArray) UnsetRange(begin uint, end uint)
- func (ba *FilterBitArray) ValueAt(i uint) byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDirIfMissing ¶
CreateDirIfMissing creates a dir for dirPath if not already exists. If the dir is empty it returns true
func DecodeOrderPreservingVarUint64 ¶
DecodeOrderPreservingVarUint64 decodes the number from the bytes obtained from method 'EncodeOrderPreservingVarUint64'. Also, returns the number of bytes that are consumed in the process
func EncodeOrderPreservingVarUint64 ¶
EncodeOrderPreservingVarUint64 returns a byte-representation for a uint64 number such that all zero-bits starting bytes are trimmed in order to reduce the length of the array For preserving the order in a default bytes-comparison, first byte contains the number of remaining bytes. The presence of first byte also allows to use the returned bytes as part of other larger byte array such as a composite-key representation in db
func FileExists ¶
FileExists checks whether the given file exists. If the file exists, this method also returns the size of the file.
func GetSortedKeys ¶
func GetSortedKeys(m interface{}) []string
GetSortedKeys returns the keys of the map in a sorted order. This function assumes that the keys are string
func ListSubdirs ¶
ListSubdirs returns the subdirectories
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer provides a wrapper on top of proto.Buffer. The purpose of this wrapper is to get to know the current position in the []byte
func (*Buffer) DecodeRawBytes ¶
DecodeRawBytes wraps the actual method and updates the position
func (*Buffer) DecodeVarint ¶
DecodeVarint wraps the actual method and updates the position
func (*Buffer) GetBytesConsumed ¶
GetBytesConsumed returns the offset of the current position in the underlying []byte
type FilterBitArray ¶
type FilterBitArray []byte
FilterBitArray is an array of bits based on byte unit, so 8 bits at each index. The array automatically increases if the set index is larger than the current capacity. The bit index starts at 0.
func NewFilterBitArray ¶
func NewFilterBitArray(size uint) FilterBitArray
NewFilterBitArray creates an array with the specified bit-size. This is an optimization to make array once for the expected capacity rather than using Set function to auto-increase the array.
func NewFilterBitArrayFromBytes ¶
func NewFilterBitArrayFromBytes(bytes []byte) FilterBitArray
NewFilterBitArrayFromBytes reconstructs an array from given byte array.
func (*FilterBitArray) Capacity ¶
func (ba *FilterBitArray) Capacity() uint
Capacity returns the number of bits in the FilterBitArray.
func (*FilterBitArray) FromBytes ¶
func (ba *FilterBitArray) FromBytes(bytes []byte)
FromBytes accepts a byte array.
func (*FilterBitArray) IsSet ¶
func (ba *FilterBitArray) IsSet(i uint) bool
IsSet returns true if the specified bit-index is 1; false otherwise.
func (*FilterBitArray) Set ¶
func (ba *FilterBitArray) Set(i uint)
Set assigns 1 to the specified bit-index, which is starting from 0. Set automatically increases the array to accommodate the bit-index.
func (*FilterBitArray) SetRange ¶
func (ba *FilterBitArray) SetRange(begin uint, end uint)
SetRange assigns 1 to the bit-indexes specified by range [begin, end] Set automatically increases the array to accommodate the bit-index.
func (*FilterBitArray) ToBytes ¶
func (ba *FilterBitArray) ToBytes() []byte
ToBytes returns the byte array for storage.
func (*FilterBitArray) Unset ¶
func (ba *FilterBitArray) Unset(i uint)
Unset assigns 0 the specified bit-index. If bit-index is larger than capacity, do nothing.
func (*FilterBitArray) UnsetRange ¶
func (ba *FilterBitArray) UnsetRange(begin uint, end uint)
UnsetRange assigns 0 to all bits in range [begin, end]. If bit-index is larger than capacity, do nothing.
func (*FilterBitArray) ValueAt ¶
func (ba *FilterBitArray) ValueAt(i uint) byte
ValueAt returns the value at the specified bit-index. If bit-index is out of range, return 0. Note that the returned value is in byte, so it may be a power of 2 if not 0.