Ejemplo n.º 1
0
 public virtual void Dispose()
 {
     Factory.Disposing -= HandleFactoryDisposing;
     if (BaseContainer != null)
     {
         BaseContainer.Dispose();
     }
 }
Ejemplo n.º 2
0
        public virtual void Dispose()
        {
            Factory.Disposing -= HandleFactoryDisposing;

            /*
             * AdditionalContainers are null except for GenericIOContainers
             * on multi pin types, which handle all their pin disposing internally already
             * so only call BaseContainer.Dispose on single pin types
             */
            if (BaseContainer != null && AssociatedContainers == null)
            {
                BaseContainer.Dispose();
            }
        }
Ejemplo n.º 3
0
        public void CouldTryGetBlockSingleChunkBench()
        {
            var count  = (int)TestUtils.GetBenchCount(50_000_000, 50_000);
            var rounds = TestUtils.GetBenchCount(20, 2);

            // for this test capacity is irrelevant - interpolation search hits exact position on first try
            var capacity = count / 100;
            var bc       = new BaseContainer <long>();

            var rm = BuffersTestHelper.CreateFilledRM(capacity);
            var vs = RetainedVec.Create(rm, 0, rm.Length);

            var block = DataBlock.Create(rowIndex: vs, rowLength: capacity);

            bc.Data = block;

            for (int r = 0; r < rounds; r++)
            {
                using (Benchmark.Run("TryGetBlock", count))
                {
                    var m = count / capacity;
                    for (int _ = 0; _ < m; _++)
                    {
                        for (long i = 0; i < capacity; i++)
                        {
                            var ival  = vs.UnsafeReadUnaligned <long>((IntPtr)i);
                            var ival2 = vs.UnsafeReadUnaligned <long>((IntPtr)capacity - 1);
                            var ival3 = Unsafe.Add <long>(ref vs.UnsafeGetRef <long>(), capacity - 1);
                            var ival4 = Unsafe.Add <long>(ref (bc.Data as DataBlock).RowKeys.UnsafeGetRef <long>(), capacity - 1);
                            var found = bc.TryGetBlock(i, out var c, out var ci);
                            if (!found ||
                                !ReferenceEquals(block, c) ||
                                i != ci
                                )
                            {
                                Assert.Fail();
                            }
                        }
                    }
                }
            }

            Benchmark.Dump();
            bc.Dispose();
        }
Ejemplo n.º 4
0
        public void CouldTryFindBlockAtSingleChunkBench()
        {
            var count  = 50_000_000;
            var rounds = 20;

            // for this test capacity is irrelevant - interpolation search hits exact position on first try
            var capacity = count / 100;
            var bc       = new BaseContainer <int>();
            var rm       = ArrayMemory <int> .Create(Enumerable.Range(0, capacity).ToArray());

            var vs = VecStorage.Create(rm, 0, rm.Length);

            var block = DataBlock.Create(rowIndex: vs, rowLength: vs.Vec.Length);

            bc.Data = block;

            for (int r = 0; r < rounds; r++)
            {
                using (Benchmark.Run("TryFindChunkAt", count))
                {
                    var m = count / capacity;
                    for (int _ = 0; _ < m; _++)
                    {
                        for (int i = 1; i < capacity; i++)
                        {
                            var searchIndexRef = i;
                            var found          = bc.TryFindBlockAt(ref searchIndexRef, Lookup.LE, out var c, out var ci);
                            if (!found ||
                                !ReferenceEquals(block, c) ||
                                i != ci ||
                                i != searchIndexRef
                                )
                            {
                                Assert.Fail();
                            }
                        }
                    }
                }
            }

            Benchmark.Dump();
            bc.Dispose();
        }
Ejemplo n.º 5
0
        public void CouldTryFindBlockAtSingleChunkBench()
        {
            var count  = (int)TestUtils.GetBenchCount(50_000_000, 50_000);
            var rounds = TestUtils.GetBenchCount(20, 2);

            // for this test capacity is irrelevant - interpolation search hits exact position on first try
            var capacity = count / 100;
            var bc       = new BaseContainer <long>();
            var rm       = BuffersTestHelper.CreateFilledRM(capacity);
            var vs       = RetainedVec.Create(rm, 0, rm.Length);

            var block = DataBlock.Create(rowIndex: vs, rowLength: capacity);

            bc.Data = block;

            for (int r = 0; r < rounds; r++)
            {
                using (Benchmark.Run("TryFindChunkAt", count))
                {
                    var m = count / capacity;
                    for (int _ = 0; _ < m; _++)
                    {
                        for (long i = 1; i < capacity; i++)
                        {
                            var searchIndexRef = i;
                            var found          = bc.TryFindBlockAt(ref searchIndexRef, Lookup.LE, out var c, out var ci);
                            if (!found ||
                                !ReferenceEquals(block, c) ||
                                i != ci ||
                                i != searchIndexRef
                                )
                            {
                                Assert.Fail();
                            }
                        }
                    }
                }
            }

            Benchmark.Dump();
            bc.Dispose();
        }
