Example #1
0
        public void OpenStorageWithWrongPageSizeShouldFail()
        {
            var factory = new StorageFactory();

            using (var storage = factory.CreateBPlusTreeStorage <ComparableKeyOf <Int32>, ValueOf <Int32> >(
                       p => BitConverter.GetBytes(p.Value),
                       p => BitConverter.ToInt32(p, 0),
                       p => BitConverter.GetBytes(p.Value),
                       p => BitConverter.ToInt32(p, 0),
                       BPlusTreeStorageSettings.Default()))
            {
                storage.CreateNew(StoragePath);
            }

            var differentSettings = BPlusTreeStorageSettings.Default();

            differentSettings.PageSize = PageSize._8192;

            using (var storage = factory.CreateBPlusTreeStorage <ComparableKeyOf <Int32>, ValueOf <Int32> >(
                       p => BitConverter.GetBytes(p.Value),
                       p => BitConverter.ToInt32(p, 0),
                       p => BitConverter.GetBytes(p.Value),
                       p => BitConverter.ToInt32(p, 0),
                       differentSettings))
            {
                storage.OpenExisting(StoragePath);
            }
        }
Example #2
0
        public void SuccessfulCreateCloseAndOpenStorage()
        {
            var factory = new StorageFactory();

            using (var storage = factory.CreateBPlusTreeStorage <ComparableKeyOf <Int32>, ValueOf <Int32> >(
                       p => BitConverter.GetBytes(p.Value),
                       p => BitConverter.ToInt32(p, 0),
                       p => BitConverter.GetBytes(p.Value),
                       p => BitConverter.ToInt32(p, 0),
                       BPlusTreeStorageSettings.Default()))
            {
                storage.CreateNew(StoragePath);
            }

            using (var storage = factory.CreateBPlusTreeStorage <ComparableKeyOf <Int32>, ValueOf <Int32> >(
                       p => BitConverter.GetBytes(p.Value),
                       p => BitConverter.ToInt32(p, 0),
                       p => BitConverter.GetBytes(p.Value),
                       p => BitConverter.ToInt32(p, 0),
                       BPlusTreeStorageSettings.Default()))
            {
                storage.OpenExisting(StoragePath);
            }

            using (var storage = factory.CreateBPlusTreeStorage <ComparableKeyOf <Int32>, ValueOf <Int32> >(
                       p => BitConverter.GetBytes(p.Value),
                       p => BitConverter.ToInt32(p, 0),
                       p => BitConverter.GetBytes(p.Value),
                       p => BitConverter.ToInt32(p, 0),
                       BPlusTreeStorageSettings.Default()))
            {
                storage.OpenOrCreate(StoragePath);
            }
        }
        private static IKeyValueStorage <ComparableKeyOf <int>, ValueOf <int> > GetIntStorage()
        {
            var factory = new StorageFactory();

            return(factory.CreateBPlusTreeStorage <int, int>(
                       BitConverter.GetBytes,
                       p => BitConverter.ToInt32(p, 0),
                       BPlusTreeStorageSettings.Default(sizeof(int))));
        }
Example #4
0
        public ObjectStorage(Configuration configuration, Collection collection)
        {
            var dirPath = Path.Combine(configuration.DataPath, collection.Name);

            Directory.CreateDirectory(dirPath);

            var settings = Utils.StorageSettings(configuration, 32);

            _storage = Factory.CreateBPlusTreeStorage(DocumentIdSerializer.Singleton, new NativeSerializer <T>(), settings);
            _storage.OpenOrCreate(dirPath);

            _topId = _storage.Max() ?? new DocumentId();
        }
        private IBPlusTreeKeyValueStorage <ComparableKeyOf <String>, ValueOf <String> > GetStorage()
        {
            var factory = new StorageFactory();

            var settings = BPlusTreeStorageSettings.Default();

            settings.CacheSettings.MaxCachedPages = 3000;
            settings.CacheSettings.MaxDirtyPages  = 2000;
            settings.ForcedWrites = false;
            settings.MaxKeySize   = 16;
            settings.PageSize     = PageSize._4096;

            return(factory.CreateBPlusTreeStorage(
                       p => Encoding.UTF8.GetBytes(p),
                       p => Encoding.UTF8.GetString(p),
                       p => Encoding.UTF8.GetBytes(p),
                       p => Encoding.UTF8.GetString(p),
                       settings));
        }
Example #6
0
 private IKeyValueStorage <ComparableKeyOf <string>, ValueOf <string> > GetStorage()
 {
     return(_storageFactory.CreateBPlusTreeStorage <string, string>(BPlusTreeStorageSettings.Default(255)));
 }