diff options
Diffstat (limited to 'src/dedo.go')
-rw-r--r-- | src/dedo.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/dedo.go b/src/dedo.go index 84c8857..ae15ff2 100644 --- a/src/dedo.go +++ b/src/dedo.go @@ -918,15 +918,19 @@ func (b *bucketT) Delete(key []byte) error { return bucketDelete(b, key) } -func bytesLE(num uint64) []byte { +func ID2Bytes(num uint64) []byte { arr := make([]byte, 8) - binary.LittleEndian.PutUint64(arr, uint64(num)) + binary.LittleEndian.PutUint64(arr, num) return arr } +func Bytes2ID(bytes []byte) uint64 { + return binary.LittleEndian.Uint64(bytes) +} + func bucketNextID(b *bucketT) []byte { id := g.Must(b.NextSequence()) - return bytesLE(id) + return ID2Bytes(id) } func (b *bucketT) NextID() []byte { @@ -1939,7 +1943,7 @@ func (bucket *inMemoryValueT) Put(key []byte, value []byte) error { func (bucket *inMemoryValueT) NextID() []byte { id := g.Must(bucket.NextSequence()) - return bytesLE(id) + return ID2Bytes(id) } func (bucket *inMemoryValueT) NextSequence() (uint64, error) { |