public byte[] Read(JToken key, Guid txId)
{
Guid mofiedByTx;
if (keysModifiedInTx.TryGetValue(key, out mofiedByTx) && mofiedByTx == txId)
{
Command command = operationsInTransactions.GetOrAdd(txId, new List<Command>()).LastOrDefault(
x => JTokenComparer.Instance.Equals(x.Key, key));
if (command != null)
{
switch (command.Type)
{
case CommandType.Put:
return ReadData(command.Position, command.Size);
case CommandType.Delete:
return null;
default:
throw new ArgumentOutOfRangeException();
}
}
}
PositionInFile pos;
if (keyToFilePos.TryGetValue(key, out pos) == false)
return null;
return ReadData(pos.Position, pos.Size);
}