public async Task <BerkeleyResult <Byte[]> > ReadAsync(Byte[] key) { BerkeleyError error = await base.OpenAsync().ConfigureAwait(false); if (error.HasError) { return(new BerkeleyResult <Byte[]>(error)); } var readData = new List <Byte[]>(); int offset = 0; for (; ;) { BerkeleyResult <Byte[]> result = await base.Methods.ReadPartialAsync(this, key, offset, base.BufferSize).ConfigureAwait(false); if (result.HasError) { return(result); } Byte[] value = result.Result; readData.Add(value); offset += value.Length; if (value.Length < base.BufferSize) { break; } } return(new BerkeleyResult <Byte[]>(Join(readData))); }
public async Task <BerkeleyError> OpenAsync(String name, BerkeleyDbOpenFlags flags) { BerkeleyResult <long> result = await _methods.CreateDb(this, _flags).ConfigureAwait(false); if (result.HasError) { return(result.Error); } _handle = result.Result; return(await _methods.OpenDbAsync(this, name, flags).ConfigureAwait(false)); }
protected async Task <BerkeleyError> OpenAsync() { if (_handle == InvalidHandle) { BerkeleyResult <long> result = await BerkeleyDb.Methods.OpenCursorAsync(BerkeleyDb, CursorFlags).ConfigureAwait(false); if (result.HasError) { return(result.Error); } _handle = result.Result; } return(BerkeleyError.NoError); }
public async Task <BerkeleyResult <int> > GetPageSizeAsync() { if (_pageSize == 0) { BerkeleyResult <int> result = await _methods.GetPageSizeAsync(this); if (result.Error.HasError) { return(result); } _pageSize = result.Result; } return(new BerkeleyResult <int>(_pageSize)); }
protected async Task <BerkeleyError> SetBuffer(Byte[] key, BerkeleyDbOperation operation) { BerkeleyError error = await base.OpenAsync().ConfigureAwait(false); if (error.HasError) { return(error); } BerkeleyResult <Dto.BerkeleyDtoGet> resultDtoGet = await base.Methods.GetDtoGet(this, key, operation, _multiple, base.BufferSize).ConfigureAwait(false); if (!resultDtoGet.HasError) { Dto.BerkeleyDtoGet dtoGet = resultDtoGet.Result; SetDtoGet(ref dtoGet); } return(resultDtoGet.Error); }
public async Task <BerkeleyResult <BerkeleyKeyValue> > ReadAsync(Byte[] key, BerkeleyDbOperation operation) { BerkeleyError error = await base.OpenAsync().ConfigureAwait(false); if (error.HasError) { return(new BerkeleyResult <BerkeleyKeyValue>(error)); } BerkeleyResult <Dto.BerkeleyDtoGet> resultDtoGet = await base.Methods.GetDtoGet(this, key, operation, 0, 0).ConfigureAwait(false); if (resultDtoGet.HasError) { return(new BerkeleyResult <BerkeleyKeyValue>(resultDtoGet.Error)); } var keyValue = new BerkeleyKeyValue(resultDtoGet.Result.Key, resultDtoGet.Result.Value); return(new BerkeleyResult <BerkeleyKeyValue>(keyValue)); }