csharptest / CSharpTest.Net.Collections

BPlusTree and other collections moved from http://code.google.com/p/csharptest-net
107 stars 48 forks source link

BTree fails to initialize when FileBlockSize > 4096 #17

Open benjaminc opened 4 years ago

benjaminc commented 4 years ago

If you have very large nodes (single-node size > 16 MB), you can increase the FileBlockSize to accommodate the larger nodes. This works fine when writing the data, however if you restart your process and it tries to initialize the BTree by reading the data from disk, it will fail in the TransactedCompoundFile.FileSection.Read method when it tries to validate the ActualBlocks count. This is because the Length written during the Write portion was greater than 16 MB, occupying more than 3 bytes, however the first byte was reserved for the header length. When trying to read the length back out, we only get the last 3 bytes of the length, which doesn't match the expected number of ActualBlocks, causing an error.