Skip to content

Commit bdd170c

Browse files
committed
Added new method for getting values using span
1 parent 8a8e527 commit bdd170c

File tree

6 files changed

+865
-763
lines changed

6 files changed

+865
-763
lines changed
Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,44 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
3-
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp1.1;net451</TargetFrameworks>
5-
<AssemblyName>LightningDB.Tests</AssemblyName>
6-
<PackageId>LightningDB.Tests</PackageId>
7-
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
8-
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">1.0.4</RuntimeFrameworkVersion>
9-
</PropertyGroup>
10-
11-
<ItemGroup>
12-
<ProjectReference Include="..\LightningDB\LightningDB.csproj" />
13-
</ItemGroup>
14-
15-
<ItemGroup>
16-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
17-
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
18-
<PackageReference Include="xunit" Version="2.2.0" />
19-
</ItemGroup>
20-
21-
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
22-
<PackageReference Include="Microsoft.NETCore.Platforms" Version="1.1.0" />
23-
<Reference Include="System" />
24-
<Reference Include="Microsoft.CSharp" />
25-
</ItemGroup>
26-
27-
<ItemGroup>
28-
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
29-
</ItemGroup>
30-
31-
<ItemGroup Condition=" '$(OS)' == 'Unix' ">
32-
<NativeLib Include="../LightningDB/runtimes/osx/native/lmdb.dylib" />
33-
</ItemGroup>
34-
<ItemGroup Condition=" '$(Platform)' == 'x86' AND '$(OS)' != 'Unix' ">
35-
<NativeLib Include="../LightningDB/runtimes/win-x86/native/lmdb.dll" />
36-
</ItemGroup>
37-
<ItemGroup Condition=" ('$(Platform)' == 'x64' OR '$(Platform)' == 'AnyCPU') AND '$(OS)' == 'Windows_NT' ">
38-
<NativeLib Include="../LightningDB/runtimes/win-x64/native/lmdb.dll" />
39-
</ItemGroup>
40-
41-
<Target Name="CopyNativeLib" AfterTargets="Build">
42-
<Copy SourceFiles="@(NativeLib)" DestinationFolder="$(OutputPath)" />
43-
</Target>
44-
45-
</Project>
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>netcoreapp2.1;net451</TargetFrameworks>
5+
<AssemblyName>LightningDB.Tests</AssemblyName>
6+
<PackageId>LightningDB.Tests</PackageId>
7+
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
8+
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">1.0.4</RuntimeFrameworkVersion>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<ProjectReference Include="..\LightningDB\LightningDB.csproj" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
17+
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
18+
<PackageReference Include="xunit" Version="2.2.0" />
19+
</ItemGroup>
20+
21+
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
22+
<PackageReference Include="Microsoft.NETCore.Platforms" Version="1.1.0" />
23+
<Reference Include="System" />
24+
<Reference Include="Microsoft.CSharp" />
25+
</ItemGroup>
26+
27+
<ItemGroup>
28+
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
29+
</ItemGroup>
30+
31+
<ItemGroup Condition=" '$(OS)' == 'Unix' ">
32+
<NativeLib Include="../LightningDB/runtimes/osx/native/lmdb.dylib" />
33+
</ItemGroup>
34+
<ItemGroup Condition=" '$(Platform)' == 'x86' AND '$(OS)' != 'Unix' ">
35+
<NativeLib Include="../LightningDB/runtimes/win-x86/native/lmdb.dll" />
36+
</ItemGroup>
37+
<ItemGroup Condition=" ('$(Platform)' == 'x64' OR '$(Platform)' == 'AnyCPU') AND '$(OS)' == 'Windows_NT' ">
38+
<NativeLib Include="../LightningDB/runtimes/win-x64/native/lmdb.dll" />
39+
</ItemGroup>
40+
41+
<Target Name="CopyNativeLib" AfterTargets="Build">
42+
<Copy SourceFiles="@(NativeLib)" DestinationFolder="$(OutputPath)" />
43+
</Target>
44+
</Project>

src/LightningDB.Tests/SpanTests.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
using Xunit;
4+
5+
namespace LightningDB.Tests
6+
{
7+
[Collection("SharedFileSystem")]
8+
public class SpanTests : IDisposable
9+
{
10+
private LightningEnvironment _env;
11+
private Random generator;
12+
13+
public SpanTests(SharedFileSystem fileSystem)
14+
{
15+
var path = fileSystem.CreateNewDirectoryForTest();
16+
_env = new LightningEnvironment(path);
17+
_env.Open();
18+
generator = new Random(Guid.NewGuid().GetHashCode());
19+
}
20+
21+
public void Dispose()
22+
{
23+
_env.Dispose();
24+
}
25+
26+
[Fact]
27+
public void ValueShouldBeReadProperly()
28+
{
29+
using (var txn = _env.BeginTransaction())
30+
using (var db = txn.OpenDatabase(configuration: new DatabaseConfiguration
31+
{
32+
Flags = DatabaseOpenFlags.Create
33+
}))
34+
{
35+
var value = generator.Next(int.MinValue, int.MaxValue);
36+
var key = BitConverter.GetBytes(1);
37+
38+
txn.Put(db, key, BitConverter.GetBytes(value));
39+
var span = txn.GetSpan(db, key);
40+
var intSpan = MemoryMarshal.Cast<byte, int>(span);
41+
42+
var savedValue = intSpan[0];
43+
44+
Assert.Equal(savedValue, value);
45+
}
46+
}
47+
}
48+
}

