Deedle


Ranges

Namespace: Deedle.Ranges

Provides F# functions for working with the Ranges<'T> type. Note that most of the functions are also exposed as members. The terminology in the functions below is:

  • offset refers to an absolute int64 offset of a key in the range
  • key refers to a key value of type 'T

Say, you have daily range [ (2015-01-01, 2015-01-10); (2015-02-01, 2015-02-10) ]. Then, the keys are the dates and the offsets are 0 .. 9 for the first part and 10 .. 19 for the second part.

Functions and values

Function or valueDescription
combine(ranges)
Signature: ranges:seq<Ranges<'T>> -> Ranges<'T>
Type parameters: 'T

Combine ranges - the arguments don't have to be sorted, but must not overlap (they can be aligned, in which case ranges are merged)

create ops ranges
Signature: ops:IRangeKeyOperations<'T> -> ranges:seq<'T * 'T> -> Ranges<'T>
Type parameters: 'T

Create a range from a sequence of low-high pairs and an explicitly specified range key operations

inlineCreate succ ranges
Signature: succ:(^T -> int64 -> ^T) -> ranges:seq<^T * ^T> -> Ranges<^T>
Type parameters: ^T

Create a range from a sequence of low-high pairs (range key operations used standard arithmetic)

invalid
Signature: int64

Represents invalid offset

keyAtOffset offs ranges
Signature: offs:int64 -> ranges:Ranges<'T> -> 'T
Type parameters: 'T

Returns the key at a given offset. For example, given ranges [10..12; 30..32], the function defines a mapping:

0->10, 1->11, 2->12, 3->30, 4->31, 5->32

When the offset is wrong, throws IndexOutOfRangeException

keyRange(ranges)
Signature: ranges:Ranges<'T> -> 'T * 'T
Type parameters: 'T

Returns the smallest & greatest overall key

keys(ranges)
Signature: ranges:Ranges<'T> -> seq<'T>
Type parameters: 'T

Returns a lazy sequence containing all keys

length(ranges)
Signature: ranges:Ranges<'T> -> int64
Type parameters: 'T

Returns the length of the ranges

lookup key semantics check ranges
Signature: key:'T -> semantics:Lookup -> check:('T -> int64 -> bool) -> ranges:Ranges<'T> -> OptionalValue<'T * int64>
Type parameters: 'T

Implements a lookup using the specified semantics & check function. For Exact match, this is the same as offsetOfKey. In other cases, we first find the place where the key would be and then scan in one or the other direction until 'check' returns 'true' or we find the end.

Returns the key together with its offset in the range.

offsetOfKey key ranges
Signature: key:'T -> ranges:Ranges<'T> -> int64
Type parameters: 'T

Returns the offset of a given key. For example, given ranges [10..12; 30..32], the function defines a mapping:

10->0, 11->1, 12->2, 30->3, 31->4, 32->5

When the key is wrong, returns Ranges.invalid

restrictRanges restriction ranges
Signature: restriction:RangeRestriction<'T> -> ranges:Ranges<'T> -> Ranges<'T>
Type parameters: 'T

Restricts the ranges according to the specified range restriction

Fork me on GitHub