-
Notifications
You must be signed in to change notification settings - Fork 570
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/Microsoft/FASTER into asy…
…nc-support
- Loading branch information
Showing
40 changed files
with
1,487 additions
and
490 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /> | ||
</startup> | ||
</configuration> |
38 changes: 38 additions & 0 deletions
38
cs/playground/FixedLenStructSample/FixedLenStructSample.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net46</TargetFramework> | ||
<Platforms>x64</Platforms> | ||
<RuntimeIdentifier>win7-x64</RuntimeIdentifier> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<RootNamespace>StructSample</RootNamespace> | ||
<ErrorReport>prompt</ErrorReport> | ||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle> | ||
<Prefer32Bit>true</Prefer32Bit> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'"> | ||
<DefineConstants>TRACE;DEBUG</DefineConstants> | ||
<DebugType>full</DebugType> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\x64\Debug\</OutputPath> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\x64\Release\</OutputPath> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\core\FASTER.core.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using FASTER.core; | ||
using System; | ||
|
||
namespace FixedLenStructSample | ||
{ | ||
/// <summary> | ||
/// Callback functions for FASTER operations | ||
/// </summary> | ||
public class FixedLenFunctions : IFunctions<FixedLenKey, FixedLenValue, string, string, Empty> | ||
{ | ||
public void CheckpointCompletionCallback(Guid sessionId, long serialNum) | ||
{ | ||
} | ||
|
||
public void ConcurrentReader(ref FixedLenKey key, ref string input, ref FixedLenValue value, ref string dst) | ||
{ | ||
dst = value.ToString(); | ||
} | ||
|
||
public void ConcurrentWriter(ref FixedLenKey key, ref FixedLenValue src, ref FixedLenValue dst) | ||
{ | ||
src.CopyTo(ref dst); | ||
} | ||
|
||
public void CopyUpdater(ref FixedLenKey key, ref string input, ref FixedLenValue oldValue, ref FixedLenValue newValue) | ||
{ | ||
} | ||
|
||
public void DeleteCompletionCallback(ref FixedLenKey key, Empty ctx) | ||
{ | ||
} | ||
|
||
public void InitialUpdater(ref FixedLenKey key, ref string input, ref FixedLenValue value) | ||
{ | ||
} | ||
|
||
public void InPlaceUpdater(ref FixedLenKey key, ref string input, ref FixedLenValue value) | ||
{ | ||
} | ||
|
||
public void ReadCompletionCallback(ref FixedLenKey key, ref string input, ref string output, Empty ctx, Status status) | ||
{ | ||
} | ||
|
||
public void RMWCompletionCallback(ref FixedLenKey key, ref string input, Empty ctx, Status status) | ||
{ | ||
} | ||
|
||
public void SingleReader(ref FixedLenKey key, ref string input, ref FixedLenValue value, ref string dst) | ||
{ | ||
dst = value.ToString(); | ||
} | ||
|
||
public void SingleWriter(ref FixedLenKey key, ref FixedLenValue src, ref FixedLenValue dst) | ||
{ | ||
src.CopyTo(ref dst); | ||
} | ||
|
||
public void UpsertCompletionCallback(ref FixedLenKey key, ref FixedLenValue value, Empty ctx) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using FASTER.core; | ||
using System; | ||
|
||
namespace FixedLenStructSample | ||
{ | ||
public class Program | ||
{ | ||
// This sample uses fixed length structs for keys and values | ||
static void Main() | ||
{ | ||
var log = Devices.CreateLogDevice("hlog.log", deleteOnClose: true); | ||
var fht = new FasterKV<FixedLenKey, FixedLenValue, string, string, Empty, FixedLenFunctions> | ||
(128, new FixedLenFunctions(), | ||
new LogSettings { LogDevice = log, MemorySizeBits = 17, PageSizeBits = 12 } | ||
); | ||
fht.StartSession(); | ||
|
||
var key = new FixedLenKey("foo"); | ||
var value = new FixedLenValue("bar"); | ||
|
||
var status = fht.Upsert(ref key, ref value, Empty.Default, 0); | ||
|
||
if (status != Status.OK) | ||
Console.WriteLine("FixedLenStructSample: Error!"); | ||
|
||
var input = default(string); // unused | ||
var output = default(string); | ||
|
||
key = new FixedLenKey("xyz"); | ||
status = fht.Read(ref key, ref input, ref output, Empty.Default, 0); | ||
|
||
if (status != Status.NOTFOUND) | ||
Console.WriteLine("FixedLenStructSample: Error!"); | ||
|
||
key = new FixedLenKey("foo"); | ||
status = fht.Read(ref key, ref input, ref output, Empty.Default, 0); | ||
|
||
if (status != Status.OK) | ||
Console.WriteLine("FixedLenStructSample: Error!"); | ||
|
||
if (output.Equals(value.ToString())) | ||
Console.WriteLine("FixedLenStructSample: Success!"); | ||
else | ||
Console.WriteLine("FixedLenStructSample: Error!"); | ||
|
||
fht.StopSession(); | ||
fht.Dispose(); | ||
log.Close(); | ||
|
||
Console.WriteLine("Press <ENTER> to end"); | ||
Console.ReadLine(); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
cs/playground/FixedLenStructSample/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyCopyright("Copyright © 2019")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("17bdd0a5-98e5-464a-8a00-050d9ff4c562")] |
Oops, something went wrong.