Skip to content

Commit

Permalink
Cleaning up interface and comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
badrishc committed Sep 5, 2019
1 parent 9afc5fb commit 62cecc8
Show file tree
Hide file tree
Showing 9 changed files with 305 additions and 216 deletions.
92 changes: 46 additions & 46 deletions cs/src/core/Index/FASTER/FASTER.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ public void Refresh()


/// <summary>
/// Complete outstanding pending operations
/// Complete all pending operations issued by this session
/// </summary>
/// <param name="wait"></param>
/// <returns></returns>
/// <param name="wait">Whether we spin-wait for pending operations to complete</param>
/// <returns>Whether all pending operations have completed</returns>
public bool CompletePending(bool wait = false)
{
return InternalCompletePending(wait);
Expand Down Expand Up @@ -391,45 +391,45 @@ public bool CompleteCheckpoint(bool wait = false)
}

/// <summary>
/// Read
/// Read operation
/// </summary>
/// <param name="key"></param>
/// <param name="input"></param>
/// <param name="output"></param>
/// <param name="userContext"></param>
/// <param name="monotonicSerialNum"></param>
/// <returns></returns>
/// <param name="key">Key of read</param>
/// <param name="input">Input argument used by Reader to select what part of value to read</param>
/// <param name="output">Reader stores the read result in output</param>
/// <param name="context">User context to identify operation in asynchronous callback</param>
/// <param name="serialNo">Increasing sequence number of operation (used for recovery)</param>
/// <returns>Status of operation</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Status Read(ref Key key, ref Input input, ref Output output, Context userContext, long monotonicSerialNum)
public Status Read(ref Key key, ref Input input, ref Output output, Context context, long serialNo)
{
var context = default(PendingContext);
var internalStatus = InternalRead(ref key, ref input, ref output, ref userContext, ref context);
var pcontext = default(PendingContext);
var internalStatus = InternalRead(ref key, ref input, ref output, ref context, ref pcontext);
Status status;
if (internalStatus == OperationStatus.SUCCESS || internalStatus == OperationStatus.NOTFOUND)
{
status = (Status)internalStatus;
}
else
{
status = HandleOperationStatus(threadCtx.Value, context, internalStatus);
status = HandleOperationStatus(threadCtx.Value, pcontext, internalStatus);
}
threadCtx.Value.serialNum = monotonicSerialNum;
threadCtx.Value.serialNum = serialNo;
return status;
}

/// <summary>
/// Upsert
/// (Blind) upsert operation
/// </summary>
/// <param name="key"></param>
/// <param name="desiredValue"></param>
/// <param name="userContext"></param>
/// <param name="monotonicSerialNum"></param>
/// <returns></returns>
/// <param name="key">Key of read</param>
/// <param name="value">Value being upserted</param>
/// <param name="context">User context to identify operation in asynchronous callback</param>
/// <param name="serialNo">Increasing sequence number of operation (used for recovery)</param>
/// <returns>Status of operation</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Status Upsert(ref Key key, ref Value desiredValue, Context userContext, long monotonicSerialNum)
public Status Upsert(ref Key key, ref Value value, Context context, long serialNo)
{
var context = default(PendingContext);
var internalStatus = InternalUpsert(ref key, ref desiredValue, ref userContext, ref context);
var pcontext = default(PendingContext);
var internalStatus = InternalUpsert(ref key, ref value, ref context, ref pcontext);
Status status;

if (internalStatus == OperationStatus.SUCCESS || internalStatus == OperationStatus.NOTFOUND)
Expand All @@ -438,35 +438,35 @@ public Status Upsert(ref Key key, ref Value desiredValue, Context userContext, l
}
else
{
status = HandleOperationStatus(threadCtx.Value, context, internalStatus);
status = HandleOperationStatus(threadCtx.Value, pcontext, internalStatus);
}
threadCtx.Value.serialNum = monotonicSerialNum;
threadCtx.Value.serialNum = serialNo;
return status;
}

