Skip to content

Commit

Permalink
Added store.Log.FixedRecordSize API to get the size per record (only …
Browse files Browse the repository at this point in the history
…fixed-size part) on the main log. (#399)
  • Loading branch information
badrishc committed Feb 5, 2021
1 parent c44fe36 commit 0549188
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cs/src/core/Allocator/AllocatorBase.cs
Expand Up @@ -334,6 +334,12 @@ public abstract (int, int) GetRecordSize<Input, FasterSession>(long physicalAddr
/// <returns></returns>
public abstract int GetAverageRecordSize();

/// <summary>
/// Get size of fixed (known) part of record on the main log
/// </summary>
/// <returns></returns>
public abstract int GetFixedRecordSize();

/// <summary>
/// Get initial record size
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions cs/src/core/Allocator/BlittableAllocator.cs
Expand Up @@ -75,6 +75,8 @@ public override int GetAverageRecordSize()
return recordSize;
}

public override int GetFixedRecordSize() => recordSize;

public override (int, int) GetInitialRecordSize<Input, FasterSession>(ref Key key, ref Input input, FasterSession fasterSession)
{
return (recordSize, recordSize);
Expand Down
2 changes: 2 additions & 0 deletions cs/src/core/Allocator/GenericAllocator.cs
Expand Up @@ -160,6 +160,8 @@ public override int GetAverageRecordSize()
return recordSize;
}

public override int GetFixedRecordSize() => recordSize;

public override (int, int) GetInitialRecordSize<Input, FasterSession>(ref Key key, ref Input input, FasterSession fasterSession)
{
return (recordSize, recordSize);
Expand Down
7 changes: 7 additions & 0 deletions cs/src/core/Allocator/VarLenBlittableAllocator.cs
Expand Up @@ -158,6 +158,13 @@ public override int GetAverageRecordSize()
((ValueLength.GetInitialLength() + kRecordAlignment - 1) & (~(kRecordAlignment - 1)));
}

public override int GetFixedRecordSize()
{
return RecordInfo.GetLength()
+ (fixedSizeKey ? KeyLength.GetInitialLength() : 0)
+ (fixedSizeValue ? ValueLength.GetInitialLength() : 0);
}

public override (int, int) GetInitialRecordSize<TInput, FasterSession>(ref Key key, ref TInput input, FasterSession fasterSession)
{
var actualSize = RecordInfo.GetLength() +
Expand Down
8 changes: 8 additions & 0 deletions cs/src/core/Index/FASTER/LogAccessor.cs
Expand Up @@ -53,6 +53,14 @@ public LogAccessor(FasterKV<Key, Value> fht, AllocatorBase<Key, Value> allocator
/// </summary>
public long BeginAddress => allocator.BeginAddress;

/// <summary>
/// Get the bytes used on the primary log by every record. Does not include
/// the size of variable-length inline data. Note that class objects occupy
/// 8 bytes (reference) on the main log (i.e., the heap space occupied by
/// class objects is not included in the result of this call).
/// </summary>
public int FixedRecordSize => allocator.GetFixedRecordSize();

/// <summary>
/// Truncate the log until, but not including, untilAddress. Make sure address corresponds to record boundary if snapToPageStart is set to false.
/// </summary>
Expand Down

0 comments on commit 0549188

Please sign in to comment.