コード例 #1
0
ファイル: FASTER.cs プロジェクト: FlorianGrimm/Latrans
        internal Status ContextReadAtAddress <Input, Output, Context, FasterSession>(long address, ref Input input, ref Output output, ReadFlags readFlags, Context context, FasterSession fasterSession, long serialNo,
                                                                                     FasterExecutionContext <Input, Output, Context> sessionCtx)
            where FasterSession : IFasterSession <Key, Value, Input, Output, Context>
        {
            var pcontext = default(PendingContext <Input, Output, Context>);

            pcontext.operationFlags = PendingContext <Input, Output, Context> .GetOperationFlags(readFlags, noKey : true);

            Key key            = default;
            var internalStatus = InternalRead(ref key, ref input, ref output, address, ref context, ref pcontext, fasterSession, sessionCtx, serialNo);

            Debug.Assert(internalStatus != OperationStatus.RETRY_NOW);

            Status status;

            if (internalStatus == OperationStatus.SUCCESS || internalStatus == OperationStatus.NOTFOUND)
            {
                status = (Status)internalStatus;
            }
            else
            {
                status = HandleOperationStatus(sessionCtx, sessionCtx, ref pcontext, fasterSession, internalStatus, false, out _);
            }

            Debug.Assert(serialNo >= sessionCtx.serialNum, "Operation serial numbers must be non-decreasing");
            sessionCtx.serialNum = serialNo;
            return(status);
        }
コード例 #2
0
ファイル: ReadAsync.cs プロジェクト: yitao-zhang/FASTER
        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));
        }