Skip to content

Commit

Permalink
Update FasterLog.md
Browse files Browse the repository at this point in the history
  • Loading branch information
badrishc authored Nov 26, 2019
1 parent ff51d3c commit 237c227
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions docs/cs/FasterLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ segments corresponding to files on disk. Each segment consists of a fixed number
and pages sizes are configurable during construction of FasterLog. By default,
FasterLog commits at page boundaries. You can also force-commit the log as frequently as you need, e.g., every
5ms. The typical use cases of FasterLog are captured in our extremely detailed commented sample [here](https://github.com/microsoft/FASTER/blob/master/cs/playground/FasterLogSample/Program.cs). FasterLog
works with .NET Standard 2.0, and can be used on a broad range of machines and devices.
works with .NET Standard 2.0, and can be used on a broad range of machines and devices. We have tested
it on both Windows and Linux-based machines.

## Creating the Log

Expand Down Expand Up @@ -130,9 +131,19 @@ end of iteration, or because we are waiting for a page read or commit to complet
For tailing iteration, you simply specify `long.MaxValue` as the end address for the scan. You are guaranteed
to see only committed entries during a tailing iteration.

You can persist iterators as part of commit by simply naming them during their creation. On recovery, if an
iterator with the specified name exists, it will be initialized with the corresponding current iterator
pointer.
An iterator is associated with a `CompletedUntilAddress` which indicates until what address the iteration has been
completed. Users update the `CompletedUntilAddress` as follows:

```cs
iter.CompleteUntil(long address);
```

The specified address needs to be a valid log address, similar to the `TruncateUntil` call on the log, described
earlier.

You can persist iterators (or more precisely, their `CompletedUntilAddress`) as part of a commit by simply naming
them during their creation. On recovery, if an iterator with the specified name exists, it will be initialized with
its last-committed `CompletedUntilAddress` as the current iterator pointer.

```cs
using (var iter = log.Scan(0, long.MaxValue, name: "foo"))
Expand All @@ -149,10 +160,18 @@ using (var iter = log.Scan(0, long.MaxValue, name: "foo", recover: false))

FasterLog support log head truncation, until any prefix of the log. Truncation updates the log begin address and
deletes truncated parts of the log from disk, if applicable. A truncation is persisted via commit, similar
to tail address commit. Here is an example, where we truncate the log to limit it to the last 100GB:
to tail address commit.

There are two variants: `TruncateUntilPageStart` truncates until the start of the page corresponding to the
specified address. This is safe to invoke with any address, as the page start is always a valid pointer to the
log. The second variant, called `TruncateUntil`, truncates exactly until the specified address. Here, the user
needs to be careful and provide a valid address that points to a log entry. For example, any address returned by
an iterator is a valid location that one could truncate until.

Here is an example, where we truncate the log to limit it to the last 100GB:

```cs
log.TruncateUntil(log.CommittedUntilAddress - 100_000_000_000L);
log.TruncateUntilPageStart(log.CommittedUntilAddress - 100_000_000_000L);
```

### Random Read
Expand Down

0 comments on commit 237c227

Please sign in to comment.