Beispiel #1
0
func (f futureKeyValueArray) Get() ([]KeyValue, bool, error) {
	f.BlockUntilReady()

	var kvs *C.FDBKeyValue
	var count C.int
	var more C.fdb_bool_t

	if err := C.fdb_future_get_keyvalue_array(f.ptr, &kvs, &count, &more); err != 0 {
		return nil, false, Error{int(err)}
	}

	ret := make([]KeyValue, int(count))

	for i := 0; i < int(count); i++ {
		kvptr := unsafe.Pointer(uintptr(unsafe.Pointer(kvs)) + uintptr(i*24))

		ret[i].Key = stringRefToSlice(kvptr)
		ret[i].Value = stringRefToSlice(unsafe.Pointer(uintptr(kvptr) + 12))
	}

	return ret, (more != 0), nil
}
Beispiel #2
0
func (f *futureKeyValueArray) GetWithError() ([]KeyValue, bool, error) {
	fdb_future_block_until_ready(f.ptr)

	var kvs *C.void
	var count C.int
	var more C.fdb_bool_t

	if err := C.fdb_future_get_keyvalue_array(f.ptr, (**C.FDBKeyValue)(unsafe.Pointer(&kvs)), &count, &more); err != 0 {
		return nil, false, Error(err)
	}

	ret := make([]KeyValue, int(count))

	for i := 0; i < int(count); i++ {
		kvptr := uintptr(unsafe.Pointer(kvs)) + uintptr(i*24)

		ret[i].Key = stringRefToSlice(kvptr)
		ret[i].Value = stringRefToSlice(kvptr + 12)

	}

	return ret, (more != 0), nil
}