Esempio n. 1
0
        public void CanPersist()
        {
            using (var context = new TransactionOperationContext(Env, 1024, 1024, SharedMultipleUseFlag.None))
            {
                var key1 = context.GetLazyString("orders/1");

                using (var tx = Env.WriteTransaction())
                {
                    var tree = tx.CreateTree("Filters");

                    using (var filter = new CollectionOfBloomFilters.BloomFilter64(0, tree, writable: true, allocator: context.Allocator))
                    {
                        Assert.True(filter.Add(key1));
                        Assert.Equal(1, filter.Count);
                    }

                    tx.Commit();
                }

                using (var tx = Env.WriteTransaction())
                {
                    var tree = tx.CreateTree("Filters");

                    using (var filter = new CollectionOfBloomFilters.BloomFilter64(0, tree, writable: false, allocator: context.Allocator))
                    {
                        Assert.False(filter.Add(key1));
                        Assert.Equal(1, filter.Count);
                    }
                }

                context.ReturnMemory(key1.AllocatedMemoryData);
            }
        }