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

 

using (IStorageEngine engine = STSdb.FromFile("stsdb4.sys", "stsdb4.dat"))
    {
        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);
        }

        file.Flush();
        engine.Commit();
    }

 

XFile uses special XIndex<long, byte[]> implementation and provides effective sparse file functionality. Thus, in one storage engine developers can combine using of XIndex tables and of XFile sparse files.

Last edited Aug 17, 2013 at 10:02 AM by SvetoslavMateev, version 2

Comments

No comments yet.