public BerkeleyBulkEnumerator(BerkeleyError error)
        {
            _error = error;

            _cursor  = null;
            _current = new BerkeleyKeyValueBulk();
        }
        public BerkeleyBulkEnumerator(BerkeleyBulkCursorBase cursor)
        {
            _cursor = cursor;

            _current = new BerkeleyKeyValueBulk();
            _error   = BerkeleyError.NoError;
        }
        public async Task <BerkeleyError> WriteAsync(Byte[] key, Byte[] value)
        {
            BerkeleyError error = await base.OpenAsync().ConfigureAwait(false);

            if (error.HasError)
            {
                return(error);
            }

            int offset = 0;

            do
            {
                int bufferSize = Math.Min(value.Length - offset, base.BufferSize);
                error = await base.Methods.WritePartialAsync(this, key, value, offset, bufferSize).ConfigureAwait(false);

                if (error.HasError)
                {
                    return(error);
                }

                offset += bufferSize;
            }while (offset < value.Length);

            return(BerkeleyError.NoError);
        }
        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)));
        }
Exemplo n.º 5
0
        public async Task <BerkeleyError> DeleteCurrentAsync(BerkeleyDbDelete flag = 0)
        {
            BerkeleyError error = await OpenAsync().ConfigureAwait(false);

            if (error.HasError)
            {
                return(error);
            }

            return(await Methods.DeleteCurrentAsync(this, flag).ConfigureAwait(false));
        }
Exemplo n.º 6
0
        public async Task <BerkeleyError> CloseAsync()
        {
            if (_handle == InvalidHandle)
            {
                return(BerkeleyError.NoError);
            }

            BerkeleyError error = await _methods.CloseCursorAsync(this).ConfigureAwait(false);

            _handle = InvalidHandle;
            return(error);
        }
        public async Task <BerkeleyError> WriteAsync(BerkeleyDbWriteMode writeMode)
        {
            CloseWriteBuffer();
            foreach (Dto.BerkeleyDtoPut data in _writeData)
            {
                BerkeleyError error = await base.BerkeleyDb.Methods.WriteDuplicateAsync(base.BerkeleyDb, data, _writeKeyBuffer.BufferSize, writeMode).ConfigureAwait(false);

                if (error.HasError)
                {
                    return(error);
                }
            }
            _writeData.Clear();
            return(BerkeleyError.NoError);
        }
Exemplo n.º 8
0
        public async Task <BerkeleyError> CloseAsync(BerkeleyDbClose flags)
        {
            if (_handle == InvalidHandle)
            {
                return(BerkeleyError.NoError);
            }

            BerkeleyError error = await _methods.CloseDbAsync(this, flags).ConfigureAwait(false);

            if (!error.HasError)
            {
                _handle = InvalidHandle;
            }
            return(error);
        }
        public async Task <BerkeleyError> DeleteAsync()
        {
            CloseDeleteBuffer();

            foreach (Byte[] data in _deleteData)
            {
                BerkeleyError error = await base.BerkeleyDb.DeleteAsync(data, 0, BerkeleyDbMultiple.DB_MULTIPLE_KEY).ConfigureAwait(false);

                if (error.HasError)
                {
                    return(error);
                }
            }

            _deleteData.Clear();
            return(BerkeleyError.NoError);
        }
        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));
        }
Exemplo n.º 12
0
 public BerkeleyResult(BerkeleyDbError berkeleyDbError, T result)
 {
     _error  = new BerkeleyError(berkeleyDbError);
     _result = result;
 }
Exemplo n.º 13
0
 public BerkeleyResult(T result)
 {
     _result = result;
     _error  = BerkeleyError.NoError;
 }
Exemplo n.º 14
0
 public BerkeleyResult(HttpStatusCode httpStatusCode)
 {
     _error  = new BerkeleyError(httpStatusCode);
     _result = default(T);
 }
Exemplo n.º 15
0
 public BerkeleyResult(BerkeleyDbError berkeleyDbError)
 {
     _error  = new BerkeleyError(berkeleyDbError);
     _result = default(T);
 }
        public async Task <BerkeleyBulkEnumerator> ReadAsync(Byte[] key, BerkeleyDbOperation operation)
        {
            BerkeleyError error = await SetBuffer(key, operation).ConfigureAwait(false);

            return(error.HasError ? new BerkeleyBulkEnumerator(error) : new BerkeleyBulkEnumerator(this));
        }
Exemplo n.º 17
0
 public BerkeleyResult(BerkeleyError error)
 {
     _error  = error;
     _result = default(T);
 }