/// <summary>
/// Read-modify-write
/// Atomic read-modify-write operation
/// </summary>
/// <param name="key"></param>
/// <param name="input"></param>
/// <param name="userContext"></param>
/// <param name="monotonicSerialNum"></param>
/// <returns></returns>
/// <param name="key">Key of read</param>
/// <param name="input">Input argument used by RMW callback to perform operation</param>
/// <param name="context">User context to identify operation in asynchronous callback</param>
/// <param name="serialNo">Increasing sequence number of operation (used for recovery)</param>
/// <returns>Status of operation</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Status RMW(ref Key key, ref Input input, Context userContext, long monotonicSerialNum)
public Status RMW(ref Key key, ref Input input, Context context, long serialNo)
{
var context = default(PendingContext);
var internalStatus = InternalRMW(ref key, ref input, ref userContext, ref context);
var pcontext = default(PendingContext);
var internalStatus = InternalRMW(ref key, ref input, ref context, ref pcontext);
Status status;
if (internalStatus == OperationStatus.SUCCESS || internalStatus == OperationStatus.NOTFOUND)
{
status = (Status)internalStatus;
}
else
{
status = HandleOperationStatus(threadCtx.Value, context, internalStatus);
status = HandleOperationStatus(threadCtx.Value, pcontext, internalStatus);
}
threadCtx.Value.serialNum = monotonicSerialNum;
threadCtx.Value.serialNum = serialNo;
return status;
}

