Documentation ¶
Overview ¶
For key value stores where buckets are not supported, we add a byte to the key to represent a bucket. For now, all buckets are hard coded, but we could change that in the future.
Buckets are not really enough to index everything we wish to index. So we have labels as well. Labels are shifted 8 bits left, so they can be combined with the buckets to create a unique key.
This allows us to put the raw directory block at DBlockBucket+L_raw, and meta data about the directory block at DBlockBucket+MetaLabel
Index ¶
- Constants
- func BoolBytes(b bool) []byte
- func BytesBool(data []byte) (f bool, newData []byte)
- func BytesInt64(data []byte) (int64, []byte)
- func BytesUint16(data []byte) (uint16, []byte)
- func BytesUint32(data []byte) (uint32, []byte)
- func BytesUint64(data []byte) (uint64, []byte)
- func FormatTimeLapse(d time.Duration) string
- func FormatTimeLapseSeconds(total int64) string
- func GetHomeDir() string
- func Int64Bytes(i int64) []byte
- func Uint16Bytes(i uint16) []byte
- func Uint32Bytes(i uint32) []byte
- func Uint64Bytes(i uint64) []byte
- type KeyValueDB
- type TX
Constants ¶
const (
KeyLength = 32 // Total bytes used for keys
)
Variables ¶
This section is empty.
Functions ¶
func BytesInt64 ¶
BytesInt64 Unmarshal a int64 (big endian) We only need this function on top of BytesUint64 to avoid a type conversion when dealing with int64 values
func BytesUint16 ¶
BytesUint16 Unmarshal a uint32 (big endian)
func BytesUint32 ¶
BytesUint32 Unmarshal a uint32 (big endian)
func BytesUint64 ¶
BytesUint64 Unmarshal a uint64 (big endian)
func FormatTimeLapse ¶
DurationFormat Simple formatting for duration time. Prints all results within a fixed field of text.
func FormatTimeLapseSeconds ¶
DurationFormat Simple formatting if what I have is seconds. Prints all results within a fixed field of text.
func GetHomeDir ¶
func GetHomeDir() string
GetHomeDir Used to find the Home Directory from which the configuration directory for the ValAcc application to use for its database. This is not a terribly refined way of configuring the ValAcc and may be refined in the future.
func Int64Bytes ¶
Int64Bytes Marshal a int64 (big endian) We only need this function on top of Uint64Bytes to avoid a type conversion when dealing with int64 values
Types ¶
type KeyValueDB ¶
type KeyValueDB interface { Close() error // Returns an error if the close fails InitDB(filepath string) error // Sets up the database, returns error if it fails Get(key [KeyLength]byte) (value []byte) // Get key from database, on not found, error returns nil Put(key [KeyLength]byte, value []byte) error // Put the value in the database, throws an error if fails PutBatch(TXs []TX) error // End and commit a batch of transactions }