Ejemplo n.º 6
0
        public void CouldTryGetBlockAtSingleChunk()
        {
            var capacity = 100;
            var bc       = new BaseContainer <int>();

            var rm = BuffersTestHelper.CreateFilledRM(capacity);
            var vs = RetainedVec.Create(rm, 0, rm.Length);

            var block = DataBlock.Create(rowIndex: vs, rowLength: vs.Vec.Length / 2);

            bc.Data = block;

            var searchIndex = 40;
            var found       = bc.TryGetBlockAt(searchIndex, out var dataBlock, out var ci);

            Assert.IsTrue(found);
            Assert.AreSame(block, dataBlock);
            Assert.AreEqual(searchIndex, ci);

            bc.Dispose();
        }
Ejemplo n.º 7
0
        public void CouldTryGetBlockAtSingleChunk()
        {
            var capacity = 100;
            var bc       = new BaseContainer <int>();

            var rm = ArrayMemory <int> .Create(Enumerable.Range(0, capacity).ToArray());

            var vs = VecStorage.Create(rm, 0, rm.Length);

            var block = DataBlock.Create(rowIndex: vs, rowLength: vs.Vec.Length / 2);

            bc.Data = block;

            var searchIndex = 40;
            var found       = bc.TryGetBlockAt(searchIndex, out var dataBlock, out var ci);

            Assert.IsTrue(found);
            Assert.AreSame(block, dataBlock);
            Assert.AreEqual(searchIndex, ci);

            bc.Dispose();
        }
Ejemplo n.º 8
0
        public void CouldTryGetBlockSingleChunk()
        {
            var capacity = 100;
            var bc       = new BaseContainer <long>();
            var rm       = ArrayMemory <long> .Create(Enumerable.Range(0, capacity).Select(x => (long)x).ToArray());

            var vs = VecStorage.Create(rm, 0, rm.Length);

            var block = DataBlock.Create(rowIndex: vs, rowLength: vs.Vec.Length / 2);

            bc.Data = block;

            var searchIndex    = 40L;
            var searchIndexRef = searchIndex;
            var found          = bc.TryGetBlock(searchIndexRef, out var c, out var ci);

            Assert.IsTrue(found);
            Assert.AreSame(block, c);
            Assert.AreEqual(searchIndex, ci);
            Assert.AreEqual(searchIndex, searchIndexRef);
            bc.Dispose();
        }
Ejemplo n.º 9
0
        public void CouldTryFindBlockAtSingleChunk()
        {
            var capacity = 100;
            var bc       = new BaseContainer <long>();

            var rm = BuffersTestHelper.CreateFilledRM(capacity);
            var vs = RetainedVec.Create(rm, 0, rm.Length);

            var block = DataBlock.Create(rowIndex: vs, rowLength: vs.Vec.Length / 2);

            bc.Data = block;

            var searchIndex    = 40L;
            var searchIndexRef = searchIndex;
            var found          = bc.TryFindBlockAt(ref searchIndexRef, Lookup.LT, out var c, out var ci);

            Assert.IsTrue(found);
            Assert.AreSame(block, c);
            Assert.AreEqual(searchIndex - 1, ci);
            Assert.AreEqual(searchIndex - 1, searchIndexRef);

            bc.Dispose();
        }
Ejemplo n.º 10
0
        public void CouldTryFindBlockAtSingleChunk()
        {
            var capacity = 100;
            var bc       = new BaseContainer <long>();

            var rm = ArrayMemory <long> .Create(Enumerable.Range(0, capacity).Select(x => (long)x).ToArray(), externallyOwned : true);

            var vs = VectorStorage.Create(rm, 0, rm.Length, 1);

            var block = DataBlock.Create(rowIndex: vs, rowLength: vs.Length / 2);

            bc.DataBlock = block;

            var searchIndex    = 40L;
            var searchIndexRef = searchIndex;
            var found          = bc.TryFindBlockAt(ref searchIndexRef, Lookup.LT, out var c, out var ci);

            Assert.IsTrue(found);
            Assert.AreSame(block, c);
            Assert.AreEqual(searchIndex - 1, ci);
            Assert.AreEqual(searchIndex - 1, searchIndexRef);

            bc.Dispose();
        }