func (t *T) rand_varchar(min, max int) []byte { bytes := t.rand_bytes(4) s := slice.AsSlice(&bytes) length := int(*(*uint32)(s.Array)) length = (length % (max)) + min return t.rand_bytes(length) }
func new_ctrlblk(bytes []byte, blksize uint32) (cb *ctrlblk) { back := slice.AsSlice(&bytes) cb = (*ctrlblk)(back.Array) cb.meta.blksize = blksize cb.meta.free_head = 0 cb.meta.free_len = 0 MemClr(cb.user[:]) return cb }
func (n *internal) ptrs_uint64s() []uint64 { keySize := int(n.meta.keySize) keyCap := int(n.meta.keyCap) s := keyCap * keySize e := s + keyCap*ptrSize bytes := n.bytes[s:e] sl := slice.AsSlice(&bytes) sl.Len = int(n.meta.keyCount) sl.Cap = sl.Len return *sl.AsUint64s() }
func (self *BlockFile) zero(offset uint64, n int) (uint64, error) { for i := 0; i < n; i++ { err := self.Do(offset+uint64(i*self.blksize), 1, func(block []byte) error { ptr := slice.AsSlice(&block).Array memClr(ptr, uintptr(len(block))) return nil }) if err != nil { return 0, err } } return offset, nil }
func loadBaseMeta(backing []byte) *baseMeta { back := slice.AsSlice(&backing) return (*baseMeta)(back.Array) }
func asInternal(backing []byte) *internal { back := slice.AsSlice(&backing) return (*internal)(back.Array) }
// Zero the bytes of the passed in slice. It uses the length not the // capacity of the slice. It uses the libc function memset under the // hood to do this. Go has an implementation of this function in // assembly in the runtime package but I could not find a nice way to // expose it. So here is the libc version exposed (via several method // calls and the cgo interface). func MemClr(bytes []byte) { memClr(slice.AsSlice(&bytes).Array, uintptr(len(bytes))) }
func load_ctrlblk(bytes []byte) (cb *ctrlblk, err error) { back := slice.AsSlice(&bytes) cb = (*ctrlblk)(back.Array) return cb, nil }
func asCtrl(backing []byte) *varCtrl { assert_len(backing, varCtrlSize) back := slice.AsSlice(&backing) return (*varCtrl)(back.Array) }
func loadFreeBlk(bytes []byte) *freeblk { free_s := slice.AsSlice(&bytes) return (*freeblk)(free_s.Array) }
func AsFlag(bytes []byte) Flag { back := slice.AsSlice(&bytes) return *(*Flag)(back.Array) }
func (t *T) key(bytes []byte) uint64 { t.assert("bytes must have length 8", len(bytes) == 8) s := slice.AsSlice(&bytes) return *(*uint64)(s.Array) }
func asRunMeta(backing []byte) *varRunMeta { assert_len(backing, varRunMetaSize) back := slice.AsSlice(&backing) return (*varRunMeta)(back.Array) }
func asFree(backing []byte) *varFree { assert_len(backing, varFreeSize) back := slice.AsSlice(&backing) return (*varFree)(back.Array) }
func loadLeafMeta(backing []byte) *leafMeta { back := slice.AsSlice(&backing) return (*leafMeta)(back.Array) }
func asLeaf(backing []byte) *leaf { back := slice.AsSlice(&backing) return (*leaf)(back.Array) }
func (l *List) asIdx(bytes []byte) *idxBlk { assert_len(bytes, ctrlBlkSize) back := slice.AsSlice(&bytes) return (*idxBlk)(back.Array) }