MCPcopy Index your code
hub / github.com/ByteStorage/FlyDB / encodeHashMeta

Method encodeHashMeta

structure/hash.go:1503–1519  ·  view source on GitHub ↗

EncodeHashMeta encodes a HashMetadata and returns the byte array and length. +-------------+------------+------------+------------+---------+----------+----------+---------+---------+ | data type | data size | expire | version | counter | created | updated | field | value | +--------

()

Source from the content-addressed store, hash-verified

1501// | 1 byte | variable | variable | variable | variable| variable | variable | variable| variable|
1502// +-------------+------------+------------+------------+---------+----------+----------+---------+---------+
1503func (meta *HashMetadata) encodeHashMeta() []byte {
1504 buf := make([]byte, maxHashMetaSize)
1505
1506 // Store the data type at the first byte
1507 buf[0] = meta.dataType
1508
1509 var offset = 1
1510
1511 // Store the lengths of data size, expire, version, counter, createdTime and lastUpdatedTime
1512 offset += binary.PutVarint(buf[offset:], meta.dataSize)
1513 offset += binary.PutVarint(buf[offset:], meta.expire)
1514 offset += binary.PutVarint(buf[offset:], meta.version)
1515 offset += binary.PutVarint(buf[offset:], meta.counter)
1516 offset += binary.PutVarint(buf[offset:], meta.createdTime)
1517 offset += binary.PutVarint(buf[offset:], meta.lastUpdatedTime)
1518 return buf[:offset]
1519}
1520
1521// DecodeHashMeta decodes the HashMetadata from a byte buffer.
1522func decodeHashMeta(buf []byte) *HashMetadata {

Callers 3

HSetMethod · 0.80
HDelMethod · 0.80
HExpireMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected