Esempio n. 1
0
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)
}
Esempio n. 2
0
File: fmap.go Progetto: postfix/fs2
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
}
Esempio n. 3
0
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()
}
Esempio n. 4
0
File: fmap.go Progetto: postfix/fs2
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
}
Esempio n. 5
0
func loadBaseMeta(backing []byte) *baseMeta {
	back := slice.AsSlice(&backing)
	return (*baseMeta)(back.Array)
}
Esempio n. 6
0
func asInternal(backing []byte) *internal {
	back := slice.AsSlice(&backing)
	return (*internal)(back.Array)
}
Esempio n. 7
0
File: fmap.go Progetto: postfix/fs2
// 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)))
}
Esempio n. 8
0
File: fmap.go Progetto: postfix/fs2
func load_ctrlblk(bytes []byte) (cb *ctrlblk, err error) {
	back := slice.AsSlice(&bytes)
	cb = (*ctrlblk)(back.Array)
	return cb, nil
}
Esempio n. 9
0
func asCtrl(backing []byte) *varCtrl {
	assert_len(backing, varCtrlSize)
	back := slice.AsSlice(&backing)
	return (*varCtrl)(back.Array)
}
Esempio n. 10
0
File: fmap.go Progetto: postfix/fs2
func loadFreeBlk(bytes []byte) *freeblk {
	free_s := slice.AsSlice(&bytes)
	return (*freeblk)(free_s.Array)
}
Esempio n. 11
0
File: const.go Progetto: postfix/fs2
func AsFlag(bytes []byte) Flag {
	back := slice.AsSlice(&bytes)
	return *(*Flag)(back.Array)
}
Esempio n. 12
0
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)
}
Esempio n. 13
0
func asRunMeta(backing []byte) *varRunMeta {
	assert_len(backing, varRunMetaSize)
	back := slice.AsSlice(&backing)
	return (*varRunMeta)(back.Array)
}
Esempio n. 14
0
func asFree(backing []byte) *varFree {
	assert_len(backing, varFreeSize)
	back := slice.AsSlice(&backing)
	return (*varFree)(back.Array)
}
Esempio n. 15
0
func loadLeafMeta(backing []byte) *leafMeta {
	back := slice.AsSlice(&backing)
	return (*leafMeta)(back.Array)
}
Esempio n. 16
0
func asLeaf(backing []byte) *leaf {
	back := slice.AsSlice(&backing)
	return (*leaf)(back.Array)
}
Esempio n. 17
0
File: list.go Progetto: postfix/fs2
func (l *List) asIdx(bytes []byte) *idxBlk {
	assert_len(bytes, ctrlBlkSize)
	back := slice.AsSlice(&bytes)
	return (*idxBlk)(back.Array)
}