Table of Contents

Struct BulkWriteResult

Namespace
FishMMO.Database
Assembly
FishMMO-DB.dll

What a bulk write actually did, as distinct from whether it errored.

public readonly struct BulkWriteResult
Inherited Members

Remarks

A batched, version-gated write has a richer outcome than success or failure, and collapsing it to a boolean loses the part callers need. Rows go missing between the caller's list and the database for two entirely different reasons, and only one of them is benign:

  • Filtered — the service refused to attempt the row at all: the character is deleted, the template is unresolvable, or two rows in the batch collided on the same key. The caller asked for something that could not be done, and nothing about the database's state explains it. This is worth surfacing.
  • Superseded — the row was attempted and lost the version race, because the database already holds a version at least as new. Nothing is lost: the stored value is the more recent of the two. Routine under concurrency, and not a failure.

The distinction matters because the caller cannot recover it on its own. The service deduplicates and filters before writing, so comparing Applied against the length of the list the caller passed in would attribute both causes to whichever the caller happened to assume.

Unowned is the part of Filtered an ownership-gated write refused because the writer no longer holds that character's session claim (see CharacterWriteGate). It is counted inside Filtered on purpose: a refused row never reached the database, so every caller that clears its dirty marks only when nothing was filtered keeps them without having to know the gate exists. It is broken out only so the log can say why.

Constructors

BulkWriteResult(int, int, int)

Initializes a new instance of the BulkWriteResult struct.

public BulkWriteResult(int supplied, int attempted, int applied)

Parameters

supplied int

Rows the caller handed over.

attempted int

Rows the statement tried.

applied int

Rows written.

BulkWriteResult(int, int, int, int)

Initializes a new instance of the BulkWriteResult struct.

public BulkWriteResult(int supplied, int attempted, int applied, int unowned)

Parameters

supplied int

Rows the caller handed over.

attempted int

Rows the statement tried.

applied int

Rows written.

unowned int

Rows refused because the writer does not hold their character's claim; part of the filtered count.

Properties

Applied

Rows inserted or updated.

public int Applied { get; }

Property Value

int

Attempted

Rows the statement actually tried, after the service dropped duplicates and anything belonging to a character or template it could not resolve.

public int Attempted { get; }

Property Value

int

Empty

An outcome with nothing to do — an empty or fully filtered batch.

public static BulkWriteResult Empty { get; }

Property Value

BulkWriteResult

Filtered

Rows the service declined to attempt. Non-zero means the caller's batch contained something it could not act on — see the remarks on BulkWriteResult.

public int Filtered { get; }

Property Value

int

IsComplete

True when every supplied row was written.

public bool IsComplete { get; }

Property Value

bool

Superseded

Rows attempted but not written, because the database already held a version at least as new. Benign.

public int Superseded { get; }

Property Value

int

Supplied

Rows the caller handed to the service.

public int Supplied { get; }

Property Value

int

Unowned

Of the Filtered rows, those refused because the writer does not hold the session claim of the character they belong to. Never attempted, like every filtered row.

public int Unowned { get; }

Property Value

int

Methods

ToString()

Returns a short description of the outcome, suitable for a log line.

public override string ToString()

Returns

string

Formatted counts.

Operators

operator +(BulkWriteResult, BulkWriteResult)

Adds two outcomes, for a service that writes its batch in more than one statement.

public static BulkWriteResult operator +(BulkWriteResult left, BulkWriteResult right)

Parameters

left BulkWriteResult

First outcome.

right BulkWriteResult

Second outcome.

Returns

BulkWriteResult

The combined outcome.