Ejemplo n.º 1
0
 internal void SetOperationFlags(ReadFlags readFlags, ref ReadOptions readOptions, bool noKey = false)
 => this.SetOperationFlags(GetOperationFlags(readFlags, noKey), readOptions.StopAddress);
Ejemplo n.º 2
0
        public ValueTask <FasterKV <Key, Value> .ReadAsyncResult <Input, Output, Context> > ReadAtAddressAsync(ref Input input, ref ReadOptions readOptions,
                                                                                                               Context userContext = default, long serialNo = 0, CancellationToken cancellationToken = default)
        {
            Debug.Assert(!clientSession.fht.epoch.ThisInstanceProtected());
            Key key = default;

            return(clientSession.fht.ReadAsync(FasterSession, clientSession.ctx, ref key, ref input, ref readOptions, userContext, serialNo, cancellationToken, noKey: true));
        }
Ejemplo n.º 3
0
 public Status Read(ref Key key, ref Input input, ref Output output, ref ReadOptions readOptions, out RecordMetadata recordMetadata, Context userContext = default, long serialNo = 0)
 {
     Debug.Assert(clientSession.fht.epoch.ThisInstanceProtected());
     return(clientSession.fht.ContextRead(ref key, ref input, ref output, ref readOptions, out recordMetadata, userContext, FasterSession, serialNo, clientSession.ctx));
 }
Ejemplo n.º 4
0
 public Status ReadAtAddress(ref Input input, ref Output output, ref ReadOptions readOptions, Context userContext = default, long serialNo = 0)
 {
     Debug.Assert(clientSession.fht.epoch.ThisInstanceProtected());
     return(clientSession.fht.ContextReadAtAddress(ref input, ref output, ref readOptions, userContext, FasterSession, serialNo, clientSession.ctx));
 }
Ejemplo n.º 5
0
        internal ValueTask <ReadAsyncResult <Input, Output, Context> > ReadAsync <Input, Output, Context>(IFasterSession <Key, Value, Input, Output, Context> fasterSession,
                                                                                                          FasterExecutionContext <Input, Output, Context> currentCtx,
                                                                                                          ref Key key, ref Input input, ref ReadOptions readOptions, Context context, long serialNo, CancellationToken token, bool noKey = false)
        {
            var pcontext       = default(PendingContext <Input, Output, Context>);
            var operationFlags = PendingContext <Input, Output, Context> .GetOperationFlags(MergeReadFlags(currentCtx.ReadFlags, readOptions.ReadFlags), noKey);

            pcontext.SetOperationFlags(operationFlags, readOptions.StopAddress);
            var    diskRequest = default(AsyncIOContext <Key, Value>);
            Output output      = default;

            fasterSession.UnsafeResumeThread();
            try
            {
                OperationStatus internalStatus;
                do
                {
                    internalStatus = InternalRead(ref key, ref input, ref output, readOptions.StartAddress, ref context, ref pcontext, fasterSession, currentCtx, serialNo);
                }while (internalStatus == OperationStatus.RETRY_NOW);
                Debug.Assert(internalStatus != OperationStatus.RETRY_LATER);

                if (OperationStatusUtils.TryConvertToStatusCode(internalStatus, out Status status))
                {
                    return(new ValueTask <ReadAsyncResult <Input, Output, Context> >(new ReadAsyncResult <Input, Output, Context>(new(internalStatus), output, new RecordMetadata(pcontext.recordInfo, pcontext.logicalAddress))));
                }

                status = HandleOperationStatus(currentCtx, currentCtx, ref pcontext, fasterSession, internalStatus, true, out diskRequest);
                if (!status.IsPending)
                {
                    return(new ValueTask <ReadAsyncResult <Input, Output, Context> >(new ReadAsyncResult <Input, Output, Context>(status, output, new RecordMetadata(pcontext.recordInfo, pcontext.logicalAddress))));
                }
            }
            finally
            {
                Debug.Assert(serialNo >= currentCtx.serialNum, "Operation serial numbers must be non-decreasing");
                currentCtx.serialNum = serialNo;
                fasterSession.UnsafeSuspendThread();
            }

            return(SlowReadAsync(this, fasterSession, currentCtx, pcontext, diskRequest, token));
        }