Skip to end of metadata
Go to start of metadata

STSdb 4.0 supports sparse files called XFile. We can work with XFile as we work with a standard .NET stream.

    using (IStorageEngine engine = STSdb.FromFile("test.stsdb4"))
        XFile file = engine.OpenXFile("file");
        Random random = new Random();
        byte[] buffer = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
        for (int i = 0; i < 100; i++)
            long position = random.Next();
            //writes some data on random positions
            file.Seek(position, SeekOrigin.Begin);
            file.Write(buffer, 0, buffer.Length);

XFile uses special XTable<long, byte[]> implementation to provide effective sparse file functionality.

The user can seek at any position – including beyond the end of the file and write to it. The engine keeps only the real pieces of data. When the user starts to read from the file, the engine fills on the fly the empty spaces with zeroes.

One storage engine can have many files.

Custom comparer and persist logic    Go to Home    Multi-threading