/// <summary>Add all missing values from the provided defaults</summary> /// <param name="options">Options provided by the caller (can be null)</param> /// <param name="limit">Default value for Limit if not provided</param> /// <param name="targetBytes">Default TargetBytes for limit if not provided</param> /// <param name="mode">Default value for Streaming mode if not provided</param> /// <param name="read">Default value for Read mode if not provided</param> /// <param name="reverse">Default value for Reverse if not provided</param> /// <returns>Options with all the values filled</returns> public static FdbRangeOptions EnsureDefaults(FdbRangeOptions?options, int?limit, int?targetBytes, FdbStreamingMode mode, FdbReadMode read, bool reverse) { Contract.Debug.Requires((limit ?? 0) >= 0 && (targetBytes ?? 0) >= 0); if (options == null) { options = new FdbRangeOptions() { Limit = limit, TargetBytes = targetBytes, Mode = mode, Reverse = reverse, Read = read, }; } else if (options.Limit == null || options.TargetBytes == null || options.Mode == null || options.Reverse == null || options.Read == null) { options = new FdbRangeOptions { Limit = options.Limit ?? limit, TargetBytes = options.TargetBytes ?? targetBytes, Mode = options.Mode ?? mode, Read = options.Read ?? read, Reverse = options.Reverse ?? reverse }; } Contract.Debug.Ensures(options.Mode != null && options.Reverse != null); Contract.Debug.Ensures((options.Limit ?? 0) >= 0, "Limit cannot be negative"); Contract.Debug.Ensures((options.TargetBytes ?? 0) >= 0, "TargetBytes cannot be negative"); Contract.Debug.Ensures(options.Mode.HasValue && Enum.IsDefined(typeof(FdbStreamingMode), options.Mode.Value), "Streaming mode must be valid"); Contract.Debug.Ensures(options.Read.HasValue && Enum.IsDefined(typeof(FdbReadMode), options.Read.Value), "Reading mode must be valid"); return(options); }
public GetRangeCommand(KeySelector begin, KeySelector end, FdbRangeOptions?options, int iteration) { this.Begin = begin; this.End = end; this.Options = options; this.Iteration = iteration; }
public static FdbRangeQuery <KeyValuePair <Slice, Slice> > GetRangeStartsWith(this IFdbReadOnlyTransaction trans, IKeySubspace subspace, FdbRangeOptions?options = null) { //REVIEW: should we remove this method? Contract.Debug.Requires(trans != null && subspace != null); return(trans.GetRange(subspace.ToRange(), options)); }
public static FdbQueryRangeExpression RangeStartsWith(IVarTuple tuple, FdbRangeOptions?options = null) { return(RangeStartsWith(TuPack.Pack(tuple), options)); }
/// <summary>Execute a Range read from the database, and return all the keys and values</summary> public static FdbQueryRangeExpression RangeStartsWith(Slice prefix, FdbRangeOptions?options = null) { // starts_with('A') means ['A', B') return(Range(KeySelectorPair.StartsWith(prefix), options)); }
/// <summary>Execute a Range read from the database, and return all the keys and values</summary> public static FdbQueryRangeExpression Range(KeySelector start, KeySelector stop, FdbRangeOptions?options = null) { return(Range(new KeySelectorPair(start, stop), options)); }
/// <summary>Execute a Range read from the database, and return all the keys and values</summary> public static FdbQueryRangeExpression Range(KeySelectorPair range, FdbRangeOptions?options = null) { return(new FdbQueryRangeExpression(range, options)); }
/// <summary>Construct a query with a set of initial settings</summary> internal FdbRangeQuery(IFdbReadOnlyTransaction transaction, KeySelector begin, KeySelector end, Func <KeyValuePair <Slice, Slice>, T> transform, bool snapshot, FdbRangeOptions?options) { Contract.Requires(transaction != null && transform != null); this.Transaction = transaction; this.Begin = begin; this.End = end; this.Transform = transform; this.Snapshot = snapshot; this.Options = options ?? new FdbRangeOptions(); this.OriginalRange = KeySelectorPair.Create(begin, end); }
/// <summary>Create a query that will attempt to read all the entries in the map within a single transaction.</summary> /// <param name="trans">Transaction used for the operation</param> /// <param name="options"></param> /// <returns>Async sequence of pairs of keys and values, ordered by keys ascending.</returns> /// <remarks>CAUTION: This can be dangerous if the map contains a lot of entries! You should always use .Take() to limit the number of results returned.</remarks> public IAsyncEnumerable <KeyValuePair <TKey, TValue> > All(IFdbReadOnlyTransaction trans, FdbRangeOptions?options = null) { if (trans == null) { throw new ArgumentNullException(nameof(trans)); } return(trans .GetRange(this.Subspace.ToRange(), options) .Select(kv => DecodeItem(this.Subspace, this.ValueEncoder, kv))); }
public FdbRangeQuery <TResult> GetRange <TResult>(KeySelector beginInclusive, KeySelector endExclusive, Func <KeyValuePair <Slice, Slice>, TResult> selector, FdbRangeOptions?options = null) { return(m_parent.GetRangeCore(beginInclusive, endExclusive, options, snapshot: true, selector)); }
public FdbRangeQuery <KeyValuePair <Slice, Slice> > GetRange(KeySelector beginInclusive, KeySelector endExclusive, FdbRangeOptions?options = null) { return(m_parent.GetRangeCore(beginInclusive, endExclusive, options, snapshot: true, kv => kv)); }
public Task <FdbRangeChunk> GetRangeAsync(KeySelector beginInclusive, KeySelector endExclusive, FdbRangeOptions?options, int iteration) { int limit = options?.Limit ?? 0; bool reverse = options?.Reverse ?? false; int targetBytes = options?.TargetBytes ?? 0; var mode = options?.Mode ?? FdbStreamingMode.Iterator; var read = options?.Read ?? FdbReadMode.Both; return(GetRangeAsync(beginInclusive, endExclusive, limit, reverse, targetBytes, mode, read, iteration)); }
internal FdbQueryRangeExpression(KeySelectorPair range, FdbRangeOptions?options) { this.Range = range; this.Options = options; }