src/LightningDB/LightningDB.csproj

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,46 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
3-
<PropertyGroup>
4-
<Description>LightningDB</Description>
5-
<VersionPrefix>0.10.0</VersionPrefix>
6-
<Authors>Ilya Lukyanov;Corey Kaylor</Authors>
7-
<TargetFrameworks>net45;netstandard1.3</TargetFrameworks>
8-
<AssemblyName>LightningDB</AssemblyName>
9-
<PackageId>LightningDB</PackageId>
10-
<PackageTags>lmdb;lightning;storage;persistance;key-value;nosql</PackageTags>
11-
<PackageProjectUrl>https://github.com/CoreyKaylor/Lightning.NET</PackageProjectUrl>
12-
</PropertyGroup>
13-
14-
<ItemGroup>
15-
<None Include="runtimes\win-x64\native\lmdb.dll" Pack="true" PackagePath="runtimes/win-x64/native/lmdb.dll" />
16-
<None Include="runtimes\win-x86\native\lmdb.dll" Pack="true" PackagePath="runtimes/win-x86/native/lmdb.dll" />
17-
<None Include="runtimes\osx\native\lmdb.dylib" Pack="true" PackagePath="runtimes/osx/native/lmdb.dylib" />
18-
<None Include="runtimes\linux-arm\native\liblmdb.so" Pack="true" PackagePath="runtimes/linux-arm/native/liblmdb.so" />
19-
<None Include="LightningDB.targets" Pack="true" PackagePath="build" />
20-
</ItemGroup>
21-
22-
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
23-
<Reference Include="System" />
24-
<Reference Include="Microsoft.CSharp" />
25-
</ItemGroup>
26-
27-
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
28-
<PackageReference Include="System.Net.Primitives" Version="4.3.0" />
29-
<PackageReference Include="System.Runtime" Version="4.3.0" />
30-
<PackageReference Include="System.Linq" Version="4.3.0" />
31-
<PackageReference Include="System.Collections.Concurrent" Version="4.3.0" />
32-
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
33-
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
34-
<PackageReference Include="System.Threading" Version="4.3.0" />
35-
</ItemGroup>
36-
37-
<ItemGroup>
38-
<Folder Include="runtimes\linux-arm\native\" />
39-
<Folder Include="runtimes\linux-arm\" />
40-
</ItemGroup>
41-
42-
</Project>
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<Description>LightningDB</Description>
5+
<VersionPrefix>0.10.0</VersionPrefix>
6+
<Authors>Ilya Lukyanov;Corey Kaylor</Authors>
7+
<TargetFrameworks>net45;netstandard1.3</TargetFrameworks>
8+
<AssemblyName>LightningDB</AssemblyName>
9+
<PackageId>LightningDB</PackageId>
10+
<PackageTags>lmdb;lightning;storage;persistance;key-value;nosql</PackageTags>
11+
<PackageProjectUrl>https://github.com/CoreyKaylor/Lightning.NET</PackageProjectUrl>
12+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
13+
</PropertyGroup>
14+
15+
<ItemGroup>
16+
<None Include="runtimes\win-x64\native\lmdb.dll" Pack="true" PackagePath="runtimes/win-x64/native/lmdb.dll" />
17+
<None Include="runtimes\win-x86\native\lmdb.dll" Pack="true" PackagePath="runtimes/win-x86/native/lmdb.dll" />
18+
<None Include="runtimes\osx\native\lmdb.dylib" Pack="true" PackagePath="runtimes/osx/native/lmdb.dylib" />
19+
<None Include="runtimes\linux-arm\native\liblmdb.so" Pack="true" PackagePath="runtimes/linux-arm/native/liblmdb.so" />
20+
<None Include="LightningDB.targets" Pack="true" PackagePath="build" />
21+
</ItemGroup>
22+
23+
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
24+
<Reference Include="System" />
25+
<Reference Include="Microsoft.CSharp" />
26+
</ItemGroup>
27+
28+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
29+
<PackageReference Include="System.Net.Primitives" Version="4.3.0" />
30+
<PackageReference Include="System.Runtime" Version="4.3.0" />
31+
<PackageReference Include="System.Linq" Version="4.3.0" />
32+
<PackageReference Include="System.Collections.Concurrent" Version="4.3.0" />
33+
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
34+
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
35+
<PackageReference Include="System.Threading" Version="4.3.0" />
36+
</ItemGroup>
37+
38+
<ItemGroup>
39+
<Folder Include="runtimes\linux-arm\native\" />
40+
<Folder Include="runtimes\linux-arm\" />
41+
</ItemGroup>
42+
43+
<ItemGroup>
44+
<PackageReference Include="System.Memory" Version="4.5.1" />
45+
</ItemGroup>
46+
</Project>

0 commit comments

Comments
 (0)