Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of https://github.com/Bobris/BTDB

  • Loading branch information...
commit d502c5485a487af5c4ce0ab3e9acfbcdaaef3b0a 2 parents a8718ee + 2d67cf6
@Bobris authored
View
12 BTDB/EventStoreLayer/AppendingEventStore.cs
@@ -63,7 +63,7 @@ public void Store(object metadata, IReadOnlyList<object> events)
out IDescriptorSerializerContext serializerContext, out BlockType blockType,
out int lenWithoutEndPadding, out ByteBuffer block)
{
- startOffset = (int) EndBufferLen + HeaderSize;
+ startOffset = (int)EndBufferLen + HeaderSize;
var writer = new ByteBufferWriter();
writer.WriteBlock(_zeroes, 0, startOffset);
serializerContext = Mapping;
@@ -95,7 +95,7 @@ public void Store(object metadata, IReadOnlyList<object> events)
}
else
{
- writer.WriteVUInt32((uint) events.Count);
+ writer.WriteVUInt32((uint)events.Count);
foreach (var o in events)
{
serializerContext.StoreObject(writer, o);
@@ -103,8 +103,8 @@ public void Store(object metadata, IReadOnlyList<object> events)
blockType |= BlockType.HasMoreEvents;
}
}
- lenWithoutEndPadding = (int) writer.GetCurrentPosition();
- writer.WriteBlock(_zeroes, 0, (int) (SectorSize - 1));
+ lenWithoutEndPadding = (int)writer.GetCurrentPosition();
+ writer.WriteBlock(_zeroes, 0, (int)(SectorSize - 1));
block = writer.Data;
if (CompressionStrategy.ShouldTryToCompress(lenWithoutEndPadding - startOffset))
{
@@ -114,7 +114,7 @@ public void Store(object metadata, IReadOnlyList<object> events)
blockType |= BlockType.Compressed;
Array.Copy(compressedBlock.Buffer, compressedBlock.Offset, block.Buffer, startOffset, compressedBlock.Length);
lenWithoutEndPadding = startOffset + compressedBlock.Length;
- Array.Copy(_zeroes, 0, block.Buffer, lenWithoutEndPadding, (int) SectorSize - 1);
+ Array.Copy(_zeroes, 0, block.Buffer, lenWithoutEndPadding, (int)SectorSize - 1);
}
}
}
@@ -146,7 +146,7 @@ public void FinalizeStore()
var startOffset = (int)EndBufferLen + HeaderSize;
if (EndBufferPosition + (ulong)startOffset <= File.MaxFileSize)
{
- WriteOneBlock(ByteBuffer.NewSync(new byte[SectorSize + HeaderSize], startOffset, 0), BlockType.LastBlock);
+ WriteOneBlock(ByteBuffer.NewSync(new byte[SectorSize * 2], startOffset, 0), BlockType.LastBlock);
}
EndBufferPosition = ulong.MaxValue;
KnownAsFinished = true;
View
14 BTDBTest/EventStoreTest.cs
@@ -57,6 +57,20 @@ public void CanFinalizeEventStoreAfterReadFromStart()
}
[Test]
+ public void CanFinalizeEventStoreOnEverySectorPosition()
+ {
+ for (int i = 4000; i < 4600; i++)
+ {
+ var manager = new EventStoreManager();
+ manager.CompressionStrategy = new NoCompressionStrategy();
+ var file1 = new MemoryEventFileStorage(4096, 8192);
+ var appender = manager.AppendToStore(file1);
+ appender.Store(null, new object[] { new byte[i] });
+ appender.Store(null, new object[] { new byte[7000] });
+ }
+ }
+
+ [Test]
public void CanFinalizeEventStoreAfterReadFromStartFirstNearlyFull()
{
var manager = new EventStoreManager();
Please sign in to comment.
Something went wrong with that request. Please try again.