Example #1
0
        public MemoryDatabase(string name, ISerializer <T> modelSerializer, int blockSize)
            : base(name, modelSerializer)
        {
            dbStream   = new MemoryStream();
            RecStorage = new RecordStorage(new BlockStorage(
                                               dbStream, blockSize
                                               ));
            labels = new List <string>();

            IndexUtils.CreateUniqueIndex();
        }
Example #2
0
        public DiskDatabase(string name, ISerializer <T> modelSerializer, string directory, int blockSize)
            : base(name, modelSerializer)
        {
            this.dbDirectory = directory;

            // Create directory
            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            dbStream = new FileStream(
                GetMainDbPath(),
                FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None,
                blockSize
                );
            RecStorage = new RecordStorage(new BlockStorage(
                                               dbStream, blockSize
                                               ));

            IndexUtils.CreateUniqueIndex();
        }