Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C#] Added store.Log.FixedRecordSize API #399

Merged
merged 1 commit into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cs/src/core/Allocator/AllocatorBase.cs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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