Expand All @@ -476,28 +476,28 @@ public Status RMW(ref Key key, ref Input input, Context userContext, long monoto
/// the head of hash chain.
/// Value is set to null (using ConcurrentWrite) if it is in mutable region
/// </summary>
/// <param name="key"></param>
/// <param name="userContext"></param>
/// <param name="monotonicSerialNum"></param>
/// <returns></returns>
/// <param name="key">Key of delete</param>
/// <param name="context">User context to identify operation in asynchronous callback</param>
/// <param name="serialNo">Increasing sequence number of operation (used for recovery)</param>
/// <returns>Status of operation</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Status Delete(ref Key key, Context userContext, long monotonicSerialNum)
public Status Delete(ref Key key, Context context, long serialNo)
{
var context = default(PendingContext);
var internalStatus = InternalDelete(ref key, ref userContext, ref context);
var pcontext = default(PendingContext);
var internalStatus = InternalDelete(ref key, ref context, ref pcontext);
var status = default(Status);
if (internalStatus == OperationStatus.SUCCESS || internalStatus == OperationStatus.NOTFOUND)
{
status = (Status)internalStatus;
}
threadCtx.Value.serialNum = monotonicSerialNum;
threadCtx.Value.serialNum = serialNo;
return status;
}

/// <summary>
/// Grow the hash index
/// </summary>
/// <returns></returns>
/// <returns>Whether the request succeeded</returns>
public bool GrowIndex()
{
return InternalGrowIndex();
Expand Down
58 changes: 28 additions & 30 deletions cs/src/core/Index/Interfaces/IFasterKV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,17 @@
// Licensed under the MIT license.

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;

namespace FASTER.core
{
/// <summary>
/// Interface to FASTER key-value store
/// (customized for sample types Key, Value, Input, Output, Context)
/// Since there are pointers in the API, we cannot automatically create a
/// generic version covering arbitrary blittable types. Instead, the
/// user defines the customized interface and provides it to FASTER
/// so it can return a (generated) instance for that interface.
/// </summary>
public interface IFasterKV<Key, Value, Input, Output, Context> : IDisposable
where Key : new()
where Value : new()
{
/* Thread-related operations */
#region Session Operations

/// <summary>
/// Start a session with FASTER. FASTER sessions correspond to threads issuing
Expand Down Expand Up @@ -51,7 +40,9 @@ public interface IFasterKV<Key, Value, Input, Output, Context> : IDisposable
/// </summary>
void Refresh();

/* Store Interface */
#endregion

#region Core Index Operations

/// <summary>
/// Read operation
Expand All @@ -60,41 +51,41 @@ public interface IFasterKV<Key, Value, Input, Output, Context> : IDisposable
/// <param name="input">Input argument used by Reader to select what part of value to read</param>
/// <param name="output">Reader stores the read result in output</param>
/// <param name="context">User context to identify operation in asynchronous callback</param>
/// <param name="lsn">Increasing sequence number of operation (used for recovery)</param>
/// <param name="serialNo">Increasing sequence number of operation (used for recovery)</param>
/// <returns>Status of operation</returns>
Status Read(ref Key key, ref Input input, ref Output output, Context context, long lsn);
Status Read(ref Key key, ref Input input, ref Output output, Context context, long serialNo);

/// <summary>
/// (Blind) upsert operation
/// </summary>
/// <param name="key">Key of read</param>
/// <param name="value">Value being upserted</param>
/// <param name="context">User context to identify operation in asynchronous callback</param>
/// <param name="lsn">Increasing sequence number of operation (used for recovery)</param>
/// <param name="serialNo">Increasing sequence number of operation (used for recovery)</param>
/// <returns>Status of operation</returns>
Status Upsert(ref Key key, ref Value value, Context context, long lsn);
Status Upsert(ref Key key, ref Value value, Context context, long serialNo);

/// <summary>
/// Atomic read-modify-write operation
/// </summary>
/// <param name="key">Key of read</param>
/// <param name="input">Input argument used by RMW callback to perform operation</param>
/// <param name="context">User context to identify operation in asynchronous callback</param>
/// <param name="lsn">Increasing sequence number of operation (used for recovery)</param>
/// <param name="serialNo">Increasing sequence number of operation (used for recovery)</param>
/// <returns>Status of operation</returns>
Status RMW(ref Key key, ref Input input, Context context, long lsn);
Status RMW(ref Key key, ref Input input, Context context, long serialNo);

/// <summary>
/// Delete entry (use tombstone if necessary)
/// Hash entry is removed as a best effort (if key is in memory and at
/// the head of hash chain.
/// Value is set to null (using ConcurrentWrite) if it is in mutable region
/// </summary>
/// <param name="key"></param>
/// <param name="userContext"></param>
/// <param name="monotonicSerialNum"></param>
/// <returns></returns>
Status Delete(ref Key key, Context userContext, long monotonicSerialNum);
/// <param name="key">Key of delete</param>
/// <param name="context">User context to identify operation in asynchronous callback</param>
/// <param name="serialNo">Increasing sequence number of operation (used for recovery)</param>
/// <returns>Status of operation</returns>
Status Delete(ref Key key, Context context, long serialNo);

/// <summary>
/// Complete all pending operations issued by this session
Expand All @@ -103,8 +94,15 @@ public interface IFasterKV<Key, Value, Input, Output, Context> : IDisposable
/// <returns>Whether all pending operations have completed</returns>
bool CompletePending(bool wait);

/// <summary>
/// Grow the hash index
/// </summary>
/// <returns></returns>
bool GrowIndex();

#endregion

/* Recovery */
#region Recovery

/// <summary>
/// Take full checkpoint of FASTER
Expand Down Expand Up @@ -152,11 +150,9 @@ public interface IFasterKV<Key, Value, Input, Output, Context> : IDisposable
/// <returns>Whether checkpoint has completed</returns>
bool CompleteCheckpoint(bool wait);

/// <summary>
/// Grow the hash index
/// </summary>
/// <returns></returns>
bool GrowIndex();
#endregion

#region Other Operations

/// <summary>
/// Get number of (non-zero) hash entries in FASTER
Expand Down Expand Up @@ -198,5 +194,7 @@ public interface IFasterKV<Key, Value, Input, Output, Context> : IDisposable
/// Get accessor for FASTER read cache
/// </summary>
LogAccessor<Key, Value, Input, Output, Context> ReadCache { get; }

#endregion
}
}
Loading

0 comments on commit 62cecc8

Please sign in to comment.