Skip to content

Commit

Permalink
RavenDB-20325 : address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aviv committed May 20, 2024
1 parent 4072d75 commit 38c109d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/Raven.Server/Documents/Handlers/TimeSeriesHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1198,11 +1198,11 @@ internal class SmugglerTimeSeriesBatchCommand : TransactionOperationsMerger.Merg
public SmugglerTimeSeriesBatchCommand(DocumentDatabase database)
{
_database = database;
_dictionary = new Dictionary<string, List<TimeSeriesItem>>();
_dictionary = new Dictionary<string, List<TimeSeriesItem>>(StringComparer.OrdinalIgnoreCase);
_toDispose = new();
_toReturn = new();
_releaseContext = _database.DocumentsStorage.ContextPool.AllocateOperationContext(out _context);
_deletedRanges = new Dictionary<string, List<TimeSeriesDeletedRangeItem>>();
_deletedRanges = new Dictionary<string, List<TimeSeriesDeletedRangeItem>>(StringComparer.OrdinalIgnoreCase);
}

protected override long ExecuteCmd(DocumentsOperationContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Sparrow.Json;
using Sparrow.Json.Parsing;
using Sparrow.Server;
using Sparrow.Threading;
using Voron;

namespace Raven.Server.Documents.Replication.ReplicationItems
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public interface ITimeSeriesActions : IAsyncDisposable, INewItemActions
{
ValueTask WriteTimeSeriesAsync(TimeSeriesItem ts);

ValueTask WriteDeletedRangeAsync(TimeSeriesDeletedRangeItem deletedRange);
ValueTask WriteTimeSeriesDeletedRangeAsync(TimeSeriesDeletedRangeItem deletedRange);


void RegisterForDisposal(IDisposable data);
Expand Down
2 changes: 1 addition & 1 deletion src/Raven.Server/Smuggler/Documents/DatabaseDestination.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2404,7 +2404,7 @@ public async ValueTask WriteTimeSeriesAsync(TimeSeriesItem ts)
await HandleBatchOfTimeSeriesIfNecessaryAsync();
}

public async ValueTask WriteDeletedRangeAsync(TimeSeriesDeletedRangeItem deletedRange)
public async ValueTask WriteTimeSeriesDeletedRangeAsync(TimeSeriesDeletedRangeItem deletedRange)
{
AddToBatch(deletedRange);
await HandleBatchOfTimeSeriesIfNecessaryAsync();
Expand Down
4 changes: 2 additions & 2 deletions src/Raven.Server/Smuggler/Documents/DatabaseSmuggler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1248,8 +1248,8 @@ static bool ShouldSkip(TimeSeriesItem ts, SmugglerPatcher patcher, bool isFullBa
if (result.TimeSeriesDeletedRanges.ReadCount % 1000 == 0)
AddInfoToSmugglerResult(result, $"Time Series deleted ranges entries {result.TimeSeriesDeletedRanges}");

if (ShouldSkip(deletedRange, _patcher) == false)
await actions.WriteDeletedRangeAsync(deletedRange);
if (ShouldSkip(deletedRange, _patcher) == false)
await actions.WriteTimeSeriesDeletedRangeAsync(deletedRange);

else
result.TimeSeriesDeletedRanges.SkippedCount++;
Expand Down
15 changes: 8 additions & 7 deletions src/Raven.Server/Smuggler/Documents/DatabaseSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,10 @@ public SmugglerSourceType GetSourceType()
return _type;
}

#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public async IAsyncEnumerable<TimeSeriesDeletedRangeItem> GetTimeSeriesDeletedRangesAsync(ITimeSeriesActions action, List<string> collectionsToExport)
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
public IAsyncEnumerable<TimeSeriesDeletedRangeItem> GetTimeSeriesDeletedRangesAsync(ITimeSeriesActions action, List<string> collectionsToExport) =>
GetTimeSeriesDeletedRanges(collectionsToExport).ToAsyncEnumerable();

private IEnumerable<TimeSeriesDeletedRangeItem> GetTimeSeriesDeletedRanges(IEnumerable<string> collectionsToExport)
{
Debug.Assert(_context != null);

Expand All @@ -620,9 +621,9 @@ public async IAsyncEnumerable<TimeSeriesDeletedRangeItem> GetTimeSeriesDeletedRa
state =>
{
if (state.StartEtagByCollection.Count != 0)
return GetDeletedRangesFromCollections(_context, state);
return GetTimeSeriesDeletedRangesFromCollections(_context, state);
return GetAllDeletedRanges(_context, state.StartEtag);
return GetAlTimeSeriesDeletedRanges(_context, state.StartEtag);
}, initialState);

while (enumerator.MoveNext())
Expand All @@ -632,7 +633,7 @@ public async IAsyncEnumerable<TimeSeriesDeletedRangeItem> GetTimeSeriesDeletedRa
}


private static IEnumerable<TimeSeriesDeletedRangeItem> GetAllDeletedRanges(DocumentsOperationContext context, long startEtag)
private static IEnumerable<TimeSeriesDeletedRangeItem> GetAlTimeSeriesDeletedRanges(DocumentsOperationContext context, long startEtag)
{
var database = context.DocumentDatabase;
foreach (var deletedRange in database.DocumentsStorage.TimeSeriesStorage.GetDeletedRangesFrom(context, startEtag))
Expand All @@ -655,7 +656,7 @@ private static IEnumerable<TimeSeriesDeletedRangeItem> GetAllDeletedRanges(Docum
}
}

private static IEnumerable<TimeSeriesDeletedRangeItem> GetDeletedRangesFromCollections(DocumentsOperationContext context, TimeSeriesDeletedRangeIterationState state)
private static IEnumerable<TimeSeriesDeletedRangeItem> GetTimeSeriesDeletedRangesFromCollections(DocumentsOperationContext context, TimeSeriesDeletedRangeIterationState state)
{
var database = context.DocumentDatabase;
var collections = state.StartEtagByCollection.Keys.ToList();
Expand Down
2 changes: 1 addition & 1 deletion src/Raven.Server/Smuggler/Documents/StreamDestination.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ public async ValueTask WriteTimeSeriesAsync(TimeSeriesItem item)
}
}

public async ValueTask WriteDeletedRangeAsync(TimeSeriesDeletedRangeItem deletedRangeItem)
public async ValueTask WriteTimeSeriesDeletedRangeAsync(TimeSeriesDeletedRangeItem deletedRangeItem)
{
using (deletedRangeItem)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4005,7 +4005,7 @@ await store.Subscriptions.CreateAsync(new SubscriptionCreationOptions<Order>
}
}

[Fact, Trait("Category", "Smuggler")]
[RavenFact(RavenTestCategory.Smuggler | RavenTestCategory.BackupExportImport | RavenTestCategory.TimeSeries)]
public async Task can_backup_and_restore_with_deleted_timeseries_ranges()
{
var backupPath = NewDataPath(suffix: "BackupFolder");
Expand Down Expand Up @@ -4074,7 +4074,7 @@ await store.Smuggler.ImportIncrementalAsync(new DatabaseSmugglerImportOptions(),
}
}

[Fact, Trait("Category", "Smuggler")]
[RavenFact(RavenTestCategory.Smuggler | RavenTestCategory.BackupExportImport | RavenTestCategory.TimeSeries)]
public async Task deleted_ranges_should_be_processed_before_timeseries()
{
var backupPath = NewDataPath(suffix: "BackupFolder");
Expand Down

0 comments on commit 38c109d

Please sign in to comment.