Skip to content

Commit

Permalink
Avoid interface usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoganand Rajasekaran committed May 10, 2024
1 parent 233984d commit f0c6a34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions libs/server/Storage/SizeTracker/CacheSizeTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace Garnet.server
/// </summary>
public class CacheSizeTracker
{
internal readonly LogSizeTracker<byte[], IGarnetObject, ILogSizeCalculator<byte[], IGarnetObject>> mainLogTracker;
internal readonly LogSizeTracker<byte[], IGarnetObject, ILogSizeCalculator<byte[], IGarnetObject>> readCacheTracker;
internal readonly LogSizeTracker<byte[], IGarnetObject, LogSizeCalculator> mainLogTracker;
internal readonly LogSizeTracker<byte[], IGarnetObject, LogSizeCalculator> readCacheTracker;
internal long targetSize;

private const int deltaFraction = 10; // 10% of target size
Expand Down Expand Up @@ -61,15 +61,15 @@ public CacheSizeTracker(TsavoriteKV<byte[], IGarnetObject> store, LogSettings lo

var (mainLogTargetSizeBytes, readCacheTargetSizeBytes) = CalculateLogTargetSizeBytes(targetSize);

this.mainLogTracker = new LogSizeTracker<byte[], IGarnetObject, ILogSizeCalculator<byte[], IGarnetObject>>(store.Log, logSizeCalculator,
this.mainLogTracker = new LogSizeTracker<byte[], IGarnetObject, LogSizeCalculator>(store.Log, logSizeCalculator,
mainLogTargetSizeBytes, mainLogTargetSizeBytes / deltaFraction, loggerFactory?.CreateLogger("ObjSizeTracker"));
store.Log.SubscribeEvictions(mainLogTracker);
store.Log.SubscribeDeserializations(new LogOperationObserver<byte[], IGarnetObject>(mainLogTracker, LogOperationType.Deserialize));
store.Log.SubscribeDeserializations(new LogOperationObserver<byte[], IGarnetObject, LogSizeCalculator>(mainLogTracker, LogOperationType.Deserialize));
store.Log.IsSizeBeyondLimit = () => mainLogTracker.IsSizeBeyondLimit;

if (store.ReadCache != null)
{
this.readCacheTracker = new LogSizeTracker<byte[], IGarnetObject, ILogSizeCalculator<byte[], IGarnetObject>>(store.ReadCache, logSizeCalculator,
this.readCacheTracker = new LogSizeTracker<byte[], IGarnetObject, LogSizeCalculator>(store.ReadCache, logSizeCalculator,
readCacheTargetSizeBytes, readCacheTargetSizeBytes / deltaFraction, loggerFactory?.CreateLogger("ObjReadCacheSizeTracker"));
store.ReadCache.SubscribeEvictions(readCacheTracker);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ public enum LogOperationType
Deserialize
}

public class LogOperationObserver<Key, Value> : IObserver<ITsavoriteScanIterator<Key, Value>>
public class LogOperationObserver<Key, Value, TLogSizeCalculator> : IObserver<ITsavoriteScanIterator<Key, Value>>
where TLogSizeCalculator : ILogSizeCalculator<Key, Value>
{
private readonly LogSizeTracker<Key, Value, ILogSizeCalculator<Key, Value>> logSizeTracker;
private readonly LogSizeTracker<Key, Value, TLogSizeCalculator> logSizeTracker;
private readonly LogOperationType logOperationType;

public LogOperationObserver(LogSizeTracker<Key, Value, ILogSizeCalculator<Key, Value>> logSizeTracker, LogOperationType logOperationType)
public LogOperationObserver(LogSizeTracker<Key, Value, TLogSizeCalculator> logSizeTracker, LogOperationType logOperationType)
{
this.logSizeTracker = logSizeTracker;
this.logOperationType = logOperationType;
Expand Down

0 comments on commit f0c6a34

Please sign in to comment.