Skip to content

Commit

Permalink
Bump LightningDB from 0.12.0 to 0.13.0 (#4535)
Browse files Browse the repository at this point in the history
* Bump LightningDB from 0.12.0 to 0.13.0

Bumps [LightningDB](https://github.com/CoreyKaylor/Lightning.NET) from 0.12.0 to 0.13.0.
- [Release notes](https://github.com/CoreyKaylor/Lightning.NET/releases)
- [Commits](CoreyKaylor/Lightning.NET@v0.12.0...v0.13.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Adapt to changes in LightningDB API changes

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Gregorius Soedharmo <arkatufus@yahoo.com>
  • Loading branch information
dependabot-preview[bot] and Arkatufus committed Aug 14, 2020
1 parent 4eb845c commit 2b3e2d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="LightningDB" Version="0.12.0" />
<PackageReference Include="LightningDB" Version="0.13.0" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Akka.DistributedData.Internal;
using LightningDB;
using System.Diagnostics;
using System.Linq;

namespace Akka.DistributedData.LightningDB
{
Expand Down Expand Up @@ -145,8 +146,8 @@ protected override void PostStop()
if(IsDbInitialized)
{
var (env, db, _) = Lmdb;
try { db.Dispose(); } catch { }
try { env.Dispose(); } catch { }
try { db?.Dispose(); } catch { }
try { env?.Dispose(); } catch { }
}
}

Expand Down Expand Up @@ -196,34 +197,32 @@ private void Init()
return;
}
var l = Lmdb;
var (environment, db, _) = Lmdb;
var t0 = Stopwatch.StartNew();
using (var tx = l.env.BeginTransaction(TransactionBeginFlags.ReadOnly))
using (var cursor = tx.CreateCursor(l.db))
using (var tx = environment.BeginTransaction(TransactionBeginFlags.ReadOnly))
using (var cursor = tx.CreateCursor(db))
{
try
{
var n = 0;
var builder = ImmutableDictionary.CreateBuilder<string, DurableDataEnvelope>();
foreach (var entry in cursor)
var data = cursor.AsEnumerable().Select((x, i)
=> {
var (key, value) = x;
return new KeyValuePair<string, DurableDataEnvelope>(
Encoding.UTF8.GetString(key.CopyToNewArray()),
(DurableDataEnvelope)_serializer.FromBinary(value.CopyToNewArray(), _manifest));
}).ToImmutableDictionary();
if (data.Count > 0)
{
n++;
var key = Encoding.UTF8.GetString(entry.Key.CopyToNewArray());
var envelope = (DurableDataEnvelope)_serializer.FromBinary(entry.Value.CopyToNewArray(), _manifest);
builder.Add(key, envelope);
}
if (builder.Count > 0)
{
var loadData = new LoadData(builder.ToImmutable());
var loadData = new LoadData(data);
Sender.Tell(loadData);
}
Sender.Tell(LoadAllCompleted.Instance);
t0.Stop();
if (_log.IsDebugEnabled)
_log.Debug($"Load all of [{n}] entries took [{t0.ElapsedMilliseconds}]");
_log.Debug($"Load all of [{data.Count}] entries took [{t0.ElapsedMilliseconds}]");
Become(Active);
}
Expand Down

0 comments on commit 2b3e2d3

Please sign in to comment.