Documentation ¶
Index ¶
- Constants
- func CheckStoreSize(directory, filePrefix string, maxFiles int, maxFileSize int64) (err error)
- func FindFileIndexes(directory, filePrefix string) (minIndex, maxIndex uint64, maxDataSize int64, totalFiles int, err error)
- func IncrementWriteFile(directory, filePrefix string, maxFiles int) (index, data string, err error)
- func MegaByteToByte(n int64) int64
- func PruneDirectory(directory, filePrefix, readIndexFile string) (err error)
- func ReadData(data map[uint64]*[]byte, indexes ...*Index) (err error)
- func ReadIndexes(directory, filePrefix string, indices map[uint64]*Index) (indexRead, indexWrite uint64, err error)
- func Size(filepath string) (size int64, err error)
- func Sizes(directory, filePrefix, fileSuffix string) (int64, error)
- func WriteIndex(indexes ...*Index) (err error)
- type Bytes
- type Files
- type Index
Constants ¶
const ( ErrLessBytes string = "not enough bytes to decode" ErrBadBytesWritten string = "bytes written not equal to input slice" ErrMaxFilesCreated string = "max files created, store is full" ErrMaxStoreSize string = "max store size reached, store is full" )
error constants
Variables ¶
This section is empty.
Functions ¶
func CheckStoreSize ¶
CheckStoreSize can be used to determine if the store is full
func FindFileIndexes ¶
func IncrementWriteFile ¶
incrementWriteFile can be used to increment the index and data files associated with a store it will pull the current index and generate new index/data filepaths
func MegaByteToByte ¶
func PruneDirectory ¶
pruneDirectory can be used to remove un-used files less than the provided index or all files with the given file prefix if set to -1
func ReadIndexes ¶
func ReadIndexes(directory, filePrefix string, indices map[uint64]*Index) (indexRead, indexWrite uint64, err error)
ReadIndexes will take a directory, get all the index files from it and load them into an indices map while ignoring any deleted indexes
func WriteIndex ¶
writeIndex can be used to write multiple indexes
Types ¶
type Index ¶
type Index struct { DataFile string //the data file associated with the index IndexFile string //the index file associated with the index MinIndex uint64 //minimum index for the file Index uint64 //the index/key Start int64 //the file start offset Finish int64 //the file finish offset Deleted bool //whether or not the index is deleted }
Index is a type used to describe a fixed-size index of a single data entry of a store, although all fields are exported, only Index, Start, Finish and Deleted are actually stored on disk, DataFile, IndexFile, and MinIndex are populated when the index file is read in as a whole
func (*Index) MarshalBinary ¶
MarshalBinary will convert the provided index into a byte slice
func (*Index) UnmarshalBinary ¶
UnmarshalBinary will decode a slice of bytes into an index