Esempio n. 1
0
        public async Task <FdbRangeChunk> GetRangeAsync(FdbKeySelector beginInclusive, FdbKeySelector endExclusive, FdbRangeOptions options, int iteration, bool snapshot, CancellationToken cancellationToken)
        {
            Contract.Requires(beginInclusive.Key.HasValue && endExclusive.Key.HasValue && options != null);

            cancellationToken.ThrowIfCancellationRequested();

            //TODO: check system keys

            //Trace.WriteLine("## GetRange " + beginInclusive + " <= k < " + endExclusive + ", limit=" + options.Limit + ", reverse=" + options.Reverse + ", snapshot=" + snapshot);

            lock (m_buffer)
            {
                beginInclusive = m_buffer.InternSelector(beginInclusive);
                endExclusive   = m_buffer.InternSelector(endExclusive);
            }

            // we need the read version
            EnsureHasReadVersion();

            options = FdbRangeOptions.EnsureDefaults(options, null, null, FdbStreamingMode.Iterator, false);
            options.EnsureLegalValues();

            var result = await m_db.GetRangeAtVersion(beginInclusive, endExclusive, options.Limit ?? 0, options.TargetBytes ?? 0, options.Mode.Value, iteration, options.Reverse.Value, m_readVersion.Value).ConfigureAwait(false);

            if (!snapshot)
            {
                lock (m_lock)
                {
                    //TODO: use the result to create the conflict range (between the resolver key and the returned key)
                    //AddReadConflict_NeedsLocking(range);
                }
            }
            return(result);
        }